Ignore:
Timestamp:
26 Sep 2018, 05:47:59 (6 years ago)
Author:
Henrik Bettermann
Message:

Implement matric number generator.

Location:
main/kofacustom.edopoly/trunk/src/kofacustom/edopoly
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/browser/pages.py

    r15015 r15176  
    1919from waeup.kofa.browser.pages import (
    2020    SessionConfigurationAddFormPage, SessionConfigurationManageFormPage,
    21     LoginPage, CertificatePage, CertificateManageFormPage)
     21    LoginPage, CertificatePage, CertificateManageFormPage,
     22    ConfigurationContainerManageFormPage)
     23from waeup.kofa.interfaces import IConfigurationContainer
    2224from waeup.kofa.university.interfaces import ICertificate
    2325from kofacustom.edopoly.interfaces import (
    2426    ICustomSessionConfiguration, ICustomSessionConfigurationAdd)
     27
     28class CustomConfigurationContainerManageFormPage(
     29    ConfigurationContainerManageFormPage):
     30
     31    form_fields = grok.AutoFields(IConfigurationContainer).omit(
     32        'frontpage_dict')
     33    form_fields['maintmode_enabled_by'].for_display = True
    2534
    2635class CustomSessionConfigurationAddFormPage(SessionConfigurationAddFormPage):
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/locales/en/LC_MESSAGES/waeup.kofa.po

    r15019 r15176  
    3030msgid "Foreigner Returning School Fee"
    3131msgstr "Tuition Fee 4 (not used)"
     32
     33msgid "Next Matriculation Number Integer"
     34msgstr "Next ND-FT Matriculation Number Integer"
     35
     36msgid "Integer used for constructing the next matriculation number"
     37msgstr ""
     38"Integer used for constructing the next matriculation number of ND-FT students"
     39
     40msgid "Next Matriculation Number Integer 2"
     41msgstr "Next HND-FT Matriculation Number Integer"
     42
     43msgid "2nd integer used for constructing the next matriculation number"
     44msgstr ""
     45"Integer used for constructing the next matriculation number of HND-FT students"
     46
     47msgid "Next Matriculation Number Integer 3"
     48msgstr "Next ND-PT Matriculation Number Integer"
     49
     50msgid "3rd integer used for constructing the next matriculation number"
     51msgstr ""
     52"Integer used for constructing the next matriculation number of ND-PT students"
     53
     54msgid "Next Matriculation Number Integer 4"
     55msgstr "Next HND-PT Matriculation Number Integer"
     56
     57msgid "4th integer used for constructing the next matriculation number"
     58msgstr ""
     59"Integer used for constructing the next matriculation number of HND-PT "
     60"students"
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/students/browser.py

    r15167 r15176  
    2323from waeup.kofa.interfaces import REQUESTED, IExtFileStore, IKofaUtils
    2424from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
    25 from waeup.kofa.browser.layout import KofaEditFormPage
    26 from waeup.kofa.browser.layout import action, jsaction
     25from waeup.kofa.browser.layout import (
     26    KofaEditFormPage, UtilityView, action, jsaction)
    2727from waeup.kofa.students.browser import (
    2828    StudyLevelEditFormPage, StudyLevelDisplayFormPage,
     
    3131    BedTicketAddPage, ExportPDFTranscriptSlip,
    3232    msave, emit_lock_message)
    33 from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket
     33from waeup.kofa.students.interfaces import (
     34    IStudentsUtils, ICourseTicket, IStudent)
    3435from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
    3536from kofacustom.nigeria.students.browser import (
     
    4142    NigeriaExportPDFClearanceSlip,
    4243    )
    43 
    4444from kofacustom.edopoly.students.interfaces import (
    4545    ICustomStudentOnlinePayment, ICustomStudentStudyCourse,
    46     ICustomStudentStudyLevel)
     46    ICustomStudentStudyLevel, ICustomStudent)
    4747from kofacustom.edopoly.interfaces import MessageFactory as _
    4848
     
    146146            return
    147147        return
     148
     149class StudentGetMatricNumberPage(UtilityView, grok.View):
     150    """ Construct and set the matriculation number.
     151    """
     152    grok.context(IStudent)
     153    grok.name('get_matric_number')
     154    grok.require('waeup.viewStudent')
     155
     156    def update(self):
     157        students_utils = getUtility(IStudentsUtils)
     158        msg, mnumber = students_utils.setMatricNumber(self.context)
     159        if msg:
     160            self.flash(msg, type="danger")
     161        else:
     162            self.flash(_('Matriculation number %s assigned.' % mnumber))
     163            self.context.writeLogMessage(self, '%s assigned' % mnumber)
     164        self.redirect(self.url(self.context))
     165        return
     166
     167    def render(self):
     168        return
     169
     170class ExportPDFMatricNumberSlip(UtilityView, grok.View):
     171    """Deliver a PDF notification slip.
     172    """
     173    grok.context(ICustomStudent)
     174    grok.name('matric_number_slip.pdf')
     175    grok.require('waeup.viewStudent')
     176    prefix = 'form'
     177
     178    form_fields = grok.AutoFields(ICustomStudent).select(
     179        'student_id', 'matric_number')
     180    omit_fields = ('date_of_birth', 'current_level', 'flash_notice')
     181
     182    @property
     183    def title(self):
     184        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     185        return translate(_('Matriculation Number'), 'waeup.kofa',
     186            target_language=portal_language)
     187
     188    @property
     189    def label(self):
     190        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     191        return translate(_('Matriculation Number Slip\n'),
     192            target_language=portal_language) \
     193            + ' %s' % self.context.display_fullname
     194
     195    def render(self):
     196        if self.context.state not in (PAID,) or not self.context.is_fresh \
     197            or not self.context.matric_number:
     198            self.flash('Not allowed.', type="danger")
     199            self.redirect(self.url(self.context))
     200            return
     201        students_utils = getUtility(IStudentsUtils)
     202        pre_text = _('Congratulations! Your acceptance fee and school fees ' +
     203                     'payments have been received and your matriculation ' +
     204                     'number generated with details as follows.')
     205        return students_utils.renderPDFAdmissionLetter(self,
     206            self.context.student, omit_fields=self.omit_fields,
     207            pre_text=pre_text, post_text='')
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/students/utils.py

    r15105 r15176  
    1717##
    1818from time import time
     19import grok
    1920from zope.component import createObject, getUtility
    2021from waeup.kofa.interfaces import (IKofaUtils,
     
    246247        payment.amount_auth = amount
    247248        return None, payment
     249
     250    def constructMatricNumber(self, student):
     251        faccode = student.faccode
     252        depcode = student.depcode
     253        certcode = student.certcode
     254        year = unicode(student.entry_session)[2:]
     255        if not student.state in (PAID, ) or not student.is_fresh:
     256            return _('Matriculation number cannot be set.'), None
     257
     258        # ESITM/ENG/MEC/11/5367
     259        if student.current_mode == 'nd_ft':
     260            next_integer = grok.getSite()['configuration'].next_matric_integer
     261            if next_integer == 0:
     262                return _('Matriculation number cannot be set.'), None
     263            return None, "ESITM/%s/%s/%s/%05d" % (
     264                faccode, depcode, year, next_integer)
     265
     266        # ESITM/ENG/MEC/HND/11/5367
     267        if student.current_mode == 'hnd_ft':
     268            next_integer = grok.getSite()['configuration'].next_matric_integer_2
     269            if next_integer == 0:
     270                return _('Matriculation number cannot be set.'), None
     271            return None, "ESITM/%s/%s/HND/%s/%05d" % (
     272                faccode, depcode, year, next_integer)
     273
     274        # ESITM/PT-ND/ENG/MEC/11/5367
     275        if student.current_mode == 'nd_pt':
     276            next_integer = grok.getSite()['configuration'].next_matric_integer_3
     277            if next_integer == 0:
     278                return _('Matriculation number cannot be set.'), None
     279            return None, "ESITM/PT-ND/%s/%s/%s/%05d" % (
     280                faccode, depcode, year, next_integer)
     281
     282        # ???
     283        if student.current_mode == 'hnd_pt':
     284            pass
     285
     286        return _('Matriculation number cannot be set.'), None
  • main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/students/viewlets.py

    r15000 r15176  
    2020from waeup.kofa.interfaces import REQUESTED
    2121from waeup.kofa.browser.viewlets import ManageActionButton
    22 from kofacustom.edopoly.students.interfaces import (
    23     ICustomStudentStudyCourse, ICustomStudentStudyLevel)
    2422from waeup.kofa.students.fileviewlets import (
    2523    StudentFileDisplay, StudentFileUpload, StudentImage)
    2624from waeup.kofa.students.browser import (
    2725    ExportPDFClearanceSlip, StudyCourseDisplayFormPage,
    28     StudyLevelDisplayFormPage)
     26    StudyLevelDisplayFormPage, StudentBaseDisplayFormPage)
     27from waeup.kofa.students.interfaces import IStudent
     28
     29from kofacustom.edopoly.students.interfaces import (
     30    ICustomStudentStudyCourse, ICustomStudentStudyLevel)
    2931
    3032from kofacustom.nigeria.interfaces import MessageFactory as _
     33
     34class GetMatricNumberActionButton(ManageActionButton):
     35    grok.order(10)
     36    grok.context(IStudent)
     37    grok.view(StudentBaseDisplayFormPage)
     38    grok.require('waeup.viewStudent')
     39    #grok.require('waeup.manageStudent')
     40    icon = 'actionicon_count.png'
     41    text = _('Get Matriculation Number')
     42
     43    @property
     44    def target_url(self):
     45        students_utils = getUtility(IStudentsUtils)
     46        if self.context.matric_number:
     47            return ''
     48        error, matric_number = students_utils.constructMatricNumber(
     49            self.context)
     50        if error:
     51            return ''
     52        return self.view.url(self.view.context, 'get_matric_number')
     53
     54class MatricNumberSlipActionButton(ManageActionButton):
     55    grok.order(10)
     56    grok.context(IStudent)
     57    grok.view(StudentBaseDisplayFormPage)
     58    grok.require('waeup.viewStudent')
     59    icon = 'actionicon_pdf.png'
     60    text = _('Download matriculation number slip')
     61    target = 'matric_number_slip.pdf'
     62
     63    @property
     64    def target_url(self):
     65        if self.context.state not in (PAID,) or not self.context.is_fresh \
     66            or not self.context.matric_number:
     67            return ''
     68        return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.