Changeset 15802


Ignore:
Timestamp:
12 Nov 2019, 22:16:57 (5 years ago)
Author:
Henrik Bettermann
Message:

Implement automatic matric number assignment.

Location:
main/kofacustom.iuokada/trunk/src/kofacustom/iuokada
Files:
4 edited

Legend:

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

    r15661 r15802  
    1919from waeup.kofa.browser.pages import (
    2020    SessionConfigurationAddFormPage, SessionConfigurationManageFormPage,
    21     LoginPage, CertificatePage, CertificateManageFormPage)
     21    LoginPage, CertificatePage, CertificateManageFormPage,
     22    ConfigurationContainerManageFormPage)
    2223from waeup.kofa.university.interfaces import ICertificate
     24from waeup.kofa.interfaces import IConfigurationContainer
    2325from kofacustom.iuokada.interfaces import (
    2426    ICustomSessionConfiguration, ICustomSessionConfigurationAdd)
     
    2830    """
    2931    form_fields = grok.AutoFields(ICustomSessionConfigurationAdd)
     32
     33class CustomConfigurationContainerManageFormPage(
     34    ConfigurationContainerManageFormPage):
     35
     36    form_fields = grok.AutoFields(IConfigurationContainer).omit(
     37        'frontpage_dict',
     38        'next_matric_integer_2',
     39        'next_matric_integer_3',
     40        'next_matric_integer_4',
     41        )
     42    form_fields['maintmode_enabled_by'].for_display = True
    3043
    3144class CustomSessionConfigurationManageFormPage(SessionConfigurationManageFormPage):
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/browser.py

    r15722 r15802  
    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    action, jsaction, UtilityView, KofaEditFormPage)
    2727from waeup.kofa.students.browser import (
    2828    StudyLevelEditFormPage, StudyLevelDisplayFormPage,
     
    3030    CourseTicketDisplayFormPage, StudentTriggerTransitionFormPage,
    3131    msave, emit_lock_message)
    32 from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket
     32from waeup.kofa.students.interfaces import (
     33    IStudentsUtils, ICourseTicket, IStudent)
    3334from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
    3435from kofacustom.nigeria.students.browser import (
     
    101102    with_ac = False
    102103    with_bedselection = True
     104
     105class StudentGetMatricNumberPage(UtilityView, grok.View):
     106    """ Construct and set the matriculation number.
     107    """
     108    grok.context(IStudent)
     109    grok.name('get_matric_number')
     110    grok.require('waeup.viewStudent')
     111
     112    def update(self):
     113        students_utils = getUtility(IStudentsUtils)
     114        msg, mnumber = students_utils.setMatricNumber(self.context)
     115        if msg:
     116            self.flash(msg, type="danger")
     117        else:
     118            self.flash(_('Matriculation number %s assigned.' % mnumber))
     119            self.context.writeLogMessage(self, '%s assigned' % mnumber)
     120        self.redirect(self.url(self.context))
     121        return
     122
     123    def render(self):
     124        return
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/utils.py

    r15780 r15802  
    1616## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1717##
     18import grok
    1819from time import time
    1920from zope.component import createObject, getUtility
     
    185186        payment.p_combi = combi
    186187        return None, payment
     188
     189    def constructMatricNumber(self, student):
     190        """Fetch the matric number counter which fits the student and
     191        construct the new matric number of the student.
     192        """
     193        next_integer = grok.getSite()['configuration'].next_matric_integer
     194        if next_integer == 0:
     195            return _('Matriculation number cannot be set.'), None
     196        year = unicode(student.entry_session)[2:]
     197        return None, "%s/%06d" % (year, next_integer)
  • main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/students/viewlets.py

    r15654 r15802  
    1818
    1919import grok
     20from zope.component import getUtility
    2021from waeup.kofa.interfaces import REQUESTED
    2122from waeup.kofa.browser.viewlets import ManageActionButton
     23from waeup.kofa.students.interfaces import IStudent, IStudentsUtils
    2224from kofacustom.iuokada.students.interfaces import (
    2325    ICustomStudentStudyCourse, ICustomStudentStudyLevel)
     
    2628from waeup.kofa.students.browser import (
    2729    ExportPDFClearanceSlip, StudyCourseDisplayFormPage,
    28     StudyLevelDisplayFormPage)
     30    StudyLevelDisplayFormPage, StudentBaseDisplayFormPage)
    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    icon = 'actionicon_count.png'
     40    text = _('Get Matriculation Number')
     41
     42    @property
     43    def target_url(self):
     44        students_utils = getUtility(IStudentsUtils)
     45        if self.context.matric_number:
     46            return ''
     47        error, matric_number = students_utils.constructMatricNumber(
     48            self.context)
     49        if error:
     50            return ''
     51        return self.view.url(self.view.context, 'get_matric_number')
    3152
    3253# Signature
Note: See TracChangeset for help on using the changeset viewer.