diff --git a/pinaxcon/settings.py b/pinaxcon/settings.py index 1f12fc83..3e9e8d1f 100644 --- a/pinaxcon/settings.py +++ b/pinaxcon/settings.py @@ -30,10 +30,11 @@ 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.smtp.EmailBackend' +EMAIL_BACKEND = 'django.core.mail.backends.console.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) @@ -69,6 +70,8 @@ saml2_contact = { fail = False +BADGER_DEFAULT_SVG = 'registrasion/badge.svg' + if SECRET_KEY is None: print("FAILURE: You need to supply a DJANGO_SECRET_KEY " "environment variable") diff --git a/pinaxcon/templates/registrasion/badge.svg b/pinaxcon/templates/registrasion/badge.svg new file mode 100644 index 00000000..288e31af --- /dev/null +++ b/pinaxcon/templates/registrasion/badge.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/templatetags/lca2018_tags.py b/pinaxcon/templatetags/lca2018_tags.py index 380df581..7e09126b 100644 --- a/pinaxcon/templatetags/lca2018_tags.py +++ b/pinaxcon/templatetags/lca2018_tags.py @@ -5,6 +5,7 @@ from django import template from django.conf import settings from django.contrib.staticfiles.templatetags import staticfiles from easy_thumbnails.files import get_thumbnailer +from registrasion.templatetags import registrasion_tags from symposion.conference import models as conference_models from symposion.schedule.models import Track @@ -94,3 +95,47 @@ def trackname(room, day): except Track.DoesNotExist: track_name = None return track_name + +@register.simple_tag(takes_context=True) +def ticket_type(context): + + # Default to purchased ticket type (only item from category 1) + items = registrasion_tags.items_purchased(context, 1) + + item = next(iter(items)) + name = item.product.name + if name == "Conference Volunteer": + return "Volunteer" + elif name == "Conference Organiser": + return "Organiser" + else: + ticket_type = name + + + # Miniconfs are secion 2 + # General sessions are section 1 + + user = registrasion_tags.user_for_context(context) + + if hasattr(user, "speaker_profile"): + best = 0 + for presentation in user.speaker_profile.presentations.all(): + if presentation.section.id == 1: + best = 1 + if best == 0 and presentation.section.id == 2: + best = 2 + if best == 1: + return "Speaker" + elif best == 2: + return "Miniconf Org" + + if name == "Sponsor": + return "Professional" + elif name == "Fairy Penguin Sponsor": + return "Professional" + elif name == "Monday and Tuesday Only": + return "Mon/Tue Only" + + # Default to product type + return ticket_type + diff --git a/vendor/registrasion/registrasion/views.py b/vendor/registrasion/registrasion/views.py index 7a7f79d2..e0ef72b9 100644 --- a/vendor/registrasion/registrasion/views.py +++ b/vendor/registrasion/registrasion/views.py @@ -1115,30 +1115,31 @@ def _get_badge_template_name(): @user_passes_test(_staff_only) def badge(request, user_id): - ''' - Renders a single user's badge (SVG). - - This does little more than call Richard Jones' collate and svg_badge - functions found in generate_badges. - ''' + ''' Renders a single user's badge (SVG). ''' user_id = int(user_id) user = User.objects.get(pk=user_id) - # This will fail spectacularly -- will put exception handling in later ... - user_data = list(collate({'usernames': [user.username]}))[0] + print(type(user)) + print(dir(user)) + print(user) - orig = etree.parse(_get_badge_template_name()) - tree = deepcopy(orig) - root = tree.getroot() + rendered = render_badge(user) + response = HttpResponse(rendered) - svg_badge(root, user_data, 0) - - response = HttpResponse(etree.tostring(root)) response["Content-Type"] = "image/svg+xml" response["Content-Disposition"] = 'inline; filename="badge.svg"' return response +def render_badge(user): + ''' Renders a single user's badge. ''' + + data = { + "user": user, + } + + t = loader.get_template('registrasion/badge.svg') + return t.render(data) def badges(request): '''