Changeset 6701 for main/waeup.sirp


Ignore:
Timestamp:
9 Sep 2011, 16:29:19 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement password control field.

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

Legend:

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

    r6699 r6701  
    339339    @grok.action('Save')
    340340    def save(self, **data):
     341        form = self.request.form
     342        ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
     343        if form.has_key('password') and form['password']:
     344            if form['password'] != form['control_password']:
     345                self.flash('Passwords do not match.')
     346                return
     347            IUserAccount(self.context).setPassword(form['password'])
     348            self.context.loggerInfo(ob_class, 'password changed')
    341349        changed_fields = self.applyData(self.context, **data)
    342350        changed_fields = changed_fields.values()
    343351        fields_string = '+'.join(' + '.join(str(i) for i in b) for b in changed_fields)
    344352        self.context._p_changed = True
    345         form = self.request.form
    346353        if form.has_key('transition') and form['transition']:
    347354            transition_id = form['transition']
    348355            self.wf_info.fireTransition(transition_id)
    349         if form.has_key('password') and form['password']:
    350             IUserAccount(self.context).setPassword(form['password'])
    351             if fields_string:
    352                 fields_string += ' + password'
    353             else:
    354                 fields_string = 'password'
    355356        self.flash('Form has been saved.')
    356         ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
    357357        if fields_string:
    358358            self.context.loggerInfo(ob_class, 'saved: % s' % fields_string)
     
    554554    @grok.action('Save')
    555555    def save(self, **data):
     556        form = self.request.form
     557        ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
     558        if form.has_key('password') and form['password']:
     559            if form['password'] != form['control_password']:
     560                self.flash('Passwords do not match.')
     561                return
     562            IUserAccount(self.context).setPassword(form['password'])
     563            self.context.loggerInfo(ob_class, 'password changed')
    556564        changed_fields = self.applyData(self.context, **data)
    557565        changed_fields = changed_fields.values()
    558566        fields_string = '+'.join(' + '.join(str(i) for i in b) for b in changed_fields)
    559567        self.context._p_changed = True
    560         form = self.request.form
    561         if form.has_key('password') and form['password']:
    562             IUserAccount(self.context).setPassword(form['password'])
    563             if fields_string:
    564                 fields_string += ' + password'
    565             else:
    566                 fields_string = 'password'
    567568        self.flash('Form has been saved.')
    568         ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
    569569        if fields_string:
    570570            self.context.loggerInfo(ob_class, 'saved: % s' % fields_string)
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/baseeditpage.pt

    r6700 r6701  
    4444        </td>
    4545      </tr>
     46      <tr>
     47        <td class="label"><label>Retype password:</label></td>
     48        <td>
     49          <input name="control_password" type="password" />
     50        </td>
     51      </tr>
    4652    </tbody>
    4753  </table>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/basemanagepage.pt

    r6700 r6701  
    4545      </tr>
    4646      <tr>
     47        <td class="label"><label>Retype password:</label></td>
     48        <td>
     49          <input name="control_password" type="password" />
     50        </td>
     51      </tr>
     52      <tr>
    4753        <td class="label"><label>Registration Transition:</label></td>
    4854        <td>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r6699 r6701  
    207207        self.browser.getControl(name="form.reg_number").value = '123'
    208208        self.browser.getControl(name="password").value = 'secret'
     209        self.browser.getControl(name="control_password").value = 'secret'
    209210        self.browser.getControl("Save").click()
    210211        self.assertMatches('...Form has been saved...',
    211212                           self.browser.contents)
    212         #self.assertTrue('Form has been saved' in self.browser.contents)
    213 
    214213        self.browser.open(self.student_path)
    215214        self.browser.getLink("Clearance Data").click()
     
    266265        self.browser.getLink("Change password").click()
    267266        self.browser.getControl(name="password").value = 'new_password'
     267        self.browser.getControl(name="control_password").value = 'new_password'
    268268        self.browser.getControl("Save").click()
    269269        self.assertTrue('Form has been saved' in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.