Changeset 15288


Ignore:
Timestamp:
10 Jan 2019, 10:12:19 (6 years ago)
Author:
Henrik Bettermann
Message:

Add matric number construction tools.

Location:
main/kofacustom.dspg/trunk/src/kofacustom/dspg
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/interfaces.py

    r15264 r15288  
    410410        )
    411411
     412    lsfp_penalty_fee = schema.Float(
     413        title = _(u'HND/ND FT Fresh Student Late School Fee Payment Penalty Fee'),
     414        default = 0.0,
     415        required = True,
     416        )
    412417
    413418    def getSessionString():
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/locales/en/LC_MESSAGES/waeup.kofa.po

    r15189 r15288  
    4040
    4141msgid "Next Matriculation Number Integer"
    42 msgstr "Next ND Matriculation Number Integer"
     42msgstr "Next ND FT Matriculation Number Integer"
    4343
    4444msgid "Integer used for constructing the next matriculation number"
    4545msgstr ""
    46 "Integer used for constructing the next matriculation number of ND students"
     46"Integer used for constructing the next matriculation number of ND FT students"
    4747
    4848msgid "Next Matriculation Number Integer 2"
     49msgstr "Next HND FT Matriculation Number Integer"
     50
     51msgid "Next Matriculation Number Integer 3"
    4952msgstr "Next ND PT Matriculation Number Integer"
    5053
    51 msgid "Next Matriculation Number Integer 3"
    52 msgstr "Next HND Matriculation Number Integer"
    53 
    5454msgid "Next Matriculation Number Integer 4"
    55 msgstr "Next HND PT Matriculation Number Integer"
     55msgstr "Next HND PT Matriculation Number Integer "
    5656
    5757msgid "2nd integer used for constructing the next matriculation number"
    5858msgstr ""
    59 "Integer used for constructing the next matriculation number of ND PT students"
     59"Integer used for constructing the next matriculation number of HND FT "
     60"students"
    6061
    6162msgid "3rd integer used for constructing the next matriculation number"
    6263msgstr ""
    63 "Integer used for constructing the next matriculation number of HND students"
     64"Integer used for constructing the next matriculation number of ND PT "
     65"students (start value 10001)"
    6466
    6567msgid "4th integer used for constructing the next matriculation number"
    6668msgstr ""
    6769"Integer used for constructing the next matriculation number of HND PT "
    68 "students"
     70"students (start value 10001)"
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/browser.py

    r15225 r15288  
    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    ExportPDFTranscriptSlip, BedTicketAddPage,
    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 (
     
    4243    NigeriaAccommodationManageFormPage,
    4344    )
    44 
    4545from kofacustom.dspg.students.interfaces import (
    4646    ICustomStudentOnlinePayment, ICustomStudentStudyCourse,
    47     ICustomStudentStudyLevel)
     47    ICustomStudentStudyLevel, ICustomStudent)
    4848from kofacustom.dspg.interfaces import MessageFactory as _
    4949
     
    176176    """
    177177    with_hostel_selection = True
     178
     179class StudentGetMatricNumberPage(UtilityView, grok.View):
     180    """ Construct and set the matriculation number.
     181    """
     182    grok.context(IStudent)
     183    grok.name('get_matric_number')
     184    grok.require('waeup.viewStudent')
     185
     186    def update(self):
     187        students_utils = getUtility(IStudentsUtils)
     188        msg, mnumber = students_utils.setMatricNumber(self.context)
     189        if msg:
     190            self.flash(msg, type="danger")
     191        else:
     192            self.flash(_('Matriculation number %s assigned.' % mnumber))
     193            self.context.writeLogMessage(self, '%s assigned' % mnumber)
     194        self.redirect(self.url(self.context))
     195        return
     196
     197    def render(self):
     198        return
     199
     200class ExportPDFMatricNumberSlip(UtilityView, grok.View):
     201    """Deliver a PDF notification slip.
     202    """
     203    grok.context(ICustomStudent)
     204    grok.name('matric_number_slip.pdf')
     205    grok.require('waeup.viewStudent')
     206    prefix = 'form'
     207
     208    form_fields = grok.AutoFields(ICustomStudent).select(
     209        'student_id', 'matric_number')
     210    omit_fields = ('date_of_birth', 'current_level', 'flash_notice')
     211
     212    @property
     213    def title(self):
     214        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     215        return translate(_('Matriculation Number'), 'waeup.kofa',
     216            target_language=portal_language)
     217
     218    @property
     219    def label(self):
     220        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     221        return translate(_('Matriculation Number Slip\n'),
     222            target_language=portal_language) \
     223            + ' %s' % self.context.display_fullname
     224
     225    def render(self):
     226        if self.context.state not in (PAID,) or not self.context.is_fresh \
     227            or not self.context.matric_number:
     228            self.flash('Not allowed.', type="danger")
     229            self.redirect(self.url(self.context))
     230            return
     231        students_utils = getUtility(IStudentsUtils)
     232        return students_utils.renderPDFAdmissionLetter(self,
     233            self.context.student, omit_fields=self.omit_fields,
     234            pre_text=pre_text, post_text='')
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/utils.py

    r15255 r15288  
    4343                if ticket.p_state == 'paid' and \
    4444                    ticket.p_category == 'dep_sug' and \
     45                    ticket.p_session == session:
     46                    return True
     47        return False
     48
     49    def _lsfp_penalty_paymentMade(self, student, session):
     50        if student.current_mode not in ('hnd_ft', 'nd_ft'):
     51            return True
     52        if len(student['payments']):
     53            for ticket in student['payments'].values():
     54                if ticket.p_state == 'paid' and \
     55                    ticket.p_category == 'lsfp_penalty' and \
    4556                    ticket.p_session == session:
    4657                    return True
     
    143154                    return _('You have to pay NADESU/SA/SUG Dues first.'), None
    144155                if student.state == CLEARED:
     156                    penalty = getattr(academic_session, 'lsfp_penalty_fee')
     157                    if  penalty and not self._lsfp_penalty_paymentMade(
     158                        student, student.current_session):
     159                        return _('You have to pay late school fee payment penalty first.'), None
    145160                    if local(student):
    146161                        amount = getattr(certificate, 'school_fee_1', 0.0)
     
    258273    #: passport pictures is allowed.
    259274    PORTRAIT_CHANGE_STATES = (ADMITTED, RETURNING,)
     275
     276    def constructMatricNumber(self, student):
     277        #faccode = student.faccode
     278        depcode = student.depcode
     279        #certcode = student.certcode
     280        year = unicode(student.entry_session)[2:]
     281        if not student.state in (PAID, ) or not student.is_fresh:
     282            return _('Matriculation number cannot be set.'), None
     283
     284        # ACC/ND/17/00001
     285        if student.current_mode == 'nd_ft':
     286            next_integer = grok.getSite()['configuration'].next_matric_integer
     287            if next_integer == 0:
     288                return _('Matriculation number cannot be set.'), None
     289            return None, "%s/ND/%s/%05d" % (depcode, year, next_integer)
     290
     291        # ACC/HND/17/00001
     292        if student.current_mode == 'hnd_ft':
     293            next_integer = grok.getSite()['configuration'].next_matric_integer_2
     294            if next_integer == 0:
     295                return _('Matriculation number cannot be set.'), None
     296            return None, "%s/HND/%s/%05d" % (depcode, year, next_integer)
     297
     298        # PT students get the same prefixes but their counter should start
     299        # with 10001. This is inconsistent because after 9999 ft students
     300        # the ft and pt number ranges will overlap. Issoufou pointed this
     301        # out but the director said:
     302        # "when the counter gets to 9999 for ft, it can start counting
     303        # along where pt is, at that moment."
     304
     305        # ACC/ND/17/10001
     306        if student.current_mode in ('nd_pt, nd_we'):
     307            next_integer = grok.getSite()['configuration'].next_matric_integer_3
     308            if next_integer == 0:
     309                return _('Matriculation number cannot be set.'), None
     310            return None, "%s/ND/%s/%05d" % (depcode, year, next_integer)
     311        # ACC/HND/17/10001
     312        if student.current_mode in ('hnd_pt, hnd_we'):
     313            next_integer = grok.getSite()['configuration'].next_matric_integer_4
     314            if next_integer == 0:
     315                return _('Matriculation number cannot be set.'), None
     316            return None, "%s/HND/%s/%05d" % (depcode, year, next_integer)
     317
     318        return _('Matriculation number cannot be set.'), None
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/viewlets.py

    r14913 r15288  
    2121from waeup.kofa.interfaces import REQUESTED
    2222from waeup.kofa.browser.viewlets import ManageActionButton
    23 from waeup.kofa.students.interfaces import IStudentsUtils
    24 from kofacustom.dspg.students.interfaces import (
    25     ICustomStudentStudyCourse, ICustomStudentStudyLevel)
     23from waeup.kofa.students.interfaces import IStudentsUtils, IStudent
    2624from waeup.kofa.students.fileviewlets import (
    2725    StudentFileDisplay, StudentFileUpload, StudentImage)
    2826from waeup.kofa.students.browser import (
    2927    ExportPDFClearanceSlip, StudyCourseDisplayFormPage,
    30     StudyLevelDisplayFormPage)
     28    StudyLevelDisplayFormPage, StudentBaseDisplayFormPage)
     29from kofacustom.dspg.students.interfaces import (
     30    ICustomStudentStudyCourse, ICustomStudentStudyLevel)
    3131
    3232from 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)
    3369
    3470# ND Result
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/utils/utils.py

    r15263 r15288  
    124124        'pom':'POM Pack',
    125125        'hrm':'HRM Pack',
     126        'lsfp_penalty':'HND/ND FT Fresh Student Late School Fee Payment Penalty',
    126127        }
    127128
     
    188189        'pom':'POM Pack',
    189190        'hrm':'HRM Pack',
     191        'lsfp_penalty':'HND/ND FT Fresh Student Late School Fee Payment Penalty',
    190192        }
    191193
Note: See TracChangeset for help on using the changeset viewer.