Skip to content

Commit

Permalink
Add configuration settings for collections subscriptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdilauro committed Nov 21, 2024
1 parent 1d1b4eb commit 341649a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/palace/manager/api/circulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,33 @@ class BaseCirculationApiSettings(BaseSettings):
)
}

subscription_activation_date: str | None = FormField(
default=None,
form=ConfigurationFormItem(
label=_("Collection Subscription Activation Date"),
type=ConfigurationFormItemType.DATE,
description=(
"A date before which this collection is considered inactive. Associated libraries"
" will not be considered to be subscribed until this date). If not specified,"
" it will not restrict any associated library's subscription status."
),
required=False,
),
)
subscription_expiration_date: str | None = FormField(
default=None,
form=ConfigurationFormItem(
label=_("Collection Subscription Expiration Date"),
type=ConfigurationFormItemType.DATE,
description=(
"A date after which this collection is considered inactive. Associated libraries"
" will not be considered to be subscribed beyond this date). If not specified,"
" it will not restrict any associated library's subscription status."
),
required=False,
),
)


SettingsType = TypeVar("SettingsType", bound=BaseCirculationApiSettings, covariant=True)
LibrarySettingsType = TypeVar("LibrarySettingsType", bound=BaseSettings, covariant=True)
Expand Down
1 change: 1 addition & 0 deletions src/palace/manager/integration/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class ConfigurationFormItemType(Enum):
"""Enumeration of configuration setting types"""

TEXT = None
DATE = "date-picker"
TEXTAREA = "textarea"
SELECT = "select"
LIST = "list"
Expand Down
20 changes: 20 additions & 0 deletions tests/manager/api/admin/test_form_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ class MockSettings(BaseSettings):
label="Field 3",
),
)
field4: str | None = FormField(
None,
form=ConfigurationFormItem(
label="Date field",
type=ConfigurationFormItemType.DATE,
description="A date.",
),
)
field5: str | None = FormField(
None,
form=ConfigurationFormItem(
label="Another date field",
type=ConfigurationFormItemType.DATE,
description="Another date.",
),
)


def test_get_settings():
Expand All @@ -41,9 +57,13 @@ def test_get_settings():
("field2_value3", "blah blah"),
("field2_value4", "blah blah blah"),
("field3", "value5"),
("field4", "2024-10-23"),
("field5", ""),
]
)
settings = ProcessFormData.get_settings(MockSettings, data)
assert settings.field1 == ["value1", "value2"]
assert settings.field2 == ["value3", "value4"]
assert settings.field3 == "value5"
assert settings.field4 == "2024-10-23"
assert settings.field5 is None

0 comments on commit 341649a

Please sign in to comment.