Changeset 15977


Ignore:
Timestamp:
3 Feb 2020, 14:54:07 (5 years ago)
Author:
Henrik Bettermann
Message:

Add Examination Clearance Slip.

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

Legend:

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

    r15961 r15977  
    2222from zope.security import checkPermission
    2323from hurry.workflow.interfaces import IWorkflowInfo
    24 from waeup.kofa.interfaces import ADMITTED, IKofaUtils
     24from waeup.kofa.interfaces import ADMITTED, VALIDATED, IKofaUtils
    2525from waeup.kofa.interfaces import MessageFactory as _
    2626from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
     
    3030    ExportPDFAdmissionSlip, StudyLevelDisplayFormPage,
    3131    PaymentsManageFormPage,
    32     OnlinePaymentApproveView)
     32    OnlinePaymentApproveView,
     33    StudentBasePDFFormPage)
    3334from kofacustom.nigeria.students.browser import (
    3435    NigeriaOnlinePaymentDisplayFormPage,
     
    205206    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level')
    206207
     208class ExportPDFExaminationClearanceSlip(CustomExportPDFCourseRegistrationSlip):
     209    """Deliver a PDF slip of the context.
     210    """
     211
     212    grok.name('examination_clearance_slip.pdf')
     213
     214    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit(
     215        'gpa', 'transcript_remark', 'total_credits', 'level_verdict')
     216
     217    @property
     218    def label(self):
     219        return 'Year %s Examination Clearance' % self.context.level_session
     220
     221    def update(self):
     222        if self.context.student.state != VALIDATED \
     223            or self.context.student.current_level != self.context.level:
     224            self.flash(_('Forbidden'), type="warning")
     225            self.redirect(self.url(self.context))
     226
     227    def render(self):
     228        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     229        Code = translate('Code', 'waeup.kofa', target_language=portal_language)
     230        Title = translate('Title', 'waeup.kofa', target_language=portal_language)
     231        Dept = translate('Dept.', 'waeup.kofa', target_language=portal_language)
     232        Faculty = translate('Faculty', 'waeup.kofa', target_language=portal_language)
     233        Cred = translate(_('Credits'), 'waeup.uniben', target_language=portal_language)
     234        Grade = translate('Grade', 'waeup.kofa', target_language=portal_language)
     235        studentview = StudentBasePDFFormPage(self.context.student,
     236            self.request, self.omit_fields)
     237        students_utils = getUtility(IStudentsUtils)
     238
     239        tabledata = []
     240        tableheader = []
     241        for i in range(1,7):
     242            tabledata.append(sorted(
     243                [value for value in self.context.values() if value.semester == i],
     244                key=lambda value: str(value.semester) + value.code))
     245            tableheader.append([(Code,'code', 2.5),
     246                             (Title,'title', 5),
     247                             (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5),
     248                             (Cred, 'credits', 1.5),
     249                             ])
     250        return students_utils.renderPDF(
     251            self, 'examination_clearance_slip.pdf',
     252            self.context.student, studentview,
     253            tableheader=tableheader,
     254            tabledata=tabledata,
     255            omit_fields=self.omit_fields
     256            )
     257
     258
    207259class CustomPaymentsManageFormPage(PaymentsManageFormPage):
    208260    """ Page to manage the student payments. This manage form page is for
  • main/waeup.fceokene/trunk/src/waeup/fceokene/students/tests/test_browser.py

    r15887 r15977  
    442442                           self.browser.contents)
    443443        self.browser.getControl("Create course list now").click()
    444         # Students can't open the customized pdf course registration slip
     444        # Students can open the customized pdf course registration slip
    445445        self.browser.open(
    446446            self.student_path + '/studycourse/100/course_registration_slip.pdf')
     
    450450        open(path, 'wb').write(self.browser.contents)
    451451        print "Sample PDF course_registration_slip.pdf written to %s" % path
     452
     453        # Students can open the examination clearance slip if they are
     454        # in state courses validated
     455        IWorkflowState(self.student).setState('courses validated')
     456        self.browser.open(self.student_path + '/studycourse/100')
     457        self.browser.getLink("Download examination clearance slip").click()
     458        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     459        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     460        path = os.path.join(samples_dir(), 'examination_clearance_slip.pdf')
     461        open(path, 'wb').write(self.browser.contents)
     462        print "Sample PDF examination_clearance_slip.pdf written to %s" % path
  • main/waeup.fceokene/trunk/src/waeup/fceokene/students/viewlets.py

    r15940 r15977  
    1818
    1919import grok
     20from waeup.kofa.browser.viewlets import ManageActionButton
    2021from waeup.kofa.students.viewlets import (
    2122    AdmissionSlipActionButton,
    2223    AddPreviousPaymentActionButton, AddBalancePaymentActionButton,
    2324    ApprovePaymentActionButton)
    24 from waeup.kofa.students.workflow import ADMITTED
     25from waeup.kofa.students.interfaces import IStudentStudyLevel
     26from waeup.kofa.students.browser import StudyLevelDisplayFormPage
     27from waeup.kofa.students.workflow import ADMITTED, VALIDATED
    2528
    2629class AdmissionSlipActionButton(AdmissionSlipActionButton):
     
    4750
    4851    grok.require('waeup.manageStudent')
     52
     53class CourseRegistrationSlipActionButton(ManageActionButton):
     54    grok.order(6)
     55    grok.context(IStudentStudyLevel)
     56    grok.view(StudyLevelDisplayFormPage)
     57    grok.require('waeup.viewStudent')
     58    icon = 'actionicon_pdf.png'
     59    text = 'Download examination clearance slip'
     60    target = 'examination_clearance_slip.pdf'
     61
     62    @property
     63    def target_url(self):
     64        is_current = self.context.__parent__.is_current
     65        if not is_current:
     66            return ''
     67        if self.context.student.state != VALIDATED \
     68            or self.context.student.current_level != self.context.level:
     69            return ''
     70        return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.