Skip to content
Snippets Groups Projects

Improve automatic emails with temporary urls

Merged Flavio TARSETTI requested to merge 542_temporary_urls into master
All threads resolved!
Files
12
@@ -57,15 +57,10 @@ class Command(BaseCommand):
self.stdout.write('Clean expired temporary urls operation canceled')
sys.exit(1)
temporary_urls = TemporaryUrl.objects.all()
count = 0
for temporary_url in temporary_urls:
now = datetime.datetime.now()
if temporary_url.expires < now:
count+=1
temporary_url.delete()
self.stdout.write('{} Expired temporary url(s) successfully cleaned/'.format(count) + '{} Total temporary url(s) checked'.format(temporary_urls.count()))
temporary_urls_count = TemporaryUrl.objects.all().count()
now = datetime.datetime.now()
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))
def get_input_data(self, message, default=None):
Loading