Actually fix the bugs this time #100
3 changed files with 9 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
|||
from pathlib import Path
|
||||
from shutil import rmtree
|
||||
|
||||
from django.db.models.signals import post_save, post_delete
|
||||
|
@ -10,7 +11,10 @@ from .resource_generation_utils import storage
|
|||
@receiver(post_delete, sender=Export)
|
||||
def delete_export(sender, instance, *args, **kwargs):
|
||||
"""Clean up created files on the filesystem when an export is deleted"""
|
||||
rmtree(storage.path(f"export_{instance.pk}"))
|
||||
path = storage.path(f"export_{instance.pk}")
|
||||
|
||||
if Path(path).exists():
|
||||
rmtree(path)
|
||||
|
||||
|
||||
@receiver(post_save, sender=ActivationKeySet)
|
||||
|
|
|
@ -14,9 +14,10 @@ from .resource_generation_utils import create_planting_guide_pdf, get_filter_val
|
|||
@shared_task
|
||||
def generate_pdf(questionnaire_id, export_id):
|
||||
q = Questionnaire.objects.get(pk=questionnaire_id)
|
||||
e = Export.objects.get(pk=export_id)
|
||||
z = q.zone
|
||||
filename = f"export_{e.pk}/{q.slug}.pdf"
|
||||
|
||||
export = Export.objects.get(pk=export_id)
|
||||
filename = f"export_{export.pk}/{q.slug}.pdf"
|
||||
|
||||
try:
|
||||
create_planting_guide_pdf(
|
||||
|
@ -35,7 +36,7 @@ def generate_pdf(questionnaire_id, export_id):
|
|||
if not storage.exists(filename):
|
||||
raise FileNotFoundError(f"There was an error creating file: {filename}")
|
||||
|
||||
if e.completion >= 1:
|
||||
if export.completion >= 1:
|
||||
generate_zip.delay(export_id)
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ volumes:
|
|||
x-django: &django
|
||||
image: right-tree
|
||||
env_file: .env
|
||||
user: "$UID:$GID"
|
||||
restart: always
|
||||
volumes:
|
||||
- righttree-media:/app/right_tree/media
|
||||
|
|
Loading…
Reference in a new issue