Ignore:
Timestamp:
22 Dec 2023, 16:47:45 (11 months ago)
Author:
Henrik Bettermann
Message:

Ticket #1328 (second part)

Location:
main/waeup.uniben/trunk/src/waeup/uniben/applicants
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/interfaces.py

    r17597 r17659  
    2121
    2222#from grok import getSite
     23import re
    2324from zope import schema
    2425from zope.interface import invariant, Invalid
     
    5556from waeup.uniben.payments.interfaces import ICustomOnlinePayment
    5657
     58
     59# Define a validation method for JAMB reg numbers
     60class NotMatricRegNumber(schema.ValidationError):
     61    __doc__ = u"Invalid matriculation number"
     62
     63#: Regular expression to check matric_number formats.
     64check_matric_number = re.compile(r"^[^0-9\s][^\s]*$").match
     65
     66def validate_matric_number(value):
     67    if not check_matric_number(value):
     68        raise NotMatricRegNumber(value)
     69    return True
     70
    5771class TranscriptCertificateSource(CertificateSource):
    5872    """Include Department and Faculty in Title.
     
    316330        readonly = False,
    317331        required = True,
     332        constraint = validate_matric_number,
    318333        )
    319334
     
    434449    dispatch_address = schema.Text(
    435450        title = _(u'Recipient Body'),
    436         description = u'Addresses (including email address and phone number) '
    437                        'to which transcripts should be posted. '
     451        description = u'Addresses to which transcripts should be posted. '
    438452                       'All addresses must involve same courier charges.',
    439453        required = True,
    440454        readonly = False,
     455        )
     456
     457    dispatch_email = schema.ASCIILine(
     458        title = _(u'Recipient Email Address'),
     459        required = False,
     460        constraint=validate_email,
     461        )
     462
     463    dispatch_phone = PhoneNumber(
     464        title = _(u'Recipient Phone'),
     465        description = u'',
     466        required = False,
    441467        )
    442468
  • main/waeup.uniben/trunk/src/waeup/uniben/applicants/tests/test_browser.py

    r17593 r17659  
    336336        self.browser.getControl(name="form.no_copies").value = ['2']
    337337        self.browser.getControl(name="form.course_studied").value = ['CERT1']
    338         self.browser.getControl(name="form.matric_number").value = '234'
     338        self.browser.getControl(name="form.matric_number").value = 'a234'
    339339        self.browser.getControl(name="form.dispatch_address").value = 'Kuensche\nMarsch 5'
    340340        self.browser.getControl(name="form.entry_mode").value = ['ug_ft']
Note: See TracChangeset for help on using the changeset viewer.