Skip to content
Snippets Groups Projects
Commit 1004f75a authored by Flavio TARSETTI's avatar Flavio TARSETTI
Browse files

[accounts][models/management-commands] Fixed typos

parent edcb7941
No related branches found
No related tags found
1 merge request!328Improve automatic emails with temporary urls
Pipeline #39860 passed
...@@ -59,7 +59,7 @@ class Command(BaseCommand): ...@@ -59,7 +59,7 @@ class Command(BaseCommand):
temporary_urls_count = TemporaryUrl.objects.all().count() temporary_urls_count = TemporaryUrl.objects.all().count()
now = datetime.datetime.now() now = datetime.datetime.now()
count = TemporaryUrl.objects.filter(expires__lt=now).delete()[0] count, _ = TemporaryUrl.objects.filter(expires__lt=now).delete()
self.stdout.write('{} Expired temporary url(s) successfully cleaned/'.format(count) + '{} Total temporary url(s) checked'.format(temporary_urls_count)) self.stdout.write('{} Expired temporary url(s) successfully cleaned/'.format(count) + '{} Total temporary url(s) checked'.format(temporary_urls_count))
......
...@@ -35,6 +35,12 @@ import random ...@@ -35,6 +35,12 @@ import random
import string import string
import datetime import datetime
# ------------------------------------------------------------------------------
# Constants
TEMPORARY_URL_LENGTH = 32
# ------------------------------------------------------------------------------
class AccountSettingsManager(models.Manager): class AccountSettingsManager(models.Manager):
def get_by_natural_key(self, owner): def get_by_natural_key(self, owner):
...@@ -158,10 +164,9 @@ class TemporaryUrlManager(models.Manager): ...@@ -158,10 +164,9 @@ class TemporaryUrlManager(models.Manager):
# Actions that result creating the object # Actions that result creating the object
# url_hash creation # url_hash creation
length = 32
url_hash = "".join( url_hash = "".join(
random.choice(string.ascii_letters + string.digits) # nosec random.choice(string.ascii_letters + string.digits) # nosec
for _ in range(length) for _ in range(TEMPORARY_URL_LENGTH)
) )
now = datetime.datetime.now() now = datetime.datetime.now()
expiration_date_delta = datetime.timedelta( expiration_date_delta = datetime.timedelta(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment