Changeset 10695


Ignore:
Timestamp:
4 Nov 2013, 16:22:35 (11 years ago)
Author:
Henrik Bettermann
Message:

Add pdf registration form.

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

Legend:

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

    r10692 r10695  
    206206            omit_fields=self.omit_fields
    207207            )
     208
     209class ExportPDFRegistrationSlipPage(grok.View):
     210    """Deliver a PDF slip of the context.
     211    """
     212    grok.context(ICustomStudent)
     213    grok.name('registration_form.pdf')
     214    grok.require('waeup.viewStudent')
     215    prefix = 'form'
     216    omit_fields = (
     217        'suspended', 'phone',
     218        'adm_code', 'suspended_comment', 'email', 'sex',
     219        'current_mode', 'matric_number')
     220    title = ''
     221    label = 'Registration Form'
     222
     223    form_fields = grok.AutoFields(ICustomStudent).select(
     224        'marit_stat', 'lga', 'nationality',
     225        'perm_address',)
     226
     227    def render(self):
     228        studentview = StudentBasePDFFormPage(self.context.student,
     229            self.request, self.omit_fields)
     230        students_utils = getUtility(IStudentsUtils)
     231        return students_utils.renderPDF(
     232            self, 'registration_form.pdf',
     233            self.context.student, studentview, signatures=([_('Bursar')],),
     234            omit_fields=self.omit_fields)
  • main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_browser.py

    r10692 r10695  
    348348        return
    349349
    350     def test_pdf_slips(self):
     350    def test_admission_pdf_slips(self):
    351351        # Login
    352352        self.browser.open(self.login_path)
     
    367367        self.assertRaises(
    368368            LinkNotFoundError, self.browser.getLink, 'Download admission notification')
    369         self.browser.open(self.student_path, 'admission_notification.pdf')
    370         self.assertFalse('Not allowed' in self.browser.contents)
     369        self.browser.open(self.student_path + '/admission_notification.pdf')
     370        self.assertTrue('Not allowed' in self.browser.contents)
    371371        # admission notification
    372372        IWorkflowState(self.student).setState('cleared')
     
    382382        self.assertRaises(
    383383            LinkNotFoundError, self.browser.getLink, 'Download admission letter')
    384         self.browser.open(self.student_path, 'admission_slip.pdf')
    385         self.assertFalse('Not allowed' in self.browser.contents)
    386         return
    387 
    388     def test_course_registration_pdf_slip(self):
     384        self.browser.open(self.student_path + '/admission_slip.pdf')
     385        self.assertTrue('Not allowed' in self.browser.contents)
     386        return
     387
     388    def test_registration_pdf_slips(self):
    389389        # Student cant login if their password is not set
    390390        IWorkflowState(self.student).setState('school fee paid')
     
    407407        open(path, 'wb').write(self.browser.contents)
    408408        print "Sample PDF course_registration_slip.pdf written to %s" % path
    409         return
     409
     410        self.browser.open(self.student_path)
     411        self.browser.getLink("Download registration form").click()
     412        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     413        self.assertEqual(self.browser.headers['Content-Type'],
     414                         'application/pdf')
     415        path = os.path.join(samples_dir(), 'registration_form.pdf')
     416        open(path, 'wb').write(self.browser.contents)
     417        print "Sample PDF registration_form.pdf written to %s" % path
     418
     419        return
  • main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/viewlets.py

    r10691 r10695  
    7070            return ''
    7171        return self.view.url(self.view.context, self.target)
     72
     73class RegistrationFormActionButton(ManageActionButton):
     74    grok.order(4)
     75    grok.context(IStudent)
     76    grok.view(StudentBaseDisplayFormPage)
     77    grok.require('waeup.viewStudent')
     78    icon = 'actionicon_pdf.png'
     79    text = _('Download registration form')
     80    target = 'registration_form.pdf'
     81
     82    @property
     83    def target_url(self):
     84        if self.context.state in (CREATED,):
     85            return ''
     86        return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.