Changeset 463


Ignore:
Timestamp:
1 Sep 2006, 10:33:30 (18 years ago)
Author:
joachim
Message:

added missing layout student_check_pin
added validation for JAMB reg_no

Location:
WAeUP_SRP/trunk
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Widgets.py

    r444 r463  
    207207
    208208InitializeClass(StudentIdWidget)
    209 
    210209widgetRegistry.register(StudentIdWidget)
    211210
    212 ##Class StudentIdWidgetType(CPSWidgetType):
    213 ##    """Student Id String widget type."""
    214 ##    meta_type = "StudentId  Widget Type"
    215 ##    cls = StudentIdWidget
    216 
     211###)
     212
     213class JambRegNoWidget(CPSStringWidget): ###(
     214    """ JambRegNo Widget"""
     215    meta_type = "JambRegNo Widget"
     216    digits = 8
     217    digits_str = "N"*digits
     218    letters = 2
     219    letters_str = "L"*letters
     220
     221    def validate(self, datastructure, **kw):
     222        """Validate datastructure and update datamodel."""
     223
     224        valid = CPSStringWidget.validate(self, datastructure, **kw)
     225        if not valid:
     226            return 0
     227        else:
     228            widget_id = self.getWidgetId()
     229            value = datastructure[widget_id]
     230            err = 0
     231            if not (len(value) == self.digits + self.letters and value[:self.digits].isdigit() and value[self.digits:].isalpha()):
     232                err = 'Invalid Registration Number in the format: %s%s with N = Number, L = Letter' % (self.digits_str,self.letters_str)
     233            else:
     234                search = self.portal_catalog({'meta_type': 'StudentAdmission',
     235                                              'jamb_reg_no': value,
     236                                              })
     237                if len(search) < 1:
     238                    err = 'No JAMB data for %s' % (value)
     239            if err:
     240                datastructure.setError(widget_id, err)
     241            else:
     242                datamodel = datastructure.getDataModel()
     243                datamodel[self.fields[0]] = value
     244
     245            return not err
     246
     247InitializeClass(JambRegNoWidget)
     248
     249widgetRegistry.register(JambRegNoWidget)
    217250###)
    218251
  • WAeUP_SRP/trunk/profiles/default/layouts.xml

    r458 r463  
    1111 <object name="faculty" meta_type="CPS Layout"/>
    1212 <object name="student" meta_type="CPS Layout"/>
     13 <object name="student_check_pin" meta_type="CPS Layout"/>
    1314 <object name="student_study_course" meta_type="CPS Layout"/>
    1415 <object name="student_admission" meta_type="CPS Layout"/>
  • WAeUP_SRP/trunk/skins/waeup_student/request_admission.py

    r461 r463  
    4747    if len(search) < 1:
    4848        psm = "No JAMB record %s" % (jamb_id)
    49         return context.check_admission_form(rendered = res,
     49        return context.request_admission_form(rendered = res,
    5050                                 psm = psm,
    5151                                 ds = ds,
     
    5555return student.acknowledge_slip()
    5656
    57 jamb = getattr(student,'admission')
    58 res = jamb.getContent().render(layout_id = 'admission_slip',
    59                                layout_mode = 'view',
    60                                schema_id = 'jamb')
    6157
    62 return context.admission_slip_form(rendered = res, dict = ds)
    63 
Note: See TracChangeset for help on using the changeset viewer.