-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add configuration settings for collections subscriptions. (PP-1850) #2153
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2153 +/- ##
=======================================
Coverage 91.11% 91.11%
=======================================
Files 363 363
Lines 41297 41300 +3
Branches 8841 8841
=======================================
+ Hits 37629 37632 +3
Misses 2406 2406
Partials 1262 1262 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments with a couple questions on this one
), | ||
required=False, | ||
), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be adding these settings for every circulation API? It seems like we only really want them for OPDS importer based APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they could be handy more generally; but, I'm fine moving them to the OPDS collections setting hierarchy for now.
I'm planning to implement the subscription (vs. association) concept across all collection types, but the absence of these settings on a collection would be interpreted as always subscribed (i.e., no restriction).
@@ -570,6 +570,33 @@ class BaseCirculationApiSettings(BaseSettings): | |||
) | |||
} | |||
|
|||
subscription_activation_date: str | None = FormField( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are coming in as dates, should we be setting the type here to reflect that, rather then just a generic str
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did try using subscription_activation_date: datetime.date | None = FormField( ...
for these, but ran into type errors in Pydantic.
I can dig into that some more as I do the implementation.
I was thinking about this one, and I'm wondering if we want to store the subscription end dates as full datetime. We are going to need a particular time to say a subscription ends, and we will need to think about what timezone that should be in. A couple options I was thinking about:
|
My original thought on this was to use UTC to make this easier to manage with the distributors, who might also be enforcing their subscriptions. It would make things simpler. If libraries are able to negotiate a single "grace" day on each end of the subscription. We could always add an offset later. |
5f5febf
to
413c3bd
Compare
@jonathangreen Would you take another look at this one? Especially the |
I think it would be good to elaborate a bit more about the details of the issue you are working around in pydantic. I added a little test to try to understand what was happening, and it seemed like pydantic was working fine in this instance with a diff --git a/tests/manager/api/admin/test_form_data.py b/tests/manager/api/admin/test_form_data.py
index 1c1a02023..d4a8ad220 100644
diff --git a/tests/manager/api/admin/test_form_data.py b/tests/manager/api/admin/test_form_data.py
index 1c1a02023..d4a8ad220 100644
--- a/tests/manager/api/admin/test_form_data.py
+++ b/tests/manager/api/admin/test_form_data.py
@@ -1,3 +1,5 @@
+import datetime
+
from werkzeug.datastructures import ImmutableMultiDict
from palace.manager.api.admin.form_data import ProcessFormData
@@ -46,6 +48,22 @@ class MockSettings(BaseSettings):
description="Another date.",
),
)
+ field6: datetime.date | None = FormField(
+ None,
+ form=ConfigurationFormItem(
+ label="Another date field with a date type",
+ type=ConfigurationFormItemType.DATE,
+ description="A python date.",
+ ),
+ )
+ field7: datetime.date | None = FormField(
+ None,
+ form=ConfigurationFormItem(
+ label="Another date field with a date type",
+ type=ConfigurationFormItemType.DATE,
+ description="A python date.",
+ ),
+ )
def test_get_settings():
@@ -59,6 +77,8 @@ def test_get_settings():
("field3", "value5"),
("field4", "2024-10-23"),
("field5", ""),
+ ("field6", "2024-10-23"),
+ ("field7", ""),
]
)
settings = ProcessFormData.get_settings(MockSettings, data)
@@ -67,3 +87,5 @@ def test_get_settings():
assert settings.field3 == "value5"
assert settings.field4 == "2024-10-23"
assert settings.field5 is None
+ assert settings.field6 == datetime.date(2024, 10, 23)
+ assert settings.field7 is None |
413c3bd
to
9030d8f
Compare
@jonathangreen Well, you're right! It is working without errors now. A quick check doesn't show anything pertinent that has changed since this PR first went in, so I'm a little baffled. I had similar params in when I was initially testing this, too. SMH At any rate, this is ready for another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
Description
Adds start and end date configuration settings for collection subscriptions.
NB: Submitting this PR as draft, since additional work is needed fully implement the subscription functionality.
Motivation and Context
Support automatic activation/deactivation of library associations with a collection.
[Jira PP-1850]
How Has This Been Tested?
Checklist