diff --git a/src/caselawclient/models/documents.py b/src/caselawclient/models/documents.py
index cee76437..7e08c315 100644
--- a/src/caselawclient/models/documents.py
+++ b/src/caselawclient/models/documents.py
@@ -39,7 +39,12 @@ class UnparsableDate(Warning):
""" This document has been published and should be considered publicly visible. """
DOCUMENT_STATUS_IN_PROGRESS = "In progress"
-""" This document has not been published or put on hold, and should be progressing through the document pipeline. """
+""" This document has not been published or put on hold, and has been picked up by an editor and
+ should be progressing through the document pipeline. """
+
+DOCUMENT_STATUS_NEW = "New"
+""" This document isn't published, on hold, or assigned, and can be picked up by an editor in the future. """
+
DOCUMENT_COLLECTION_URI_JUDGMENT = "judgment"
DOCUMENT_COLLECTION_URI_PRESS_SUMMARY = "press-summary"
@@ -386,7 +391,10 @@ def status(self) -> str:
if self.is_held:
return DOCUMENT_STATUS_HOLD
- return DOCUMENT_STATUS_IN_PROGRESS
+ if self.assigned_to:
+ return DOCUMENT_STATUS_IN_PROGRESS
+
+ return DOCUMENT_STATUS_NEW
def enrich(self) -> None:
notify_changed(
diff --git a/src/caselawclient/responses/search_result.py b/src/caselawclient/responses/search_result.py
index c4ab7fa4..5bafc45c 100644
--- a/src/caselawclient/responses/search_result.py
+++ b/src/caselawclient/responses/search_result.py
@@ -22,6 +22,7 @@ class EditorStatus(Enum):
NEW = "new"
IN_PROGRESS = "in progress"
HOLD = "hold"
+ PUBLISHED = "published"
class EditorPriority(Enum):
@@ -97,6 +98,13 @@ def editor_hold(self) -> str:
return self._get_xpath_match_string("//editor-hold/text()")
+ @property
+ def is_published(self) -> bool:
+ """
+ :return:
+ """
+ return self._get_xpath_match_string("//published/text()") == "true"
+
@property
def editor_priority(self) -> str:
"""
@@ -130,6 +138,8 @@ def editor_status(
:return: The editor status based on the metadata
"""
+ if self.is_published:
+ return EditorStatus.PUBLISHED.value
if self.editor_hold == "true":
return EditorStatus.HOLD.value
if self.assigned_to:
diff --git a/src/caselawclient/xquery/get_properties_for_search_results.xqy b/src/caselawclient/xquery/get_properties_for_search_results.xqy
index 37947b14..b57db9a3 100644
--- a/src/caselawclient/xquery/get_properties_for_search_results.xqy
+++ b/src/caselawclient/xquery/get_properties_for_search_results.xqy
@@ -8,7 +8,8 @@ let $properties := (
fn:QName("", 'source-name'),
fn:QName("", 'source-email'),
fn:QName("", 'transfer-consignment-reference'),
- fn:QName("", 'transfer-received-at')
+ fn:QName("", 'transfer-received-at'),
+ fn:QName("", 'published')
)
return {
diff --git a/tests/models/test_documents.py b/tests/models/test_documents.py
index a196bde1..c2f79888 100644
--- a/tests/models/test_documents.py
+++ b/tests/models/test_documents.py
@@ -13,6 +13,7 @@
from caselawclient.models.documents import (
DOCUMENT_STATUS_HOLD,
DOCUMENT_STATUS_IN_PROGRESS,
+ DOCUMENT_STATUS_NEW,
DOCUMENT_STATUS_PUBLISHED,
CannotPublishUnpublishableDocument,
Document,
@@ -155,19 +156,28 @@ def test_judgment_content_as_xml_tree(self, mock_api_client):
assert etree.tostring(document.content_as_xml_tree) == b""
def test_document_status(self, mock_api_client):
+ new_document = Document("test/1234", mock_api_client)
+ new_document.is_held = False
+ new_document.is_published = False
+ new_document.assigned_to = ""
+ assert new_document.status == DOCUMENT_STATUS_NEW
+
in_progress_document = Document("test/1234", mock_api_client)
in_progress_document.is_held = False
in_progress_document.is_published = False
+ in_progress_document.assigned_to = "duck"
assert in_progress_document.status == DOCUMENT_STATUS_IN_PROGRESS
on_hold_document = Document("test/1234", mock_api_client)
on_hold_document.is_held = True
on_hold_document.is_published = False
+ on_hold_document.assigned_to = "duck"
assert on_hold_document.status == DOCUMENT_STATUS_HOLD
published_document = Document("test/1234", mock_api_client)
published_document.is_held = False
published_document.is_published = True
+ published_document.assigned_to = "duck"
assert published_document.status == DOCUMENT_STATUS_PUBLISHED
def test_document_best_identifier(self, mock_api_client):
diff --git a/tests/responses/test_search_result.py b/tests/responses/test_search_result.py
index 1f15a494..b4e698cd 100644
--- a/tests/responses/test_search_result.py
+++ b/tests/responses/test_search_result.py
@@ -113,6 +113,7 @@ def test_init(self):
"test_consignment_reference"
"false"
"30"
+ "true"
"2023-01-26T14:17:02Z"
""
""
@@ -127,6 +128,7 @@ def test_init(self):
assert meta.editor_priority == "30"
assert meta.submission_datetime == datetime.datetime(2023, 1, 26, 14, 17, 2)
assert meta.last_modified == "test_last_modified"
+ assert meta.is_published is True
def test_empty_properties_init(self):
"""
@@ -150,17 +152,24 @@ def test_empty_properties_init(self):
assert meta.editor_priority == EditorPriority.MEDIUM.value
assert meta.submission_datetime == datetime.datetime.min
assert meta.last_modified == "test_last_modified"
+ assert meta.is_published is False
@pytest.mark.parametrize(
- "editor_hold, assigned_to, expected_editor_status",
+ "published_string, editor_hold, assigned_to, expected_editor_status",
[
- ("false", "", EditorStatus.NEW),
- ("false", "TestEditor", EditorStatus.IN_PROGRESS),
- ("true", "", EditorStatus.HOLD),
- ("true", "TestEditor", EditorStatus.HOLD),
+ ("", "false", "", EditorStatus.NEW),
+ ("", "false", "TestEditor", EditorStatus.IN_PROGRESS),
+ ("", "true", "", EditorStatus.HOLD),
+ ("", "true", "TestEditor", EditorStatus.HOLD),
+ ("true", "false", "", EditorStatus.PUBLISHED),
+ ("true", "false", "TestEditor", EditorStatus.PUBLISHED),
+ ("true", "true", "", EditorStatus.PUBLISHED),
+ ("true", "true", "TestEditor", EditorStatus.PUBLISHED),
],
)
- def test_editor_status(self, assigned_to, editor_hold, expected_editor_status):
+ def test_editor_status(
+ self, published_string, assigned_to, editor_hold, expected_editor_status
+ ):
"""
GIVEN editor_hold and assigned_to values
WHEN creating a SearchResultMetadata instance
@@ -171,6 +180,7 @@ def test_editor_status(self, assigned_to, editor_hold, expected_editor_status):
""
f"{assigned_to}"
f"{editor_hold}"
+ f"{published_string}"
""
""
)