Used reportlabs qrcode widget (instead of extra qrcode package).

This commit is contained in:
Emanuel Schuetze 2013-10-21 16:49:11 +02:00
parent 66d9d22e27
commit f1a8993452
5 changed files with 13 additions and 72 deletions

View File

@ -4,7 +4,7 @@ How to create a new portable Windows distribution of OpenSlides:
1.) Follow the OpenSlides installation instructions for windows,
but add the option "-Z" when executing easy_install, e.g.:
easy_install -Z django django-mptt beautifulsoup4 bleach pillow qrcode reportlab tornado django-haystack whoosh
easy_install -Z django django-mptt beautifulsoup4 bleach pillow reportlab tornado django-haystack whoosh
2.) To update the version resource of the prebuild openslides.exe
pywin32 should be installed (it is not strictly required but at

View File

@ -1,48 +0,0 @@
Copyright (c) 2011, Lincoln Loop
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the package name nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
Original text and license from the pyqrnative package where this was forked
from (http://code.google.com/p/pyqrnative):
#Ported from the Javascript library by Sam Curren
#
#QRCode for Javascript
#http://d-project.googlecode.com/svn/trunk/misc/qrcode/js/qrcode.js
#
#Copyright (c) 2009 Kazuhiko Arase
#
#URL: http://www.d-project.com/
#
#Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license.php
#
# The word "QR Code" is registered trademark of
# DENSO WAVE INCORPORATED
# http://www.denso-wave.com/qrcode/faqpatent-e.html

View File

@ -90,9 +90,6 @@ SITE_PACKAGES = {
"tornado": {
"copy": ["tornado"],
},
"qrcode": {
"copy": ["qrcode"],
},
"beautifulsoup4": {
"copy": ["bs4"],
},

View File

@ -10,15 +10,6 @@
:license: GNU GPL, see LICENSE for more details.
"""
try:
import qrcode
except ImportError:
draw_qrcode = False
else:
draw_qrcode = True
from cStringIO import StringIO
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import PasswordChangeForm
@ -27,9 +18,11 @@ from django.core.urlresolvers import reverse
from django.shortcuts import redirect
from django.utils.translation import ugettext as _
from django.utils.translation import activate, ugettext_lazy
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 (Image, LongTable, Paragraph, SimpleDocTemplate,
from reportlab.platypus import (LongTable, Paragraph, SimpleDocTemplate,
Spacer, Table, TableStyle)
from openslides.config.api import config
@ -266,13 +259,14 @@ class ParticipantsPasswordsPDF(PDFView):
else:
sort = 'last_name'
# create qrcode image object from system url
if draw_qrcode:
qrcode_img = qrcode.make(participant_pdf_system_url)
img_stream = StringIO()
qrcode_img.save(img_stream, 'PNG')
img_stream.seek(0)
size = 2 * cm
I = Image(img_stream, width=size, height=size)
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)
for user in User.objects.all().order_by(sort):
cell = []
cell.append(Spacer(0, 0.8 * cm))
@ -289,8 +283,7 @@ class ParticipantsPasswordsPDF(PDFView):
% (user.default_password), stylesheet['Monotype']))
cell.append(
Paragraph(participant_pdf_system_url, stylesheet['Monotype']))
if draw_qrcode:
cell.append(I)
cell.append(draw)
cell2 = []
cell2.append(Spacer(0, 0.8 * cm))
if participant_pdf_welcometext is not None:

View File

@ -2,7 +2,6 @@ Django==1.5.4
django-mptt==0.6.0
reportlab==2.7
pillow==2.2.1
qrcode==4.0.1
tornado==3.1.1
bleach==1.2.2
beautifulsoup4==4.3.2