Skip to content

Commit

Permalink
Rename max_age to max_ttl, ahead of adding min_ttl
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejalim committed Dec 4, 2024
1 parent 3698592 commit 75ea3ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions wagtaildraftsharing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@


class WagtaildraftsharingLinkManager(models.Manager):
def get_or_create_for_revision(self, *, revision, user, max_age=None):
if max_age is None:
max_age = draftsharing_settings.MAX_AGE
def get_or_create_for_revision(self, *, revision, user, max_ttl=None):
if max_ttl is None:
max_ttl = draftsharing_settings.MAX_AGE
key = uuid.uuid4()
if max_age > 0:
active_until = tz_aware_utc_now() + timedelta(seconds=max_age)
if max_ttl > 0:
active_until = tz_aware_utc_now() + timedelta(seconds=max_ttl)
else:
active_until = None
sharing_link, created = WagtaildraftsharingLink.objects.get_or_create(
Expand Down
12 changes: 6 additions & 6 deletions wagtaildraftsharing/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def test_create_sharing_link_view__max_age_from_settings(self):
(-1, None),
)

for max_age, expected_expiry in max_ages_and_expected_expiries:
with self.subTest(max_age=max_age, expected_expiry=expected_expiry):
for max_ttl, expected_expiry in max_ages_and_expected_expiries:
with self.subTest(max_ttl=max_ttl, expected_expiry=expected_expiry):
with patch.object(
wagtaildraftsharing.models.draftsharing_settings, "MAX_AGE", max_age
wagtaildraftsharing.models.draftsharing_settings, "MAX_AGE", max_ttl
):
revision = self.create_revision()

Expand Down Expand Up @@ -83,12 +83,12 @@ def test_create_sharing_link_view__max_age_from_params(self):
(-1, None),
)

for max_age, expected_expiry in max_ages_and_expected_expiries:
with self.subTest(max_age=max_age, expected_expiry=expected_expiry):
for max_ttl, expected_expiry in max_ages_and_expected_expiries:
with self.subTest(max_ttl=max_ttl, expected_expiry=expected_expiry):
revision = self.create_revision()

link = WagtaildraftsharingLink.objects.get_or_create_for_revision(
revision=revision, user=self.test_user, max_age=max_age
revision=revision, user=self.test_user, max_ttl=max_ttl
)

assert link.active_until == expected_expiry, (
Expand Down

0 comments on commit 75ea3ca

Please sign in to comment.