Changeset 6779


Ignore:
Timestamp:
15 Sep 2011, 12:05:59 (13 years ago)
Author:
Henrik Bettermann
Message:

Check if reg_number or matric_number exist when editing student base data.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r6776 r6779  
    349349            IUserAccount(self.context).setPassword(form['password'])
    350350            self.context.loggerInfo(ob_class, 'password changed')
     351        self.reg_number = form.get('form.reg_number', None)
     352        if self.reg_number:
     353            hitlist = search(query=self.reg_number,searchtype='reg_number', view=self)
     354           
     355            if hitlist and hitlist[0].student_id != self.context.student_id:
     356                self.flash('Registration number exists.')
     357                return
     358        self.matric_number = form.get('form.matric_number', None)
     359        if self.matric_number:
     360            hitlist = search(query=self.matric_number,
     361                searchtype='matric_number', view=self)
     362            if hitlist and hitlist[0].student_id != self.context.student_id:
     363                self.flash('Matriculation number exists.')
     364                return
    351365        # Turn list of lists into single list
    352366        changed_fields = self.applyData(self.context, **data)
    353367        if changed_fields:
    354368            changed_fields = reduce(lambda x,y: x+y, changed_fields.values())
    355             changed_fields = [x for x in changed_fields
    356                               if not x.startswith('password')]
    357369        fields_string = ' + '.join(changed_fields)
    358370        self.context._p_changed = True
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r6775 r6779  
    173173        self.assertTrue('Student record created' in self.browser.contents)
    174174
    175         # Registration numbers must be unique
    176         #self.browser.getLink("Manage").click()
    177         #self.browser.getControl(name="form.reg_number").value = '123'
    178         #self.browser.getControl("Save").click()
    179         #self.assertMatches('...value already exists in catalog...',
    180         #                   self.browser.contents)
     175        # Registration and matric numbers must be unique
     176        self.browser.getLink("Manage").click()
     177        self.browser.getControl(name="form.reg_number").value = '123'
     178        self.browser.getControl("Save").click()
     179        self.assertMatches('...Registration number exists...',
     180                           self.browser.contents)
     181        self.browser.getControl(name="form.reg_number").value = '789'
     182        self.browser.getControl(name="form.matric_number").value = '234'
     183        self.browser.getControl("Save").click()
     184        self.assertMatches('...Matriculation number exists...',
     185                           self.browser.contents)
    181186
    182187        self.browser.open(self.container_path)
     
    233238        self.browser.getControl(name="transition").value = ['admit']
    234239        self.browser.getControl(name="form.name").value = 'John Tester'
    235         self.browser.getControl(name="form.reg_number").value = '123'
     240        self.browser.getControl(name="form.reg_number").value = '345'
    236241        self.browser.getControl(name="password").value = 'secret'
    237242        self.browser.getControl(name="control_password").value = 'secret'
Note: See TracChangeset for help on using the changeset viewer.