Fixed #948: Use DIN A4 format and wlan ssid qrcode on access data PDF.
This commit is contained in:
parent
7fcc786cf9
commit
a513477033
@ -91,6 +91,47 @@ def setup_general_config_page(sender, **kwargs):
|
||||
label=ugettext_lazy('Allow access for anonymous guest users'),
|
||||
required=False))
|
||||
|
||||
system_url = ConfigVariable(
|
||||
name='system_url',
|
||||
default_value='http://example.com:8000',
|
||||
form_field=forms.CharField(
|
||||
widget=forms.TextInput(),
|
||||
required=False,
|
||||
label=ugettext_lazy('System URL'),
|
||||
help_text=ugettext_lazy('Used for QRCode in PDF of access data.')))
|
||||
|
||||
system_wlan_ssid = ConfigVariable(
|
||||
name='system_wlan_ssid',
|
||||
default_value='',
|
||||
form_field=forms.CharField(
|
||||
widget=forms.TextInput(),
|
||||
required=False,
|
||||
label=ugettext_lazy('WLAN name (SSID)'),
|
||||
help_text=ugettext_lazy('Used for WLAN QRCode in PDF of access data.')))
|
||||
|
||||
system_wlan_password = ConfigVariable(
|
||||
name='system_wlan_password',
|
||||
default_value='',
|
||||
form_field=forms.CharField(
|
||||
widget=forms.TextInput(),
|
||||
required=False,
|
||||
label=ugettext_lazy('WLAN password'),
|
||||
help_text=ugettext_lazy('Used for WLAN QRCode in PDF of access data.')))
|
||||
|
||||
system_wlan_encryption = ConfigVariable(
|
||||
name='system_wlan_encryption',
|
||||
default_value='',
|
||||
form_field=forms.ChoiceField(
|
||||
widget=forms.Select(),
|
||||
required=False,
|
||||
label=ugettext_lazy('WLAN encryption'),
|
||||
help_text=ugettext_lazy('Used for WLAN QRCode in PDF of access data.'),
|
||||
choices=(
|
||||
('', ugettext_lazy('---------')),
|
||||
('WEP', ugettext_lazy('WEP')),
|
||||
('WPA', ugettext_lazy('WPA/WPA2')),
|
||||
('nopass', ugettext_lazy('No encryption')))))
|
||||
|
||||
group_event = ConfigGroup(
|
||||
title=ugettext_lazy('Event'),
|
||||
variables=(event_name, event_description, event_date, event_location, event_organizer))
|
||||
@ -101,7 +142,7 @@ def setup_general_config_page(sender, **kwargs):
|
||||
|
||||
group_system = ConfigGroup(
|
||||
title=ugettext_lazy('System'),
|
||||
variables=(system_enable_anonymous,))
|
||||
variables=(system_enable_anonymous, system_url, system_wlan_ssid, system_wlan_password, system_wlan_encryption))
|
||||
|
||||
return ConfigGroupedPage(
|
||||
title=ugettext_noop('General'),
|
||||
|
@ -30,23 +30,22 @@ def setup_participant_config_page(sender, **kwargs):
|
||||
"""
|
||||
Participant config variables.
|
||||
"""
|
||||
# TODO: Rename config-vars
|
||||
participant_pdf_system_url = ConfigVariable(
|
||||
name='participant_pdf_system_url',
|
||||
default_value='http://example.com:8000',
|
||||
form_field=forms.CharField(
|
||||
widget=forms.TextInput(),
|
||||
required=False,
|
||||
label=ugettext_lazy('System URL'),
|
||||
help_text=ugettext_lazy('Printed in PDF of first time passwords only.')))
|
||||
participant_pdf_welcometext = ConfigVariable(
|
||||
name='participant_pdf_welcometext',
|
||||
participant_pdf_welcometitle = ConfigVariable(
|
||||
name='participant_pdf_welcometitle',
|
||||
default_value=_('Welcome to OpenSlides!'),
|
||||
form_field=forms.CharField(
|
||||
widget=forms.Textarea(),
|
||||
required=False,
|
||||
label=ugettext_lazy('Welcome text'),
|
||||
help_text=ugettext_lazy('Printed in PDF of first time passwords only.')))
|
||||
label=ugettext_lazy('Title for access data and welcome PDF')))
|
||||
|
||||
participant_pdf_welcometext = ConfigVariable(
|
||||
name='participant_pdf_welcometext',
|
||||
default_value=_('[Place for your welcome and help text.]'),
|
||||
form_field=forms.CharField(
|
||||
widget=forms.Textarea(),
|
||||
required=False,
|
||||
label=ugettext_lazy('Help text for access data and welcome PDF')))
|
||||
|
||||
participant_sort_users_by_first_name = ConfigVariable(
|
||||
name='participant_sort_users_by_first_name',
|
||||
default_value=False,
|
||||
@ -59,7 +58,7 @@ def setup_participant_config_page(sender, **kwargs):
|
||||
url='participant',
|
||||
required_permission='config.can_manage',
|
||||
weight=50,
|
||||
variables=(participant_pdf_system_url,
|
||||
variables=(participant_pdf_welcometitle,
|
||||
participant_pdf_welcometext,
|
||||
participant_sort_users_by_first_name))
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
<ul class="dropdown-menu pull-right">
|
||||
{% url 'user_settings' as url_usersettings %}
|
||||
<li><a href="{% url 'user_print' %}" target="_blank"><i class="icon-list"></i> {% trans 'List of participants' %}</a></li>
|
||||
<li><a href="{% url 'print_passwords' %}" target="_blank"><i class="icon-th-large"></i> {% trans 'First time passwords' %}</a></li>
|
||||
<li><a href="{% url 'print_passwords' %}" target="_blank"><i class="icon-th-large"></i> {% trans 'List of access data' %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% else %}
|
||||
|
@ -22,8 +22,8 @@ from reportlab.graphics.barcode.qr import QrCodeWidget
|
||||
from reportlab.graphics.shapes import Drawing
|
||||
from reportlab.lib import colors
|
||||
from reportlab.lib.units import cm
|
||||
from reportlab.platypus import (LongTable, Paragraph, SimpleDocTemplate,
|
||||
Spacer, Table, TableStyle)
|
||||
from reportlab.platypus import (LongTable, PageBreak, Paragraph, Spacer, Table,
|
||||
TableStyle)
|
||||
|
||||
from openslides.config.api import config
|
||||
from openslides.projector.projector import Widget
|
||||
@ -239,73 +239,104 @@ class ParticipantsPasswordsPDF(PDFView):
|
||||
Generate the Welcomepaper for the users.
|
||||
"""
|
||||
permission_required = 'participant.can_manage_participant'
|
||||
filename = ugettext_lazy("Participant-passwords")
|
||||
filename = ugettext_lazy("Participant-access-data")
|
||||
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 = []
|
||||
participant_pdf_system_url = config["participant_pdf_system_url"]
|
||||
system_wlan_ssid = config["system_wlan_ssid"] or "-"
|
||||
system_wlan_password = config["system_wlan_password"] or "-"
|
||||
system_wlan_encryption = config["system_wlan_encryption"] or "-"
|
||||
system_url = config["system_url"] or "-"
|
||||
participant_pdf_welcometitle = config["participant_pdf_welcometitle"]
|
||||
participant_pdf_welcometext = config["participant_pdf_welcometext"]
|
||||
if config['participant_sort_users_by_first_name']:
|
||||
sort = 'first_name'
|
||||
else:
|
||||
sort = 'last_name'
|
||||
# create qrcode image object from system url
|
||||
qrcode = QrCodeWidget(participant_pdf_system_url)
|
||||
size = 1.5 * cm
|
||||
qrcode.barHeight = size
|
||||
qrcode.barWidth = size
|
||||
qrcode.barBorder = 0
|
||||
draw = Drawing(45, 45)
|
||||
draw.add(qrcode)
|
||||
qrcode_size = 2 * cm
|
||||
# qrcode for system url
|
||||
qrcode_url = QrCodeWidget(system_url)
|
||||
qrcode_url.barHeight = qrcode_size
|
||||
qrcode_url.barWidth = qrcode_size
|
||||
qrcode_url.barBorder = 0
|
||||
qrcode_url_draw = Drawing(45, 45)
|
||||
qrcode_url_draw.add(qrcode_url)
|
||||
# qrcode for wlan
|
||||
text = "WIFI:S:%s;T:%s;P:%s;;" % (system_wlan_ssid, system_wlan_encryption, system_wlan_password)
|
||||
qrcode_wlan = QrCodeWidget(text)
|
||||
qrcode_wlan.barHeight = qrcode_size
|
||||
qrcode_wlan.barWidth = qrcode_size
|
||||
qrcode_wlan.barBorder = 0
|
||||
qrcode_wlan_draw = Drawing(45, 45)
|
||||
qrcode_wlan_draw.add(qrcode_wlan)
|
||||
|
||||
for user in User.objects.all().order_by(sort):
|
||||
story.append(Paragraph(unicode(user), stylesheet['h1']))
|
||||
story.append(Spacer(0, 1 * cm))
|
||||
data = []
|
||||
# WLAN access data
|
||||
cell = []
|
||||
cell.append(Spacer(0, 0.8 * cm))
|
||||
cell.append(Paragraph(_("Account for OpenSlides"),
|
||||
stylesheet['Password_title']))
|
||||
cell.append(Paragraph(_("for %s") % (user),
|
||||
stylesheet['Password_subtitle']))
|
||||
cell.append(Paragraph(_("WLAN access data"),
|
||||
stylesheet['h2']))
|
||||
cell.append(Paragraph("%s:" % _("WLAN name (SSID)"),
|
||||
stylesheet['formfield']))
|
||||
cell.append(Paragraph(system_wlan_ssid,
|
||||
stylesheet['formfield_value']))
|
||||
cell.append(Paragraph("%s:" % _("WLAN password"),
|
||||
stylesheet['formfield']))
|
||||
cell.append(Paragraph(system_wlan_password,
|
||||
stylesheet['formfield_value']))
|
||||
cell.append(Paragraph("%s:" % _("WLAN encryption"),
|
||||
stylesheet['formfield']))
|
||||
cell.append(Paragraph(system_wlan_encryption,
|
||||
stylesheet['formfield_value']))
|
||||
cell.append(Spacer(0, 0.5 * cm))
|
||||
cell.append(Paragraph(_("User: %s") % (user.username),
|
||||
stylesheet['Monotype']))
|
||||
cell.append(
|
||||
Paragraph(
|
||||
_("Password: %s")
|
||||
% (user.default_password), stylesheet['Monotype']))
|
||||
cell.append(
|
||||
Paragraph(participant_pdf_system_url, stylesheet['Monotype']))
|
||||
cell.append(draw)
|
||||
# OpenSlides access data
|
||||
cell2 = []
|
||||
cell2.append(Spacer(0, 0.8 * cm))
|
||||
if participant_pdf_welcometext is not None:
|
||||
cell2.append(Paragraph(
|
||||
participant_pdf_welcometext.replace('\r\n', '<br/>'),
|
||||
stylesheet['Ballot_subtitle']))
|
||||
|
||||
cell2.append(Paragraph(_("OpenSlides access data"),
|
||||
stylesheet['h2']))
|
||||
cell2.append(Paragraph("%s:" % _("Username"),
|
||||
stylesheet['formfield']))
|
||||
cell2.append(Paragraph(user.username,
|
||||
stylesheet['formfield_value']))
|
||||
cell2.append(Paragraph("%s:" % _("Password"),
|
||||
stylesheet['formfield']))
|
||||
cell2.append(Paragraph(user.default_password,
|
||||
stylesheet['formfield_value']))
|
||||
cell2.append(Paragraph("URL:",
|
||||
stylesheet['formfield']))
|
||||
cell2.append(Paragraph(system_url,
|
||||
stylesheet['formfield_value']))
|
||||
data.append([cell, cell2])
|
||||
# QRCodes
|
||||
cell = []
|
||||
if system_wlan_ssid != "-" and system_wlan_encryption != "-":
|
||||
cell.append(qrcode_wlan_draw)
|
||||
cell.append(Paragraph(_("Scan this QRCode to connect WLAN."),
|
||||
stylesheet['qrcode_comment']))
|
||||
cell2 = []
|
||||
if system_url != "-":
|
||||
cell2.append(qrcode_url_draw)
|
||||
cell2.append(Paragraph(_("Scan this QRCode to open URL."),
|
||||
stylesheet['qrcode_comment']))
|
||||
data.append([cell, cell2])
|
||||
|
||||
# add empty table line if no participants available
|
||||
if not data:
|
||||
data.append(['', ''])
|
||||
# build table
|
||||
t = Table(data, 10.5 * cm, 7.42 * cm)
|
||||
t.setStyle(TableStyle([
|
||||
('LEFTPADDING', (0, 0), (0, -1), 30),
|
||||
('LINEBELOW', (0, 0), (-1, 0), 0.25, colors.grey),
|
||||
('LINEBELOW', (0, 1), (-1, 1), 0.25, colors.grey),
|
||||
('LINEBELOW', (0, 1), (-1, -1), 0.25, colors.grey),
|
||||
('VALIGN', (0, 0), (-1, -1), 'TOP'),
|
||||
]))
|
||||
story.append(t)
|
||||
table = Table(data)
|
||||
table._argW[0] = 8 * cm
|
||||
table._argW[1] = 8 * cm
|
||||
table.setStyle(TableStyle([('VALIGN', (0, 0), (-1, -1), 'TOP')]))
|
||||
story.append(table)
|
||||
story.append(Spacer(0, 2 * cm))
|
||||
|
||||
# welcome title and text
|
||||
story.append(Paragraph(participant_pdf_welcometitle,
|
||||
stylesheet['h2']))
|
||||
story.append(Paragraph(participant_pdf_welcometext.replace('\r\n', '<br/>'),
|
||||
stylesheet['Paragraph12']))
|
||||
story.append(PageBreak())
|
||||
|
||||
|
||||
class UserImportView(FormView):
|
||||
|
@ -52,6 +52,11 @@ stylesheet.add(ParagraphStyle(
|
||||
leading=14,
|
||||
spaceAfter=15
|
||||
))
|
||||
stylesheet.add(ParagraphStyle(
|
||||
name='Paragraph12',
|
||||
parent=stylesheet['Paragraph'],
|
||||
fontSize=12
|
||||
))
|
||||
stylesheet.add(ParagraphStyle(
|
||||
name='InnerParagraph',
|
||||
parent=stylesheet['Normal'],
|
||||
@ -138,7 +143,7 @@ stylesheet.add(ParagraphStyle(
|
||||
parent=stylesheet['Bold'],
|
||||
fontSize=10,
|
||||
leading=20,
|
||||
))
|
||||
), alias='h4')
|
||||
stylesheet.add(ParagraphStyle(
|
||||
name='Item',
|
||||
parent=stylesheet['Normal'],
|
||||
@ -216,45 +221,23 @@ stylesheet.add(ParagraphStyle(name='Ballot_option_group_right',
|
||||
leftIndent=49),
|
||||
)
|
||||
# Password paper stylesheets
|
||||
stylesheet.add(ParagraphStyle(name='Password_title',
|
||||
parent=stylesheet['Ballot_title'],
|
||||
stylesheet.add(ParagraphStyle(name='formfield',
|
||||
parent=stylesheet['Normal'],
|
||||
fontSize=12,
|
||||
leading=18,
|
||||
leftIndent=0),
|
||||
)
|
||||
stylesheet.add(ParagraphStyle(name='Password_subtitle',
|
||||
parent=stylesheet['Ballot_subtitle'],
|
||||
leftIndent=0),
|
||||
)
|
||||
stylesheet.add(ParagraphStyle(name='Monotype',
|
||||
stylesheet.add(ParagraphStyle(name='formfield_value',
|
||||
parent=stylesheet['Normal'],
|
||||
fontName='Courier',
|
||||
fontSize=12,
|
||||
leading=24,
|
||||
leftIndent=0),
|
||||
leading=28,
|
||||
leftIndent=10),
|
||||
)
|
||||
stylesheet.add(ParagraphStyle(name='Badge_title',
|
||||
parent=stylesheet['Bold'],
|
||||
fontSize=16,
|
||||
leading=22,
|
||||
leftIndent=30),
|
||||
stylesheet.add(ParagraphStyle(name='qrcode_comment',
|
||||
parent=stylesheet['Small'],
|
||||
spaceBefore=6),
|
||||
)
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user