Ignore:
Timestamp:
13 Mar 2019, 17:48:36 (6 years ago)
Author:
Henrik Bettermann
Message:

Add ExportJHLIdCard page.

Make email field required on CustomStudentBaseEditFormPage?.

Location:
main/waeup.uniben/trunk/src/waeup/uniben/students
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py

    r15267 r15352  
    2828from waeup.kofa.browser.layout import action, KofaEditFormPage, UtilityView
    2929from waeup.kofa.students.browser import (
     30    StudentBaseEditFormPage,
    3031    StudyLevelEditFormPage, StudyLevelDisplayFormPage,
    3132    StudentBasePDFFormPage, ExportPDFCourseRegistrationSlip,
     
    5657from waeup.uniben.students.interfaces import (
    5758    ICustomStudent,
     59    ICustomStudentBase,
    5860    ICustomStudentOnlinePayment,
    5961    ICustomStudentStudyCourse,
     
    282284            self.context.student, studentview,
    283285            omit_fields=self.omit_fields,
     286            note=self.note)
     287
     288class ExportJHLIdCard(UtilityView, grok.View):
     289    """Deliver a an id card for the John Harris Library.
     290    """
     291    grok.context(ICustomStudent)
     292    grok.name('jhl_idcard.pdf')
     293    grok.require('waeup.viewStudent')
     294    prefix = 'form'
     295
     296    label = u"John Harris Library Reader's Ticket"
     297
     298    omit_fields = (
     299        'suspended', 'email',
     300        'adm_code', 'suspended_comment',
     301        'date_of_birth','reg_number',
     302        'current_mode', 'certificate',
     303        'entry_session',
     304        'flash_notice')
     305
     306    form_fields = []
     307
     308    def _signatures(self):
     309        return ([(
     310            'Current HD<br /> D. R. (Exams & Records)<br /> '
     311            'For: Registrar')],)
     312
     313    def _sigsInFooter(self):
     314        return (_("Date, Reader's Signature"),
     315                _("Date, Circulation Librarian's Signature"),
     316                )
     317
     318    @property
     319    def note(self):
     320        return """
     321<br /><br /><br /><br /><font size='12'>
     322This is to certify that the bearer whose photograph and other details appear
     323 overleaf is a registered user of <b>John Harris Library, University of Benin</b>.
     324 The card is not transferable. A replacement fee is charged for a loss,
     325 mutilation or otherwise. If found, please, return to John Harris Library,
     326 University of Benin, Benin City.
     327</font>
     328
     329"""
     330        return
     331
     332    def render(self):
     333        studentview = StudentBasePDFFormPage(self.context.student,
     334            self.request, self.omit_fields)
     335        students_utils = getUtility(IStudentsUtils)
     336        return students_utils.renderPDF(
     337            self, 'jhl_idcard',
     338            self.context.student, studentview,
     339            omit_fields=self.omit_fields,
     340            sigs_in_footer=self._sigsInFooter(),
    284341            note=self.note)
    285342
     
    595652    """Deliver a PDF slip of the context.
    596653    """
    597 
    598654    omit_fields = ('password', 'suspended', 'suspended_comment',
    599655        'phone', 'adm_code', 'email', 'date_of_birth', 'flash_notice')
     
    613669    """
    614670    with_hostel_selection = True
     671
     672class CustomStudentBaseEditFormPage(StudentBaseEditFormPage):
     673    """ View to edit student base data
     674    """
     675    form_fields = grok.AutoFields(ICustomStudentBase).select(
     676        'email', 'phone')
     677    form_fields['email'].field.required = True
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r15314 r15352  
    213213        self.browser.open(self.student_path)
    214214        self.assertFalse('examination schedule slip' in self.browser.contents)
     215
     216    def test_jhl_idcard(self):
     217        self.browser.open(self.login_path)
     218        self.browser.getControl(name="form.login").value = self.student_id
     219        self.browser.getControl(name="form.password").value = 'spwd'
     220        self.browser.getControl("Login").click()
     221        self.browser.getLink("Download JHL Id Card").click()
     222        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     223        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     224        path = os.path.join(samples_dir(), 'jhl_idcard.pdf')
     225        open(path, 'wb').write(self.browser.contents)
     226        print "Sample PDF jhl_idcard.pdf written to %s" % path
    215227
    216228    def test_jupeb_result_slip(self):
  • main/waeup.uniben/trunk/src/waeup/uniben/students/viewlets.py

    r14902 r15352  
    111111        return False
    112112
     113class JHLIdCardActionButton(ManageActionButton):
     114    grok.order(10)
     115    grok.context(ICustomStudent)
     116    grok.view(StudentBaseDisplayFormPage)
     117    grok.require('waeup.viewStudent')
     118    icon = 'actionicon_pdf.png'
     119    text = _('Download JHL Id Card')
     120    target = 'jhl_idcard.pdf'
     121
     122    @property
     123    def target_url(self):
     124        return self.view.url(self.view.context, self.target)
     125
    113126class JUPEBResultSlipActionButton(ManageActionButton):
    114127    grok.order(11)
Note: See TracChangeset for help on using the changeset viewer.