-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! ✨(dashboard) add signals on delivery point creation
- Loading branch information
Showing
11 changed files
with
93 additions
and
25 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""Dashboard consent app settings.""" | ||
|
||
from django.conf import settings | ||
|
||
from .utils import get_end_date | ||
|
||
# `CONSENT_END_DATE` determines the default end date for the period consents | ||
# (`datetime` format). | ||
# This value is calculated dynamically via `apps.consent.utils.get_end_date()` | ||
# By default `apps.consent.utils.get_end_date()` return the last day of current year. | ||
# You can specify the number of days to add to the current date to calculate the end | ||
# date. | ||
# ie: `get_end_date(90)` will return the current date + 90 days. | ||
CONSENT_END_DATE = getattr(settings, "CONSENT_END_DATE", get_end_date()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Dashboard consent utils tests.""" | ||
|
||
from datetime import datetime, timedelta, timezone | ||
|
||
import pytest | ||
|
||
from apps.consent.utils import get_end_date | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_get_end_date_with_days(): | ||
"""Test `get_end_date` function when days argument is provided.""" | ||
days = 10 | ||
end_date = get_end_date(days=days).replace(microsecond=0) | ||
expected_date = datetime.now().replace(tzinfo=timezone.utc) + timedelta(days=days) | ||
assert end_date == expected_date.replace(microsecond=0) | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_get_end_date_without_days(): | ||
"""Test `get_end_date` function when days argument is not provided.""" | ||
end_date = get_end_date().replace(microsecond=0) | ||
current_year = datetime.now().year | ||
expected_date = datetime( | ||
year=current_year, | ||
month=12, | ||
day=31, | ||
hour=23, | ||
minute=59, | ||
second=59, | ||
tzinfo=timezone.utc, | ||
) | ||
assert end_date == expected_date.replace(microsecond=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Dashboard consent app utils.""" | ||
|
||
from datetime import datetime, timedelta, timezone | ||
|
||
|
||
def get_end_date(days: int | None = None) -> datetime: | ||
"""Get the end date of the consent period. | ||
Returns a specific end date based on the number of days provided, | ||
or the default end of the year date if no argument is passed. | ||
Parameters: | ||
days (int | None): An optional number of days to calculate the future date. | ||
If None, the function defaults to the end of the current year. | ||
""" | ||
if days: | ||
return datetime.now().replace(tzinfo=timezone.utc) + timedelta(days=days) | ||
|
||
return datetime.now().replace( | ||
month=12, day=31, hour=23, minute=59, second=59, tzinfo=timezone.utc | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters