From f708395e2bac9727910aeff05a1589ffe393a406 Mon Sep 17 00:00:00 2001
From: Daniel Ursache Dogariu
Date: Mon, 27 May 2024 18:13:05 +0300
Subject: [PATCH] Use minutes instead of hours for download time delta
---
backend/donations/views/api.py | 4 +++-
backend/donations/views/my_account.py | 4 ++--
backend/redirectioneaza/settings.py | 4 ++--
backend/templates/v1/ngo/donations-view.html | 6 +++---
terraform/main.tf | 4 ++--
5 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/backend/donations/views/api.py b/backend/donations/views/api.py
index f1547a1c..c5d9656d 100644
--- a/backend/donations/views/api.py
+++ b/backend/donations/views/api.py
@@ -173,7 +173,9 @@ def post(self, request, *args, **kwargs):
try:
latest_job: Job = Job.objects.filter(ngo=ngo).latest("date_created")
- form_retry_threshold = timezone.now() - timezone.timedelta(hours=settings.TIMEDELTA_FORMS_DOWNLOAD_HOURS)
+ form_retry_threshold = timezone.now() - timezone.timedelta(
+ minutes=settings.TIMEDELTA_FORMS_DOWNLOAD_MINUTES
+ )
if latest_job.status != JobStatusChoices.ERROR and latest_job.date_created > form_retry_threshold:
return redirect(reverse("contul-meu"))
diff --git a/backend/donations/views/my_account.py b/backend/donations/views/my_account.py
index ac490ac5..995b4144 100644
--- a/backend/donations/views/my_account.py
+++ b/backend/donations/views/my_account.py
@@ -133,7 +133,7 @@ def get(self, request: HttpRequest, *args, **kwargs):
timedelta = timezone.timedelta(0)
if last_job_status != JobStatusChoices.ERROR:
- timedelta = timezone.timedelta(hours=settings.TIMEDELTA_FORMS_DOWNLOAD_HOURS)
+ timedelta = timezone.timedelta(minutes=settings.TIMEDELTA_FORMS_DOWNLOAD_MINUTES)
if last_job_date > now - timedelta:
last_job_was_recent = True
@@ -159,7 +159,7 @@ def get(self, request: HttpRequest, *args, **kwargs):
"disable_new_download": disable_forms_download,
"disable_past_download": disable_past_download,
"contact_email": settings.CONTACT_EMAIL_ADDRESS,
- "hours_between_retries": settings.TIMEDELTA_FORMS_DOWNLOAD_HOURS,
+ "minutes_between_retries": settings.TIMEDELTA_FORMS_DOWNLOAD_MINUTES,
"has_signed_form": has_signed_form,
"current_year": now.year,
"ngo_url": ngo_url,
diff --git a/backend/redirectioneaza/settings.py b/backend/redirectioneaza/settings.py
index e9cb5e2b..2f355d6c 100644
--- a/backend/redirectioneaza/settings.py
+++ b/backend/redirectioneaza/settings.py
@@ -45,7 +45,7 @@
LOG_LEVEL=(str, "INFO"),
ENABLE_CACHE=(bool, True),
ENABLE_FORMS_DOWNLOAD=(bool, True),
- TIMEDELTA_FORMS_DOWNLOAD_HOURS=(int, 6),
+ TIMEDELTA_FORMS_DOWNLOAD_MINUTES=(int, 360),
IS_CONTAINERIZED=(bool, False),
RECAPTCHA_ENABLED=(bool, True),
# proxy headers
@@ -619,7 +619,7 @@
SILENCED_SYSTEM_CHECKS = ["django_recaptcha.recaptcha_test_key_error"]
ENABLE_FORMS_DOWNLOAD = env.bool("ENABLE_FORMS_DOWNLOAD", True)
-TIMEDELTA_FORMS_DOWNLOAD_HOURS = env.int("TIMEDELTA_FORMS_DOWNLOAD_HOURS")
+TIMEDELTA_FORMS_DOWNLOAD_MINUTES = env.int("TIMEDELTA_FORMS_DOWNLOAD_MINUTES")
# encryption
diff --git a/backend/templates/v1/ngo/donations-view.html b/backend/templates/v1/ngo/donations-view.html
index c16012ec..5ed74d43 100644
--- a/backend/templates/v1/ngo/donations-view.html
+++ b/backend/templates/v1/ngo/donations-view.html
@@ -32,7 +32,7 @@
{% endif %}
Deoarece operația de descărcare a declarațiilor poate dura mai mult timp, în funcție de numărul de donatori,
- momentan puteți descărca o singură arhivă la fiecare {{ hours_between_retries }} ore.
+ momentan puteți descărca o singură arhivă la fiecare {{ minutes_between_retries }} minute.
{% endif %}
@@ -67,8 +67,8 @@
Descărcarea de declarații este momentan blocată pentru organizația ta.
Descărcarea de declarații este limitată la una singură la fiecare
- {{ hours_between_retries }}
- ore.
+ {{ minutes_between_retries }}
+ minute.
{% endif %}