diff --git a/pinaxcon/templates/registrasion/badge.svg b/pinaxcon/templates/registrasion/badge.svg index 31dd6303..c5344d21 100644 --- a/pinaxcon/templates/registrasion/badge.svg +++ b/pinaxcon/templates/registrasion/badge.svg @@ -12,6 +12,9 @@ --> + + + @@ -1020,16 +1023,16 @@ - {{ user.attendee.attendeeprofilebase.attendeeprofile.name }} + {{ user.attendee.attendeeprofilebase.attendeeprofile.name }} - {{ user.attendee.attendeeprofilebase.attendeeprofile.company }} + {{ user.attendee.attendeeprofilebase.attendeeprofile.company }} - {{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_1 }} + {{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_1 }} - {{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_2 }} + {{ user.attendee.attendeeprofilebase.attendeeprofile.free_text_2 }} diff --git a/static/src/fonts/TwitterColorEmoji-SVGinOT.ttf b/static/src/fonts/TwitterColorEmoji-SVGinOT.ttf new file mode 100644 index 00000000..31415bc1 Binary files /dev/null and b/static/src/fonts/TwitterColorEmoji-SVGinOT.ttf differ diff --git a/vendor/registrasion/registrasion/views.py b/vendor/registrasion/registrasion/views.py index 097e13b5..bd2d5d15 100644 --- a/vendor/registrasion/registrasion/views.py +++ b/vendor/registrasion/registrasion/views.py @@ -2,6 +2,7 @@ import datetime import zipfile import os import logging +import subprocess from django.contrib import messages @@ -38,7 +39,6 @@ from django.template import Context, Template, loader from lxml import etree from copy import deepcopy -from cairosvg import svg2pdf, svg2png from registrasion.forms import BadgeForm, ticket_selection from registrasion.contrib.badger import ( @@ -57,7 +57,6 @@ _GuidedRegistrationSection = namedtuple( ) ) - @util.all_arguments_optional class GuidedRegistrationSection(_GuidedRegistrationSection): ''' Represents a section of a guided registration page. @@ -1115,26 +1114,44 @@ def _get_badge_template_name(): return os.path.join(settings.PROJECT_ROOT, 'pinaxcon', 'templates', settings.BADGER_DEFAULT_SVG) @login_required -def user_badge(request, format="svg"): +def user_badge(request, format="png"): '''Shows the logged-in user their badge''' return render_badge(request.user, format) @user_passes_test(_staff_only) -def badge(request, user_id, format="svg"): - ''' Renders a single user's badge (SVG). ''' +def badge(request, user_id, format="png"): + ''' Renders a single user's badge (PNG). ''' user_id = int(user_id) user = User.objects.get(pk=user_id) return render_badge(user, format) -def render_badge(user, format="svg"): +def _convert_img(img, outformat="png",dpi=200,width=None): + if hasattr(img, "encode"): #a string, or a SafeText + img=img.encode() + width = width or dpi*5.83 #5.83 inches in A6 portrait + conversion_cmdline = [ + "convert", + "-density",str(dpi), + "-resize",str(width), + ] + if outformat=="png": + conversion_cmdline.extend(["-background","white", + "-flatten"]) + conversion_cmdline.extend(["-", "{}:-".format(outformat)]) + out = subprocess.run(conversion_cmdline, + input=img, + stdout=subprocess.PIPE).stdout + return out + +def render_badge(user, format="png"): rendered = render_badge_svg(user) if format == "png": - rendered = svg2png(bytestring=rendered, dpi=72, scale=3) + rendered = _convert_img(rendered, outformat="png") elif format == "pdf": - rendered = svg2pdf(bytestring=rendered, dpi=72, scale=3) + rendered = _convert_img(rendered, outformat="pdf") response = HttpResponse(rendered)