Changeset 10691 for main/waeup.kwarapoly


Ignore:
Timestamp:
4 Nov 2013, 09:19:39 (11 years ago)
Author:
Henrik Bettermann
Message:

Add Admission Notification Slip. The notification can be downloaded before payment, the slip after payment of school fee.

The difference between an admission slip/letter and a notification is still not clear.

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

    r9992 r10691  
    1818import grok
    1919from zope.i18n import translate
     20from zope.component import getUtility
    2021from hurry.workflow.interfaces import IWorkflowInfo
    2122from waeup.kofa.interfaces import ADMITTED
    22 from waeup.kofa.interfaces import MessageFactory as _
     23from waeup.kofa.browser.layout import UtilityView
     24from waeup.kofa.students.interfaces import IStudentsUtils
    2325from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
    24 from waeup.kofa.students.browser import StartClearancePage, BedTicketAddPage
     26from waeup.kofa.students.browser import (
     27    StartClearancePage, BedTicketAddPage, ExportPDFAdmissionSlipPage)
     28from waeup.kwarapoly.students.interfaces import (
     29    ICustomStudent, ICustomStudentBase)
     30from waeup.kwarapoly.interfaces import MessageFactory as _
     31from waeup.kofa.students.workflow import (
     32    ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED,
     33    VALIDATED, GRADUATED, TRANSCRIPT, CREATED, CLEARANCE)
    2534from kofacustom.nigeria.students.browser import (
    2635    NigeriaOnlinePaymentDisplayFormPage,
     
    7584    notice = ''
    7685    with_ac = False
     86
     87class CustomExportPDFAdmissionSlipPage(ExportPDFAdmissionSlipPage):
     88    """Deliver a PDF Admission slip.
     89    """
     90    grok.context(ICustomStudent)
     91
     92    omit_fields = ('date_of_birth',)
     93
     94    form_fields = grok.AutoFields(ICustomStudent).select('student_id', 'reg_number')
     95
     96    def render(self):
     97        if self.context.state in (CREATED, ADMITTED,
     98                                  CLEARANCE, REQUESTED, CLEARED):
     99            self.flash('Not allowed.')
     100            self.redirect(self.url(self.context))
     101            return
     102        students_utils = getUtility(IStudentsUtils)
     103        return students_utils.renderPDFAdmissionLetter(self,
     104            self.context.student, omit_fields=self.omit_fields)
     105
     106class ExportPDFAdmissionNotificationPage(UtilityView, grok.View):
     107    """Deliver a PDF Admission nostification slip.
     108    """
     109    grok.context(ICustomStudent)
     110    grok.name('admission_notification.pdf')
     111    grok.require('waeup.viewStudent')
     112    prefix = 'form'
     113    label = 'Notification of Provisional Admission'
     114
     115    omit_fields = ('date_of_birth',)
     116
     117    form_fields = grok.AutoFields(ICustomStudent).select(
     118        'student_id', 'reg_number', 'sex', 'lga')
     119
     120    def render(self):
     121        if self.context.state not in (ADMITTED, CLEARANCE, REQUESTED, CLEARED):
     122            self.flash('Not allowed.')
     123            self.redirect(self.url(self.context))
     124            return
     125        students_utils = getUtility(IStudentsUtils)
     126        pre_text = ''
     127        post_text = '<strong>Instructions for Freshers</strong>'
     128        return students_utils.renderPDFAdmissionLetter(self,
     129            self.context.student, omit_fields=self.omit_fields,
     130            pre_text=pre_text, post_text=post_text)
  • main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_browser.py

    r10682 r10691  
    1919import shutil
    2020import tempfile
     21from mechanize import LinkNotFoundError
    2122from StringIO import StringIO
    2223from hurry.workflow.interfaces import IWorkflowState, IWorkflowInfo
     
    345346                           self.browser.contents)
    346347        return
     348
     349    def test_pdf_slips(self):
     350        IWorkflowState(self.student).setState('school fee paid')
     351        # Login
     352        self.browser.open(self.login_path)
     353        self.browser.getControl(name="form.login").value = self.student_id
     354        self.browser.getControl(name="form.password").value = 'spwd'
     355        self.browser.getControl("Login").click()
     356        self.browser.open(self.student_path)
     357        self.browser.getLink("Download admission letter").click()
     358        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     359        self.assertEqual(self.browser.headers['Content-Type'],
     360                         'application/pdf')
     361        self.browser.open(self.student_path)
     362        self.assertRaises(
     363            LinkNotFoundError, self.browser.getLink, 'Download admission notification')
     364        self.browser.open(self.student_path, 'admission_notification.pdf')
     365        self.assertFalse('Not allowed' in self.browser.contents)
     366
     367        IWorkflowState(self.student).setState('cleared')
     368        self.browser.open(self.student_path)
     369        self.browser.getLink("Download admission notification").click()
     370        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     371        self.assertEqual(self.browser.headers['Content-Type'],
     372                         'application/pdf')
     373        self.browser.open(self.student_path)
     374        self.assertRaises(
     375            LinkNotFoundError, self.browser.getLink, 'Download admission letter')
     376        self.browser.open(self.student_path, 'admission_slip.pdf')
     377        self.assertFalse('Not allowed' in self.browser.contents)
     378        return
  • main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/viewlets.py

    r9873 r10691  
    1717##
    1818
     19import grok
    1920from waeup.kofa.students.viewlets import (
    20     AddPreviousPaymentActionButton, AddBalancePaymentActionButton)
     21    AddPreviousPaymentActionButton, AddBalancePaymentActionButton,
     22    ManageActionButton)
     23from waeup.kofa.students.interfaces import IStudent
     24from waeup.kofa.students.browser import StudentBaseDisplayFormPage
     25from waeup.kofa.students.workflow import (
     26    ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED,
     27    VALIDATED, GRADUATED, TRANSCRIPT, CREATED, CLEARANCE)
     28from waeup.kwarapoly.interfaces import MessageFactory as _
    2129
    2230class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton):
     
    3139    def target_url(self):
    3240        return ''
     41
     42class AdmissionNotificationActionButton(ManageActionButton):
     43    grok.order(4)
     44    grok.context(IStudent)
     45    grok.view(StudentBaseDisplayFormPage)
     46    grok.require('waeup.viewStudent')
     47    icon = 'actionicon_pdf.png'
     48    text = _('Download admission notification')
     49    target = 'admission_notification.pdf'
     50
     51    @property
     52    def target_url(self):
     53        if self.context.state not in (ADMITTED, CLEARANCE, REQUESTED, CLEARED):
     54            return ''
     55        return self.view.url(self.view.context, self.target)
     56
     57class AdmissionSlipActionButton(ManageActionButton):
     58    grok.order(4)
     59    grok.context(IStudent)
     60    grok.view(StudentBaseDisplayFormPage)
     61    grok.require('waeup.viewStudent')
     62    icon = 'actionicon_pdf.png'
     63    text = _('Download admission letter')
     64    target = 'admission_slip.pdf'
     65
     66    @property
     67    def target_url(self):
     68        if self.context.state in (CREATED, ADMITTED,
     69                                  CLEARANCE, REQUESTED, CLEARED):
     70            return ''
     71        return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.