Merge pull request #1497 from ostcar/users-password-pdf
Fixed users password pdf view.
This commit is contained in:
commit
d0d01ed71c
@ -5,8 +5,14 @@ from reportlab.graphics.barcode.qr import QrCodeWidget
|
|||||||
from reportlab.graphics.shapes import Drawing
|
from reportlab.graphics.shapes import Drawing
|
||||||
from reportlab.lib import colors
|
from reportlab.lib import colors
|
||||||
from reportlab.lib.units import cm
|
from reportlab.lib.units import cm
|
||||||
from reportlab.platypus import (LongTable, PageBreak, Paragraph, Spacer, Table,
|
from reportlab.platypus import (
|
||||||
TableStyle)
|
LongTable,
|
||||||
|
PageBreak,
|
||||||
|
Paragraph,
|
||||||
|
Spacer,
|
||||||
|
Table,
|
||||||
|
TableStyle,
|
||||||
|
)
|
||||||
|
|
||||||
from openslides.config.api import config
|
from openslides.config.api import config
|
||||||
from openslides.utils.pdf import stylesheet
|
from openslides.utils.pdf import stylesheet
|
||||||
@ -16,7 +22,7 @@ from .models import User
|
|||||||
|
|
||||||
def users_to_pdf(pdf):
|
def users_to_pdf(pdf):
|
||||||
"""
|
"""
|
||||||
Create a list of all users as PDF
|
Create a list of all users as PDF.
|
||||||
"""
|
"""
|
||||||
data = [['#', _('Title'), _('Last Name'), _('First Name'),
|
data = [['#', _('Title'), _('Last Name'), _('First Name'),
|
||||||
_('Structure level'), _('Group')]]
|
_('Structure level'), _('Group')]]
|
||||||
@ -52,7 +58,7 @@ def users_to_pdf(pdf):
|
|||||||
|
|
||||||
def users_passwords_to_pdf(pdf):
|
def users_passwords_to_pdf(pdf):
|
||||||
"""
|
"""
|
||||||
Create access data sheets for all users as PDF
|
Create access data sheets for all users as PDF.
|
||||||
"""
|
"""
|
||||||
users_pdf_wlan_ssid = config["users_pdf_wlan_ssid"] or "-"
|
users_pdf_wlan_ssid = config["users_pdf_wlan_ssid"] or "-"
|
||||||
users_pdf_wlan_password = config["users_pdf_wlan_password"] or "-"
|
users_pdf_wlan_password = config["users_pdf_wlan_password"] or "-"
|
||||||
@ -82,7 +88,7 @@ def users_passwords_to_pdf(pdf):
|
|||||||
qrcode_wlan_draw.add(qrcode_wlan)
|
qrcode_wlan_draw.add(qrcode_wlan)
|
||||||
|
|
||||||
for user in User.objects.all().order_by(sort):
|
for user in User.objects.all().order_by(sort):
|
||||||
pdf.append(Paragraph(escape(user), stylesheet['h1']))
|
pdf.append(Paragraph(escape(user.get_full_name()), stylesheet['h1']))
|
||||||
pdf.append(Spacer(0, 1 * cm))
|
pdf.append(Spacer(0, 1 * cm))
|
||||||
data = []
|
data = []
|
||||||
# WLAN access data
|
# WLAN access data
|
||||||
|
@ -8,12 +8,12 @@ from rest_framework import status
|
|||||||
|
|
||||||
from openslides.utils.rest_api import ModelViewSet, Response
|
from openslides.utils.rest_api import ModelViewSet, Response
|
||||||
from openslides.utils.views import (
|
from openslides.utils.views import (
|
||||||
|
APIView,
|
||||||
CSVImportView,
|
CSVImportView,
|
||||||
FormView,
|
FormView,
|
||||||
LoginMixin,
|
LoginMixin,
|
||||||
PDFView,
|
PDFView,
|
||||||
UpdateView,
|
UpdateView,
|
||||||
APIView
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from .csv_import import import_users
|
from .csv_import import import_users
|
||||||
@ -24,7 +24,7 @@ from .serializers import (
|
|||||||
GroupSerializer,
|
GroupSerializer,
|
||||||
UserCreateUpdateSerializer,
|
UserCreateUpdateSerializer,
|
||||||
UserFullSerializer,
|
UserFullSerializer,
|
||||||
UserShortSerializer
|
UserShortSerializer,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,3 +87,17 @@ class TestUserLoginView(TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
json.loads(response.content.decode('utf-8')),
|
json.loads(response.content.decode('utf-8')),
|
||||||
{'success': False})
|
{'success': False})
|
||||||
|
|
||||||
|
|
||||||
|
class TestUsersPasswordsPDF(TestCase):
|
||||||
|
def test_get(self):
|
||||||
|
"""
|
||||||
|
Tests that the view returns the status code 200.
|
||||||
|
"""
|
||||||
|
self.client.login(username='admin', password='admin')
|
||||||
|
response = self.client.get('/users/passwords/print/')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
response.status_code,
|
||||||
|
200,
|
||||||
|
"The status code of the user password PDF view should be 200.")
|
||||||
|
Loading…
Reference in New Issue
Block a user