From d8cd0c2b6a4f756855121c2368285050fb042b13 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Mon, 4 Jun 2012 10:17:56 +0200 Subject: [PATCH] Renamed logo files (typo). --- ...openlides-logo.svg => openslides-logo.svg} | 0 ...s-logo_100.png => openslides-logo_100.png} | Bin ...s-logo_150.png => openslides-logo_150.png} | Bin ...logo_icon.png => openslides-logo_icon.png} | Bin ...logo_icon.svg => openslides-logo_icon.svg} | 0 openslides/openslides_settings.py | 2 +- .../participant/base_participant.html | 1 + openslides/participant/urls.py | 8 ++- openslides/participant/views.py | 46 +++++++++++++++++- openslides/utils/pdf.py | 22 +++++++++ 10 files changed, 76 insertions(+), 3 deletions(-) rename extras/logo/{openlides-logo.svg => openslides-logo.svg} (100%) rename extras/logo/{openlides-logo_100.png => openslides-logo_100.png} (100%) rename extras/logo/{openlides-logo_150.png => openslides-logo_150.png} (100%) rename extras/logo/{openlides-logo_icon.png => openslides-logo_icon.png} (100%) rename extras/logo/{openlides-logo_icon.svg => openslides-logo_icon.svg} (100%) diff --git a/extras/logo/openlides-logo.svg b/extras/logo/openslides-logo.svg similarity index 100% rename from extras/logo/openlides-logo.svg rename to extras/logo/openslides-logo.svg diff --git a/extras/logo/openlides-logo_100.png b/extras/logo/openslides-logo_100.png similarity index 100% rename from extras/logo/openlides-logo_100.png rename to extras/logo/openslides-logo_100.png diff --git a/extras/logo/openlides-logo_150.png b/extras/logo/openslides-logo_150.png similarity index 100% rename from extras/logo/openlides-logo_150.png rename to extras/logo/openslides-logo_150.png diff --git a/extras/logo/openlides-logo_icon.png b/extras/logo/openslides-logo_icon.png similarity index 100% rename from extras/logo/openlides-logo_icon.png rename to extras/logo/openslides-logo_icon.png diff --git a/extras/logo/openlides-logo_icon.svg b/extras/logo/openslides-logo_icon.svg similarity index 100% rename from extras/logo/openlides-logo_icon.svg rename to extras/logo/openslides-logo_icon.svg diff --git a/openslides/openslides_settings.py b/openslides/openslides_settings.py index 17714031a..95ecb8db2 100755 --- a/openslides/openslides_settings.py +++ b/openslides/openslides_settings.py @@ -62,7 +62,7 @@ USE_L10N = True # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" -MEDIA_ROOT = '' +MEDIA_ROOT = os.path.join(SITE_ROOT, './static/') # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). diff --git a/openslides/participant/templates/participant/base_participant.html b/openslides/participant/templates/participant/base_participant.html index cf531f158..ad688d2bc 100644 --- a/openslides/participant/templates/participant/base_participant.html +++ b/openslides/participant/templates/participant/base_participant.html @@ -25,6 +25,7 @@ {% endif %} {% if perms.participant.can_manage_participant %}
  • {% trans 'First time passwords as PDF' %}
  • +
  • Namenskarten als PDF
  • {% endif %} {% endblock %} diff --git a/openslides/participant/urls.py b/openslides/participant/urls.py index a7d152c21..eb5051fc2 100644 --- a/openslides/participant/urls.py +++ b/openslides/participant/urls.py @@ -13,7 +13,7 @@ from django.conf.urls.defaults import * from django.core.urlresolvers import reverse -from participant.views import ParticipantsListPDF, ParticipantsPasswordsPDF +from participant.views import ParticipantsListPDF, ParticipantsPasswordsPDF, ParticipantsBadgePDF urlpatterns = patterns('participant.views', url(r'^$', @@ -80,4 +80,10 @@ urlpatterns = patterns('participant.views', ParticipantsPasswordsPDF.as_view(), name='print_passwords', ), + + url(r'^badges/print$', + ParticipantsBadgePDF.as_view(), + name='print_badges', + ), + ) diff --git a/openslides/participant/views.py b/openslides/participant/views.py index 1bb656eca..195518962 100644 --- a/openslides/participant/views.py +++ b/openslides/participant/views.py @@ -53,6 +53,8 @@ from utils.template import Tab from utils.views import (FormView, PDFView) from utils.utils import delete_default_permissions +from openslides import settings +import qrcode @permission_required('participant.can_see_participant') @template('participant/overview.html') @@ -551,6 +553,10 @@ class ParticipantsPasswordsPDF(PDFView): for user in User.objects.all().order_by('last_name'): try: user.get_profile() + qrcode_img = qrcode.make(participant_pdf_system_url) + qrcode_img.save( settings.MEDIA_ROOT + 'qr-code_systemurl.png', 'PNG') + imgfile = settings.MEDIA_ROOT + 'qr-code_systemurl.png'; + qrcode_systemurl = "" % imgfile cell = [] cell.append(Spacer(0,0.8*cm)) cell.append(Paragraph(_("Account for OpenSlides"), stylesheet['Ballot_title'])) @@ -560,7 +566,8 @@ class ParticipantsPasswordsPDF(PDFView): cell.append(Paragraph(_("Password: %s") % (user.profile.firstpassword), stylesheet['Monotype'])) cell.append(Spacer(0,0.5*cm)) cell.append(Paragraph(_("URL: %s") % (participant_pdf_system_url), stylesheet['Ballot_option'])) - cell.append(Spacer(0,0.5*cm)) + cell.append(Spacer(0,1*cm)) + cell.append(Paragraph(qrcode_systemurl, stylesheet['Ballot_option'])) cell2 = [] cell2.append(Spacer(0,0.8*cm)) if participant_pdf_welcometext is not None: @@ -578,7 +585,44 @@ class ParticipantsPasswordsPDF(PDFView): ])) story.append(t) +class ParticipantsBadgePDF(PDFView): + permission_required = 'participant.can_manage_participant' + filename = _("participant-badges") + top_space = 0 + def get_template(self, buffer): + return SimpleDocTemplate(buffer, topMargin=-6, bottomMargin=-6, leftMargin=0, rightMargin=0, showBoundary=False) + + def build_document(self, pdf_document, story): + pdf_document.build(story) + + def append_to_pdf(self, story): + data= [] + for user in User.objects.all().order_by('last_name'): + try: + user.get_profile() + qrcode_img = qrcode.make( "%s%s" % (config['participant_pdf_system_url'], reverse('user_status', args=[user.id])) ) + qrcode_img.save( settings.MEDIA_ROOT + 'qr-code_statusurl.png', 'PNG') + imgfile = settings.MEDIA_ROOT + 'qr-code_statusurl.png'; + qrcode_statusurl = "" % imgfile + cell = [] + cell.append(Spacer(0,0.8*cm)) + cell.append(Paragraph("%s %s" % (user.first_name, user.last_name), stylesheet['Badge_title'])) + cell.append(Spacer(0,0.5*cm)) + cell.append(Paragraph("%s" % (user.profile.group), stylesheet['Badge_subtitle'])) + cell.append(Paragraph("%s" % (user.profile.committee), stylesheet['Badge_italic'])) + cell.append(Spacer(0,2.25*cm)) + cell.append(Paragraph(qrcode_statusurl, stylesheet['Badge_qrcode'])) + # print cards + data.append([cell,cell]) + except Profile.DoesNotExist: + pass + + t=Table(data, 10.5*cm, 7.42*cm) + t.setStyle(TableStyle([ ('GRID', (0,0), (-1,-1), 0.25, colors.grey), + ('VALIGN', (0,0), (-1,-1), 'TOP'), + ])) + story.append(t) class Config(FormView): permission_required = 'config.can_manage_config' diff --git a/openslides/utils/pdf.py b/openslides/utils/pdf.py index fb9394662..d9e3a5009 100755 --- a/openslides/utils/pdf.py +++ b/openslides/utils/pdf.py @@ -181,7 +181,29 @@ stylesheet.add(ParagraphStyle(name = 'Ballot_option_group_right', leading = 16, leftIndent = 49), ) +stylesheet.add(ParagraphStyle(name = 'Badge_title', + parent = stylesheet['Bold'], + fontSize = 16, + leading = 22, + leftIndent = 30), + ) +stylesheet.add(ParagraphStyle(name = 'Badge_subtitle', + parent = stylesheet['Normal'], + fontSize = 12, + leading = 24, + leftIndent = 30), + ) +stylesheet.add(ParagraphStyle(name = 'Badge_italic', + parent = stylesheet['Italic'], + fontSize = 12, + leading = 24, + leftIndent = 30), + ) +stylesheet.add(ParagraphStyle(name = 'Badge_qrcode', + fontSize = 12, + leftIndent = 190), + ) def firstPage(canvas, doc): canvas.saveState()