Ignore:
Timestamp:
20 Nov 2015, 10:23:08 (9 years ago)
Author:
Henrik Bettermann
Message:

Add personal data slip.

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

Legend:

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

    r13463 r13489  
    335335
    336336    @property
     337    def title(self):
     338        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     339        return translate(_('Matriculation Number'), 'waeup.kofa',
     340            target_language=portal_language)
     341
     342    @property
    337343    def label(self):
    338344        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     
    355361            pre_text=pre_text, post_text='')
    356362
     363class ExportPersonalDataSlip(UtilityView, grok.View):
     364    """Deliver a PDF notification slip.
     365    """
     366    grok.context(ICustomStudent)
     367    grok.name('personal_data_slip.pdf')
     368    grok.require('waeup.viewStudent')
     369    prefix = 'form'
     370    note = None
     371
     372    form_fields = grok.AutoFields(ICustomStudentPersonal).omit('personal_updated')
     373    omit_fields = ('suspended', 'suspended_comment', 'adm_code', 'certificate')
     374
     375    @property
     376    def title(self):
     377        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     378        return translate(_('Personal Data'), 'waeup.kofa',
     379            target_language=portal_language)
     380
     381    @property
     382    def label(self):
     383        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     384        return translate(_('Personal Data Slip\n'),
     385            'waeup.kofa', target_language=portal_language) \
     386            + ' %s' % self.context.display_fullname
     387
     388    def render(self):
     389        studentview = StudentBasePDFFormPage(self.context.student,
     390            self.request, self.omit_fields)
     391        students_utils = getUtility(IStudentsUtils)
     392        return students_utils.renderPDF(self, 'personal_data_slip.pdf',
     393            self.context.student, studentview, note=self.note,
     394            omit_fields=self.omit_fields)
     395
    357396class CustomAccommodationManageFormPage(NigeriaAccommodationManageFormPage):
    358397    """ Page to manage bed tickets.
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r13462 r13489  
    499499        return
    500500
     501    def test_personal_data_slip(self):
     502        # Login as student
     503        self.browser.open(self.login_path)
     504        IWorkflowState(self.student).setState('school fee paid')
     505        self.browser.open(self.login_path)
     506        self.browser.getControl(name="form.login").value = self.student_id
     507        self.browser.getControl(name="form.password").value = 'spwd'
     508        self.browser.getControl("Login").click()
     509        self.browser.getLink("Personal Data").click()
     510        self.assertRaises(
     511            LinkNotFoundError,
     512            self.browser.getLink, 'Download personal data slip')
     513        self.student.father_name = u'Rudolf'
     514        self.browser.open(self.personal_path)
     515        self.browser.getLink("Download personal data slip").click()
     516        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     517        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     518        path = os.path.join(samples_dir(), 'personal_data_slip.pdf')
     519        open(path, 'wb').write(self.browser.contents)
     520        print "Sample PDF personal_data_slip.pdf written to %s" % path
     521        return
     522
    501523    def test_student_course_registration(self):
    502524        IWorkflowState(self.student).setState('school fee paid')
  • main/waeup.aaue/trunk/src/waeup/aaue/students/viewlets.py

    r13380 r13489  
    2828from waeup.kofa.students.browser import StudyLevelDisplayFormPage
    2929
    30 from waeup.aaue.students.interfaces import ICustomStudentStudyLevel
     30from waeup.aaue.students.interfaces import (
     31    ICustomStudent, ICustomStudentStudyLevel)
     32from waeup.aaue.students.browser import CustomStudentPersonalDisplayFormPage
    3133from waeup.aaue.interfaces import MessageFactory as _
    3234
     
    98100        return self.view.url(self.view.context, self.target)
    99101
     102class PersonalDataSlipActionButton(ManageActionButton):
     103    grok.order(3)
     104    grok.context(ICustomStudent)
     105    grok.view(CustomStudentPersonalDisplayFormPage)
     106    grok.require('waeup.viewStudent')
     107    icon = 'actionicon_pdf.png'
     108    text = _('Download personal data slip')
     109    target = 'personal_data_slip.pdf'
     110
     111    @property
     112    def target_url(self):
     113        if not self.context.father_name:
     114            return ''
     115        return self.view.url(self.view.context, self.target)
     116
    100117class StudentPassportActionButton(StudentPassportActionButton):
    101118    """Inherit from same class in base package, not from kofacustom.nigeria
Note: See TracChangeset for help on using the changeset viewer.