Skip to content

Commit

Permalink
media
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Lind committed Aug 23, 2024
1 parent 34e9d7b commit 6c995c2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion submission/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import qrcode
from django.conf import settings

import os

@login_required
def generate_link(request):
submission_link = SubmissionLink.objects.create(admin_user=request.user)
Expand All @@ -21,7 +23,11 @@ def generate_link(request):
qr.make(fit=True)

img = qr.make_image(fill='black', back_color='white')
img_path = settings.MEDIA_URL + f'media/qr_codes/{submission_link.unique_url}.png'
# Define the directory path for QR codes
qr_code_dir = os.path.join(settings.MEDIA_ROOT, 'qr_codes')
# Ensure the directory exists
os.makedirs(qr_code_dir, exist_ok=True)
img_path = settings.MEDIA_URL + f'qr_codes/{submission_link.unique_url}.png'
img.save(img_path)

submission_link.qr_code = img_path
Expand Down

0 comments on commit 6c995c2

Please sign in to comment.