Changeset 17650 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 24 Nov 2023, 11:20:06 (13 months ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r17497 r17650 24 24 import os 25 25 import textwrap 26 import segno 26 27 from cStringIO import StringIO 27 28 from datetime import datetime … … 632 633 self.context.student, omit_fields=self.omit_fields, 633 634 letterhead_path=letterhead_path, post_text=None) 635 636 class QRCodeView(UtilityView, grok.View): 637 """View which renders a QRCode only. 638 """ 639 grok.context(IStudent) 640 grok.name('qrcode_admission_letter.png') 641 grok.require('waeup.viewStudent') 642 scale = 3 643 uri = 'admission_slip.pdf' 644 645 def render(self): 646 qrcode = segno.make(self.url(self.context, self.uri)) 647 self.response.setHeader('Content-Type', 'image/png') 648 return qrcode.png_data_uri( 649 scale=self.scale).split(',')[1].decode('base64') 634 650 635 651 class StudentBaseManageFormPage(KofaEditFormPage): -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r17261 r17650 3035 3035 self.browser.contents) 3036 3036 3037 def test_student_qrcodeview(self): 3038 IWorkflowInfo(self.student).fireTransition('admit') 3039 self.browser.open(self.login_path) 3040 self.browser.getControl(name="form.login").value = self.student_id 3041 self.browser.getControl(name="form.password").value = 'spwd' 3042 self.browser.getControl("Login").click() 3043 self.browser.open(self.student_path + '/qrcode_admission_letter.png') 3044 self.assertEqual(self.browser.headers['Status'], '200 Ok') 3045 self.assertEqual(self.browser.headers['Content-Type'], 'image/png') 3046 path = os.path.join(samples_dir(), 'qrcode_admission_letter.png') 3047 open(path, 'wb').write(self.browser.contents) 3048 print "Sample png file written to %s" % path 3049 3037 3050 def test_student_course_registration(self): 3038 3051 # Student cant login if their password is not set
Note: See TracChangeset for help on using the changeset viewer.