Changeset 18366


Ignore:
Timestamp:
24 Nov 2026, 11:38:03 (less than one hour ago)
Author:
Henrik Bettermann
Message:

Implement matric number generation.

Location:
main/kofacustom.unidel/trunk/src/kofacustom/unidel
Files:
5 edited

Legend:

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

    r18305 r18366  
    2020    SessionConfigurationAddFormPage, SessionConfigurationManageFormPage,
    2121    LoginPage, CertificatePage, CertificateManageFormPage,
    22     DatacenterImportStep2)
     22    DatacenterImportStep2, ConfigurationContainerManageFormPage)
     23from waeup.kofa.interfaces import IConfigurationContainer
    2324from waeup.kofa.university.interfaces import ICertificate
    2425from kofacustom.unidel.interfaces import (
    2526    ICustomSessionConfiguration, ICustomSessionConfigurationAdd)
     27
     28class CustomConfigurationContainerManageFormPage(
     29    ConfigurationContainerManageFormPage):
     30
     31    form_fields = grok.AutoFields(IConfigurationContainer).omit(
     32        'next_matric_integer_2',
     33        'next_matric_integer_3',
     34        'next_matric_integer_4',
     35        )
     36    form_fields['maintmode_enabled_by'].for_display = True
    2637
    2738class CustomSessionConfigurationAddFormPage(SessionConfigurationAddFormPage):
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/browser.py

    r18358 r18366  
    949949        super(CustomAddStudyLevelFormPage, self).update()
    950950        return
     951
     952class StudentGetMatricNumberPage(UtilityView, grok.View):
     953    """ Construct and set the matriculation number.
     954    """
     955    grok.context(ICustomStudent)
     956    grok.name('get_matric_number')
     957    grok.require('waeup.viewStudent')
     958
     959    def update(self):
     960        students_utils = getUtility(IStudentsUtils)
     961        msg, mnumber = students_utils.setMatricNumber(self.context)
     962        if msg:
     963            self.flash(msg, type="danger")
     964        else:
     965            self.flash(_('Matriculation number %s assigned.' % mnumber))
     966            self.context.writeLogMessage(self, '%s assigned' % mnumber)
     967        self.redirect(self.url(self.context))
     968        return
     969
     970    def render(self):
     971        return
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/tests/test_utils.py

    r18237 r18366  
    22import grok
    33from waeup.kofa.testing import FunctionalTestCase
     4from zope.component import getUtility
    45from hurry.workflow.interfaces import IWorkflowState
    56from zope.component import getUtility, createObject
    … …  
    3637        self.assertEqual(warning, None)
    3738        return
     39
     40    def test_setMatricNumber(self):
     41        site = grok.getSite()
     42        utils = getUtility(IStudentsUtils)
     43        site['configuration'].next_matric_integer = 12345
     44        self.student.matric_number = None
     45        msg, mnumber = utils.setMatricNumber(self.student)
     46        self.assertEqual(msg, 'Matriculation number cannot be set.')
     47        IWorkflowState(self.student).setState('school fee paid')
     48        msg, mnumber = utils.setMatricNumber(self.student)
     49        self.assertEqual(self.student.matric_number, 'fac10412345')
     50        return
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/utils.py

    r18341 r18366  
    523523    #        return 5, self.GPABoundaries()[5][1]
    524524    #    return
     525
     526    def constructMatricNumber(self, student):
     527        faccode = student.faccode
     528        #depcode = student.depcode
     529        #certcode = student.certcode
     530        if not student.state in (PAID, ) or not student.is_fresh:
     531            return _('Matriculation number cannot be set.'), None
     532        year = unicode(student.entry_session)[2:]
     533        next_integer = grok.getSite()['configuration'].next_matric_integer
     534        if next_integer == 0:
     535            return _('Matriculation number cannot be set.'), None
     536        return None, "%s%s%05d" % (faccode, year, next_integer)
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/viewlets.py

    r18328 r18366  
    1818
    1919import grok
     20from zope.component import getUtility
    2021from waeup.kofa.interfaces import REQUESTED
    2122from waeup.kofa.browser.viewlets import ManageActionButton
    2223from kofacustom.unidel.students.interfaces import (ICustomStudent,
    2324    ICustomStudentStudyCourse, ICustomStudentStudyLevel)
     25from waeup.kofa.students.interfaces import IStudentsUtils
    2426from waeup.kofa.students.fileviewlets import (
    2527    StudentFileDisplay, StudentFileUpload, StudentImage)
    … …  
    3133
    3234from kofacustom.nigeria.interfaces import MessageFactory as _
     35
     36
     37class GetMatricNumberActionButton(ManageActionButton):
     38    grok.order(11)
     39    grok.context(ICustomStudent)
     40    grok.view(StudentBaseDisplayFormPage)
     41    grok.require('waeup.viewStudent')
     42    #grok.require('waeup.manageStudent')
     43    icon = 'actionicon_count.png'
     44    text = _('Get Matriculation Number')
     45
     46    @property
     47    def target_url(self):
     48        students_utils = getUtility(IStudentsUtils)
     49        if self.context.matric_number:
     50            return ''
     51        error, matric_number = students_utils.constructMatricNumber(
     52            self.context)
     53        if error:
     54            return ''
     55        return self.view.url(self.view.context, 'get_matric_number')
    3356
    3457class ExamClearanceSlipActionButton(ManageActionButton):
Note: See TracChangeset for help on using the changeset viewer.