From d14048bcb8570101b89449518487e5f32fc2a3b6 Mon Sep 17 00:00:00 2001 From: James Polley Date: Tue, 26 Dec 2017 18:57:16 +1100 Subject: [PATCH] Further changes to support badge generation for lca2018 * Undo some of the debugging done early in this series of patches * Add ability for a user to preview their own badge * Add a template for the LCA2018 badge --- pinaxcon/settings.py | 4 +- pinaxcon/templates/registrasion/badge.svg | 5641 ++++------------- .../templates/registrasion/badge_form.html | 20 + pinaxcon/templates/registrasion/lca2017.svg | 4279 +++++++++++++ pinaxcon/templates/registrasion/lca2018.svg | 531 ++ vendor/registrasion/registrasion/urls.py | 2 + vendor/registrasion/registrasion/views.py | 18 +- 7 files changed, 6222 insertions(+), 4273 deletions(-) create mode 100644 pinaxcon/templates/registrasion/badge_form.html create mode 100644 pinaxcon/templates/registrasion/lca2017.svg create mode 100644 pinaxcon/templates/registrasion/lca2018.svg diff --git a/pinaxcon/settings.py b/pinaxcon/settings.py index 3e9e8d1f..e6ae9d67 100644 --- a/pinaxcon/settings.py +++ b/pinaxcon/settings.py @@ -30,11 +30,10 @@ else: DATABASES = {} DATABASES['default'] = dj_database_url.config(conn_max_age=600) -print(DATABASES) if DATABASES['default']['ENGINE'] == 'django.db.backends.mysql': DATABASES['default']['OPTIONS'] = {'charset': 'utf8mb4'} -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = os.environ.get('EMAIL_HOST', None) EMAIL_PORT = os.environ.get('EMAIL_PORT', 25) EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER', None) @@ -71,6 +70,7 @@ saml2_contact = { fail = False BADGER_DEFAULT_SVG = 'registrasion/badge.svg' +BADGER_DEFAULT_FORM = "registrasion/badge_form.html" if SECRET_KEY is None: print("FAILURE: You need to supply a DJANGO_SECRET_KEY " diff --git a/pinaxcon/templates/registrasion/badge.svg b/pinaxcon/templates/registrasion/badge.svg index 288e31af..de81dbc5 100644 --- a/pinaxcon/templates/registrasion/badge.svg +++ b/pinaxcon/templates/registrasion/badge.svg @@ -1,6 +1,4 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - LINUX.CONF.AU - 16–20 JANUARY 2017 HOBARTTHE FUTURE OF OPEN SOURCE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{ user.attendee.attendeeprofilebase.attendeeprofile.name }}{{ user.attendee.attendeeprofilebase.attendeeprofile.company }}{{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_1 }}{{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_2 }} - {{ ticket_type }} - - {{ penguin_dinner_count }} - - {{ speakers_dinner_count }} - - {{ pdns_count }} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if user.attendee.attendeeprofilebase.attendeeprofile.of_legal_age %}18+{% endif %} + + + + - - - - - - LINUX.CONF.AU - 16–20 JANUARY 2017 HOBARTTHE FUTURE OF OPEN SOURCE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{ user.attendee.attendeeprofilebase.attendeeprofile.name }}{{ user.attendee.attendeeprofilebase.attendeeprofile.company }}{{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_1 }}{{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_2 }} - {{ ticket_type }} - - {{ penguin_dinner_count }} - - {{ speakers_dinner_count }} - - {{ pdns_count }} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if user.attendee.attendeeprofilebase.attendeeprofile.of_legal_age %}18+{% endif %} + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{{ ticket_type }} + + + + + +{{ user.attendee.attendeeprofilebase.attendeeprofile.name }} + + + + + +{{ user.attendee.attendeeprofilebase.attendeeprofile.company }} + + + + + +{{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_1 }} + + + + + +{{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_2 }} + + + + + + + +{{ penguin_dinner_count }} + + + + + +{{ speakers_dinner_count }} + + + + + +{{ pdns_count }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{% if user.attendee.attendeeprofilebase.attendeeprofile.of_legal_age %}18+{% endif %} + + + + + + + diff --git a/pinaxcon/templates/registrasion/badge_form.html b/pinaxcon/templates/registrasion/badge_form.html new file mode 100644 index 00000000..e6a555e4 --- /dev/null +++ b/pinaxcon/templates/registrasion/badge_form.html @@ -0,0 +1,20 @@ +{% extends "registrasion/base.html" %} +{% load bootstrap %} + +{% block content %} +

Create Badge

+ +

Enter a username to autofill this form, or fill in the rest of the fields by hand.

+ +
+ {% csrf_token %} + + + {{ form|bootstrap }} +
+ +
+ +
+
+{% endblock %} diff --git a/pinaxcon/templates/registrasion/lca2017.svg b/pinaxcon/templates/registrasion/lca2017.svg new file mode 100644 index 00000000..288e31af --- /dev/null +++ b/pinaxcon/templates/registrasion/lca2017.svg @@ -0,0 +1,4279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + LINUX.CONF.AU + 16–20 JANUARY 2017 HOBARTTHE FUTURE OF OPEN SOURCE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ user.attendee.attendeeprofilebase.attendeeprofile.name }}{{ user.attendee.attendeeprofilebase.attendeeprofile.company }}{{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_1 }}{{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_2 }} + {{ ticket_type }} + + {{ penguin_dinner_count }} + + {{ speakers_dinner_count }} + + {{ pdns_count }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% if user.attendee.attendeeprofilebase.attendeeprofile.of_legal_age %}18+{% endif %} + + + + + + + LINUX.CONF.AU + 16–20 JANUARY 2017 HOBARTTHE FUTURE OF OPEN SOURCE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ user.attendee.attendeeprofilebase.attendeeprofile.name }}{{ user.attendee.attendeeprofilebase.attendeeprofile.company }}{{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_1 }}{{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_2 }} + {{ ticket_type }} + + {{ penguin_dinner_count }} + + {{ speakers_dinner_count }} + + {{ pdns_count }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% if user.attendee.attendeeprofilebase.attendeeprofile.of_legal_age %}18+{% endif %} + + + + diff --git a/pinaxcon/templates/registrasion/lca2018.svg b/pinaxcon/templates/registrasion/lca2018.svg new file mode 100644 index 00000000..68c58bf2 --- /dev/null +++ b/pinaxcon/templates/registrasion/lca2018.svg @@ -0,0 +1,531 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ ticket_type }} + + + {{ user.attendee.attendeeprofilebase.attendeeprofile.name }} + + + {{ user.attendee.attendeeprofilebase.attendeeprofile.company }} + + + {{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_1 }} + + + {{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_2 }} + + + + {{ penguin_dinner_count }} + + + {{ speakers_dinner_count }} + + + {{ pdns_count }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% if user.attendee.attendeeprofilebase.attendeeprofile.of_legal_age    %}18+{% endif %} + + + + + + diff --git a/vendor/registrasion/registrasion/urls.py b/vendor/registrasion/registrasion/urls.py index 72553877..18f69ba5 100644 --- a/vendor/registrasion/registrasion/urls.py +++ b/vendor/registrasion/registrasion/urls.py @@ -5,6 +5,7 @@ from django.conf.urls import url from .views import ( amend_registration, + user_badge, badge, badger, checkout, @@ -25,6 +26,7 @@ from .views import ( public = [ url(r"^amend/([0-9]+)$", amend_registration, name="amend_registration"), + url(r"^mybadge$", user_badge, name="user_badge"), url(r"^badge/([0-9]+)$", badge, name="badge"), url(r"^badger/([A-Za-z0-9]+)$", badger, name="badger"), url(r"^badger/", badger, name="badger"), diff --git a/vendor/registrasion/registrasion/views.py b/vendor/registrasion/registrasion/views.py index e0ef72b9..5d7b8c58 100644 --- a/vendor/registrasion/registrasion/views.py +++ b/vendor/registrasion/registrasion/views.py @@ -1112,6 +1112,11 @@ def invoice_mailout(request): def _get_badge_template_name(): return os.path.join(settings.PROJECT_ROOT, 'pinaxcon', 'templates', settings.BADGER_DEFAULT_SVG) +@login_required +def user_badge(request): + '''Shows the logged-in user their badge''' + + return render_badge(request.user) @user_passes_test(_staff_only) def badge(request, user_id): @@ -1120,19 +1125,18 @@ def badge(request, user_id): user_id = int(user_id) user = User.objects.get(pk=user_id) - print(type(user)) - print(dir(user)) - print(user) + return render_badge(user) - rendered = render_badge(user) +def render_badge(user): + rendered = render_badge_svg(user) response = HttpResponse(rendered) - response["Content-Type"] = "image/svg+xml" + response["Content-Type"] = "image/svg+xml;charset=utf-8" response["Content-Disposition"] = 'inline; filename="badge.svg"' return response -def render_badge(user): - ''' Renders a single user's badge. ''' +def render_badge_svg(user): + ''' Renders a single user's badge as SVG. ''' data = { "user": user,