Changeset 710 for WAeUP_SRP/trunk


Ignore:
Timestamp:
16 Oct 2006, 22:30:16 (18 years ago)
Author:
joachim
Message:

fixed several bugs in the Apply for PUME Process:
jamb_reg_no had wrong widget
applying with a different PIN a second time led to an error.

the new fields:
appl_email, appl_mobile are set to hidden in laymode create
could not set the fields to required, cause that broke the applyForm.
layout: student_application.xml still has them set to required.

Location:
WAeUP_SRP/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Students.py

    r708 r710  
    2828    if letter not in ('ABCDEFGIHKLMNOPQRSTUVWXY'):
    2929        letter= r.choice('ABCDEFGHKLMNPQRSTUVWXY')
    30     return "%c%d" % (letter,r.randint(99999,1000000))
     30    students = context.portal_catalog(meta_type = "StudentsFolder")[-1]
     31    sid = "%c%d" % (letter,r.randint(99999,1000000))
     32    while hasattr(students, sid):
     33        sid = "%c%d" % (letter,r.randint(99999,1000000))
     34    return sid
    3135    #return "%c%d" % (r.choice('ABCDEFGHKLMNPQRSTUVWXY'),r.randint(99999,1000000))
    3236
  • WAeUP_SRP/trunk/WAeUPTables.py

    r686 r710  
    104104
    105105
    106     def searchAndSetRecord(self, uid, student_id):
     106    def searchAndSetRecord(self, uid, student_id,prefix):
    107107        #records = self.searchResults(uid=uid)
     108        records = self.searchResults(student = student_id)
     109        if len(records) > 0:
     110            for r in records:
     111                if r.pin != uid and r.prefix_batch.startswith(prefix):
     112                    return -2
    108113        records = self.searchResults({"%s" % self.key : uid})
    109114        if len(records) > 1:
  • WAeUP_SRP/trunk/Widgets.py

    r667 r710  
    214214###)
    215215
    216 class StudentIdWidget(CPSStringWidget): ###(
    217     """ StudentId Widget"""
    218     meta_type = "StudentId Widget"
    219     digits = 8
    220     digits_str = "N"*digits
    221     letters = 2
    222     letters_str = "L"*letters
    223 
    224     def validate(self, datastructure, **kw):
    225         """Validate datastructure and update datamodel."""
    226 
    227         valid = CPSStringWidget.validate(self, datastructure, **kw)
    228         if not valid:
    229             return 0
    230         else:
    231             widget_id = self.getWidgetId()
    232             value = datastructure[widget_id]
    233             err = 0
    234             if not (len(value) == self.digits + self.letters and value[:self.digits].isdigit() and value[self.digits:].isalpha()):
    235                 err = 'Invalid Registration Number in the format: %s%s with N = Number, L = Letter' % (self.digits_str,self.letters_str)
    236             if err:
    237                 datastructure.setError(widget_id, err)
    238             else:
    239                 datamodel = datastructure.getDataModel()
    240                 datamodel[self.fields[0]] = value
    241 
    242             return not err
    243 
    244 InitializeClass(StudentIdWidget)
    245 widgetRegistry.register(StudentIdWidget)
    246 
    247 ###)
     216##class StudentIdWidget(CPSStringWidget): ###(
     217##    """ StudentId Widget"""
     218##    meta_type = "StudentId Widget"
     219##    digits = 8
     220##    digits_str = "N"*digits
     221##    letters = 2
     222##    letters_str = "L"*letters
     223##
     224##    def validate(self, datastructure, **kw):
     225##        """Validate datastructure and update datamodel."""
     226##
     227##        valid = CPSStringWidget.validate(self, datastructure, **kw)
     228##        if not valid:
     229##            return 0
     230##        else:
     231##            widget_id = self.getWidgetId()
     232##            value = datastructure[widget_id]
     233##            err = 0
     234##            if not (len(value) == self.digits + self.letters and value[:self.digits].isdigit() and value[self.digits:].isalpha()):
     235##                err = 'Invalid Registration Number in the format: %s%s with N = Number, L = Letter' % (self.digits_str,self.letters_str)
     236##            if err:
     237##                datastructure.setError(widget_id, err)
     238##            else:
     239##                datamodel = datastructure.getDataModel()
     240##                datamodel[self.fields[0]] = value
     241##
     242##            return not err
     243##
     244##InitializeClass(StudentIdWidget)
     245##widgetRegistry.register(StudentIdWidget)
     246##
     247#####)
    248248
    249249class JambRegNoWidget(CPSStringWidget): ###(
     
    270270                s = getStudentByRegNo(self,value)
    271271                if s is None:
    272                     err = 'No JAMB data for %s' % (value)
     272                    err = 'No Student with JAMB-Reg-No %s' % (value)
    273273            if err:
    274274                datastructure.setError(widget_id, err)
     
    342342            ref = datastructure[self.reference]
    343343        #import pdb;pdb.set_trace()
    344         ok = pins.searchAndSetRecord(pin,ref)
     344        ok = pins.searchAndSetRecord(pin,ref,self.prefix)
    345345        while 1:
    346             if ok == -1:
     346            if ok == -2:
     347                err = 'You have already applied with a different Pin, please login'
     348                break
     349            elif ok == -1:
    347350                err = 'invalid Pin'
    348351                break
     
    351354                break
    352355            if ok >= 1:
     356                #import pdb;pdb.set_trace()
    353357                if self.isStudent():
    354358                    student = self.getStudentInfo()['student']
  • WAeUP_SRP/trunk/profiles/default/layouts/student_application.xml

    r707 r710  
    5050 </widget>
    5151 <widget name="appl_email" meta_type="Email Widget">
     52  <property name="is_required">True</property>
    5253  <property name="title">Email Address</property>
    5354  <property name="fields">
     
    158159  <property name="hidden_readonly_layout_modes"/>
    159160 </widget>
    160  <widget name="jamb_reg_no" meta_type="StudentId Widget">
     161 <widget name="jamb_reg_no" meta_type="JambRegNo Widget">
    161162  <property name="title">JAMB Registration Number</property>
    162163  <property name="fields">
  • WAeUP_SRP/trunk/profiles/default/layouts/student_application_fe.xml

    r707 r710  
    6161  <property name="label">Email Address</property>
    6262  <property name="label_edit">Email Address</property>
    63   <property name="readonly_layout_modes">
    64   </property>
    65   <property name="hidden_layout_modes">
    66   </property>
     63  <property name="is_required">False</property>
     64  <property name="readonly_layout_modes">
     65  </property>
     66  <property name="hidden_layout_modes">create</property>
    6767  <property name="hidden_readonly_layout_modes"/>
    6868 </widget>
     
    7373  </property>
    7474  <property name="label">Mobile Phone No</property>
     75  <property name="is_required">False</property>
    7576  <property name="label_edit">Mobile Phone No</property>
    7677  <property name="readonly_layout_modes">
    7778  </property>
    78   <property name="hidden_layout_modes">
    79   </property>
     79  <property name="hidden_layout_modes">create</property>
    8080  <property name="hidden_readonly_layout_modes"/>
    8181 </widget>
     
    142142  <property name="hidden_readonly_layout_modes"/>
    143143 </widget>
    144  <widget name="jamb_reg_no" meta_type="StudentId Widget">
     144 <widget name="jamb_reg_no" meta_type="JambRegNo Widget">
    145145  <property name="title">JAMB Registration Number</property>
    146146  <property name="fields">
  • WAeUP_SRP/trunk/skins/waeup_pins/getBatchInfo.py

    r709 r710  
    3232        jno = item['student']
    3333        res = context.portal_catalog(SearchableText=jno,portal_type='StudentApplication')
    34         if len(res) > 1:
     34        if len(res) > 0:
    3535            item['student_url'] = "%s/%s" % (context.portal_url(),res[0].relative_path)
    3636        else:
  • WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt

    r672 r710  
    2727              err python:ds.getError(wid);
    2828              err_mapping python:ds.getErrorMapping(wid);
    29               is_required python: widget.is_required and creation and ('create' not in widget.readonly_layout_modes);
     29              is_required python: widget.is_required;
    3030              tooltip_id python:wid + '_help';
    3131              widget_css_class cell/widget_css_class|nothing;
  • WAeUP_SRP/trunk/skins/waeup_student/passport_entry_view.pt

    r672 r710  
    1 <metal:html tal:define="info context/getStudentInfo">
     1<metal:html tal:define="info context/getStudentInfo;
     2            rendered_main python:info['app_doc'].renderEdit(
     3                                                        layout_mode='edit',
     4                                                        proxy=info['app'],
     5                                                        no_form = True,
     6                                                        schema_id = 'student_application',
     7                                                        layout_id='student_application_fe',
     8            )">
    29  <metal:body use-macro="here/main_template/macros/master">
    310    <metal:main fill-slot="main">
     
    1219        <h3>Upload your Passport Picture!</h3>
    1320        <br />
    14         <span tal:omit-tag=""
    15               tal:content="structure python: info['app_doc'].render(proxy=info['app_doc'],
    16               layout_mode='edit',
    17               layout_id='student_application_fe',
    18               )"
    19               />
     21        <span tal:omit-tag="" tal:replace="structure rendered_main"/>
    2022      </span>
    2123    </metal:main>
  • WAeUP_SRP/trunk/skins/waeup_student/student_edit.py

    r659 r710  
    4848                                    use_session=True)
    4949        action = "/passport_entry_view"
    50         if app_doc.passport is not None:
    51             psm = 'You successfully uploaded your passport image.'
    52             args = {'apply_button': 'Apply',}
     50        if is_valid:
     51            if app_doc.passport is not None:
     52                psm = 'You successfully uploaded your passport image.'
     53                args = {'apply_button': 'Apply',}
     54            else:
     55                psm = "You didn't upload a passport image."
     56                args = {}
    5357        else:
    54             psm = "You didn't upload a passport image."
    55             args = {}
     58            psm = 'psm_content_error'
     59            args = getFormUidUrlArg(REQUEST)
    5660    elif 'apply_admission' not in REQUEST.form:
    5761        is_valid, ds = app_doc.validate(request=REQUEST,
Note: See TracChangeset for help on using the changeset viewer.