Ignore:
Timestamp:
11 Jun 2018, 07:29:33 (6 years ago)
Author:
Henrik Bettermann
Message:

Add validation expression for JAMB registration numbers.

Location:
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria
Files:
3 edited

Legend:

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

    r14828 r15045  
    3737from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
    3838from kofacustom.nigeria.interfaces import (
    39     LGASource, high_qual, high_grade, exam_types)
     39    LGASource, high_qual, high_grade, exam_types, validate_jamb_reg_number)
    4040from kofacustom.nigeria.interfaces import MessageFactory as _
    4141from kofacustom.nigeria.payments.interfaces import INigeriaOnlinePayment
     
    357357        title = _(u'JAMB Registration Number'),
    358358        required = False,
     359        constraint=validate_jamb_reg_number,
    359360        )
    360361    notice = schema.Text(
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interfaces.py

    r14866 r15045  
    1717##
    1818
     19import re
    1920import zope.i18nmessageid
    2021from zope import schema
     
    7677    )
    7778
     79# Define a validation method for JAMB reg numbers
     80class NotJAMBRegNumber(schema.ValidationError):
     81    __doc__ = u"Invalid JAMB registration number"
     82
     83#: Regular expression to check jamb_reg_number formats.
     84check_jamb_reg_number = re.compile(r"^[A-Z]{2}\d{8}$").match
     85
     86def validate_jamb_reg_number(value):
     87    if not check_jamb_reg_number(value):
     88        raise NotJAMBRegNumber(value)
     89    return True
     90
    7891#lgas_vocab = SimpleKofaVocabulary(
    7992#    *sorted([(x[1],x[0]) for x in LGAS]))
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_export.py

    r14741 r15045  
    2929from kofacustom.nigeria.testing import FunctionalLayer
    3030
     31curr_year = datetime.datetime.now().year
    3132
    3233class NigeriaStudentExporterTest(StudentImportExportSetup):
     
    115116        # set values we can expect in export file
    116117        self.setup_student(self.student)
    117         self.student['payments']['my-payment'].r_company = 'interswatch'
     118        self.student['payments']['my-payment'].r_company = 'interswitch'
    118119        self.student['payments']['my-payment'].r_card_num = '789'
    119120        exporter = NigeriaStudentPaymentExporter()
     
    127128            'current_session\r\n'
    128129            '666,12.12,2012-04-01 13:12:01#,,schoolfee,1,my-id,p-item,'
    129             '100,2011,paid,2012-04-01 14:12:01#,,12.12,'
    130             '789,r-code,interswatch,,,,A111111,created,2012\r\n',
     130            '100,%s,paid,2012-04-01 14:12:01#,,12.12,'
     131            '789,r-code,interswitch,,,,A111111,created,2012\r\n' % (curr_year-6),
    131132            result
    132133            )
Note: See TracChangeset for help on using the changeset viewer.