Skip to content

Commit fe029c2

Browse files
authored
Merge pull request #382 from RockefellerArchiveCenter/development
Adds logic accounting for rights statements with no end date
2 parents 10a6713 + 2df13f6 commit fe029c2

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

process_request/helpers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ def get_active_rights_acts(acts):
2222
"""Evaluates rights statement act end dates to determine if it is still active."""
2323
current_date = datetime.now()
2424
for idx, act in reversed(list(enumerate(acts))):
25-
statement_end = datetime.strptime(act['end_date'], "%Y-%m-%d")
26-
if (current_date > statement_end):
27-
acts.pop(idx)
25+
if act.get('end_date'):
26+
statement_end = datetime.strptime(act['end_date'], "%Y-%m-%d")
27+
if (current_date > statement_end):
28+
acts.pop(idx)
2829
return acts
2930

3031

process_request/tests.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,54 @@ def test_get_active_rights_acts(self):
142142
output = get_active_rights_acts(acts)
143143
self.assertEqual(output, expected)
144144

145+
acts = [
146+
{
147+
'start_date': '1886-01-01',
148+
'end_date': '1967-12-31',
149+
'created_by': 'aquarius',
150+
'last_modified_by': 'aquarius',
151+
'create_time': '2022-06-08T20:55:05Z',
152+
'system_mtime': '2022-06-08T20:55:05Z',
153+
'user_mtime': '2022-06-08T20:55:05Z',
154+
'act_type': 'publish',
155+
'restriction':
156+
'disallow',
157+
'jsonmodel_type':
158+
'rights_statement_act',
159+
'notes': []
160+
},
161+
{
162+
'start_date': '1886-01-01',
163+
'created_by': 'aquarius',
164+
'last_modified_by': 'aquarius',
165+
'create_time': '2022-06-08T20:55:05Z',
166+
'system_mtime': '2022-06-08T20:55:05Z',
167+
'user_mtime': '2022-06-08T20:55:05Z',
168+
'act_type': 'publish',
169+
'restriction':
170+
'disallow',
171+
'jsonmodel_type':
172+
'rights_statement_act',
173+
'notes': []
174+
}]
175+
expected = [
176+
{
177+
'start_date': '1886-01-01',
178+
'created_by': 'aquarius',
179+
'last_modified_by': 'aquarius',
180+
'create_time': '2022-06-08T20:55:05Z',
181+
'system_mtime': '2022-06-08T20:55:05Z',
182+
'user_mtime': '2022-06-08T20:55:05Z',
183+
'act_type': 'publish',
184+
'restriction':
185+
'disallow',
186+
'jsonmodel_type':
187+
'rights_statement_act',
188+
'notes': []
189+
}]
190+
output = get_active_rights_acts(acts)
191+
self.assertEqual(output, expected)
192+
145193
@patch("asnake.client.web_client.ASnakeClient")
146194
def test_get_resource_creators(self, mock_client):
147195
mock_client.get.return_value.json.return_value = {"results": [{"title": "Philanthropy Foundation"}]}

0 commit comments

Comments
 (0)