Skip to content

Commit

Permalink
Fix the export job creation
Browse files Browse the repository at this point in the history
  • Loading branch information
danniel committed Jan 31, 2024
1 parent 9dc60f4 commit 8d38cdd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
29 changes: 14 additions & 15 deletions backend/donations/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging

from urllib.request import Request, urlopen
from datetime import datetime
from datetime import datetime, date

from django.conf import settings
from django.contrib.auth.decorators import login_required
Expand Down Expand Up @@ -104,10 +104,12 @@ def post(self, request, *args, **kwargs):
if not ngo:
return redirect(reverse("contul-meu"))

DONATION_LIMIT = date(timezone.now().year, 5, 25)

now = timezone.now()
start_of_year = datetime(now.year, 1, 1, 0, 0)

if now.date() > settings.DONATION_LIMIT:
if now.date() > DONATION_LIMIT:
return redirect(reverse("contul-meu"))

# get all the forms that have been completed since the start of the year
Expand All @@ -129,23 +131,20 @@ def post(self, request, *args, **kwargs):
)
job.save()

export_folder = ngo_directory_path(
export_destination = ngo_directory_path(
"exports", ngo, "export_{}_{}.zip".format(job.id, hash_id_secret(timezone.now(), job.id))
)

# make request
params = json.encode(
{
"passphrase": settings.ZIP_SECRET,
"urls": urls,
"path": "exports/{}/export-{}.zip".format(export_folder, job.id),
"webhook": {
"url": "https://{}{}".format(settings.APEX_DOMAIN, reverse("webhook")),
"data": {"jobId": job.id},
},
}
)
print(params)
params = {
"passphrase": settings.ZIP_SECRET,
"urls": urls,
"path": export_destination,
"webhook": {
"url": "https://{}{}".format(settings.APEX_DOMAIN, reverse("webhook")),
"data": {"jobId": job.id},
},
}

request = Request(url=settings.ZIP_ENDPOINT, data=params, headers={"Content-type": "application/json"})

Expand Down
2 changes: 1 addition & 1 deletion backend/redirectioneaza/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,4 @@
CAPTCHA_ENABLED = True if CAPTCHA_PUBLIC_KEY else False

ZIP_ENDPOINT = env.str("ZIP_ENDPOINT")
ZIP_SECRET = env.str("ZIP_PASSPHRASE")
ZIP_SECRET = env.str("ZIP_SECRET")

0 comments on commit 8d38cdd

Please sign in to comment.