Merge pull request #2810 from tsiegleauq/issue2665-qr-code-pdf

Add QR code in user access list pdf (fixes #2665)
This commit is contained in:
Norman Jäckel 2017-01-06 11:08:22 +01:00 committed by GitHub
commit c12d985ab6
4 changed files with 111 additions and 67 deletions

View File

@ -66,6 +66,7 @@ Users:
- Added new field 'is_committee' and new default group 'Committees'. - Added new field 'is_committee' and new default group 'Committees'.
- Improved users CSV import (use group names instead of id). - Improved users CSV import (use group names instead of id).
- Added more multiselect actions. - Added more multiselect actions.
- Added QR code in users access pdf.
Other: Other:
- Django 1.10 is now supported. Dropped support for Django 1.8 and 1.9. - Django 1.10 is now supported. Dropped support for Django 1.8 and 1.9.

View File

@ -203,7 +203,7 @@ angular.module('OpenSlidesApp.core.pdf', [])
}; };
}; };
// Generates the document(definition) for pdfMake // Generates the document(definition) for pdfMake
var getDocument = function() { var getDocument = function(noFooter) {
var content = contentProvider.getContent(); var content = contentProvider.getContent();
return { return {
pageSize: 'A4', pageSize: 'A4',
@ -213,7 +213,7 @@ angular.module('OpenSlidesApp.core.pdf', [])
fontSize: 10 fontSize: 10
}, },
header: header, header: header,
footer: footer, footer: noFooter ? '' : footer,
content: content, content: content,
styles: { styles: {
title: { title: {
@ -296,6 +296,9 @@ angular.module('OpenSlidesApp.core.pdf', [])
}, },
bold: { bold: {
bold: true, bold: true,
},
small: {
fontSize: 8,
} }
} }
}; };

View File

@ -128,10 +128,8 @@ angular.module('OpenSlidesApp.users.pdf', ['OpenSlidesApp.core.pdf'])
}; };
var createAccessDataContent = function(user) { var createAccessDataContent = function(user) {
var accessDataColumns = { // wlan access data
columns: [ var columnWifi = [
{
stack: [
{ {
text: gettextCatalog.getString("WLAN access data"), text: gettextCatalog.getString("WLAN access data"),
style: 'userDataHeading' style: 'userDataHeading'
@ -160,10 +158,30 @@ angular.module('OpenSlidesApp.users.pdf', ['OpenSlidesApp.core.pdf'])
text: Config.get('users_pdf_wlan_encryption').value || '-', text: Config.get('users_pdf_wlan_encryption').value || '-',
style: 'userDataValue' style: 'userDataValue'
}, },
] {
text: "\n"
}
];
// wifi qr code
if (Config.get('users_pdf_wlan_ssid').value && Config.get('users_pdf_wlan_encryption').value) {
var wifiQrCode = "WIFI:S:" + Config.get('users_pdf_wlan_ssid').value +
";T:" + Config.get('users_pdf_wlan_encryption').value +
";P:" + Config.get('users_pdf_wlan_password').value + ";;";
columnWifi.push(
{
qr: wifiQrCode,
fit: 120,
margin: [0, 0, 0, 8]
}, },
{ {
stack: [ text: gettextCatalog.getString("Scan this QR code to connect to WLAN."),
style: 'small'
}
);
}
// openslides access data
var columnOpenSlides = [
{ {
text: gettextCatalog.getString("OpenSlides access data"), text: gettextCatalog.getString("OpenSlides access data"),
style: 'userDataHeading' style: 'userDataHeading'
@ -193,10 +211,31 @@ angular.module('OpenSlidesApp.users.pdf', ['OpenSlidesApp.core.pdf'])
link: Config.get('users_pdf_url').value, link: Config.get('users_pdf_url').value,
style: 'userDataValue' style: 'userDataValue'
}, },
] {
text: "\n"
} }
];
// url qr code
if (Config.get('users_pdf_url').value) {
columnOpenSlides.push(
{
qr: Config.get('users_pdf_url').value,
fit: 120,
margin: [0, 0, 0, 8]
},
{
text: gettextCatalog.getString("Scan this QR code to open URL."),
style: 'small'
}
);
}
var accessDataColumns = {
columns: [
columnWifi,
columnOpenSlides,
], ],
margin: [0,20] margin: [0, 20]
}; };
return accessDataColumns; return accessDataColumns;

View File

@ -681,7 +681,8 @@ angular.module('OpenSlidesApp.users.site', [
var userAccessDataListContentProvider = UserAccessDataListContentProvider.createInstance( var userAccessDataListContentProvider = UserAccessDataListContentProvider.createInstance(
$scope.usersFiltered, $scope.groups, Config); $scope.usersFiltered, $scope.groups, Config);
var documentProvider = PdfMakeDocumentProvider.createInstance(userAccessDataListContentProvider); var documentProvider = PdfMakeDocumentProvider.createInstance(userAccessDataListContentProvider);
pdfMake.createPdf(documentProvider.getDocument()).download(filename); var noFooter = true;
pdfMake.createPdf(documentProvider.getDocument(noFooter)).download(filename);
}; };
// Export as a csv file // Export as a csv file
$scope.csvExport = function () { $scope.csvExport = function () {