Changeset 6705
- Timestamp:
- 9 Sep 2011, 22:58:35 (13 years ago)
- Location:
- main/waeup.sirp/branches/uli-studentpw/src/waeup/sirp/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/branches/uli-studentpw/src/waeup/sirp/students/browser.py
r6701 r6705 63 63 WAeUPObjectWidget, WAeUPObjectDisplayWidget) 64 64 from waeup.sirp.students.interfaces import ( 65 IStudentsContainer, IStudent, IStudentClearance, 65 IStudentsContainer, IStudent, IStudentClearance, IStudentPasswordSetting, 66 66 IStudentPersonal, IStudentBase, IStudentStudyCourse, 67 67 IStudentPayments, IStudentAccommodation, IStudentNavigation, … … 159 159 self.acseries = self.request.form.get('form.acseries', None) 160 160 self.acnumber = self.request.form.get('form.acnumber', None) 161 161 162 162 if SUBMIT is None: 163 163 return … … 286 286 grok.require('waeup.viewStudent') 287 287 grok.template('basepage') 288 form_fields = grok.AutoFields(IStudentBase) #.omit('password')288 form_fields = grok.AutoFields(IStudentBase).omit('password') 289 289 pnav = 4 290 290 title = 'Base Data' … … 533 533 target = 'bedit' 534 534 535 class StudentPasswordSetting(grok.Adapter): 536 """Adapt IStudent to data needed for password settings. 537 538 We provide password getters/setters for the attached context (an 539 IStudent object) that cooperate seamless with the usual 540 formlib/form techniques. 541 """ 542 grok.context(IStudent) 543 grok.provides(IStudentPasswordSetting) 544 545 def __init__(self, context): 546 self.name = context.name 547 self.password_repeat = context.password 548 self.context = context 549 return 550 551 def getPassword(self): 552 return self.context.password 553 554 def setPassword(self, password): 555 IUserAccount(self.context).setPassword(password) 556 return 557 558 password = property(getPassword, setPassword) 559 535 560 class StudentBaseEditFormPage(WAeUPEditFormPage): 536 561 """ View to edit student base data by student … … 539 564 grok.name('bedit') 540 565 grok.require('waeup.handleStudent') 541 form_fields = grok.AutoFields(IStudentBaseEdit).omit( 542 'student_id', 'reg_number') 566 form_fields = grok.AutoFields(IStudentPasswordSetting) 543 567 grok.template('baseeditpage') 544 568 label = 'Change password' … … 547 571 548 572 def update(self): 549 datepicker.need() # Enable jQuery datepicker in date fields.573 #datepicker.need() # Enable jQuery datepicker in date fields. 550 574 super(StudentBaseEditFormPage, self).update() 551 575 self.wf_info = IWorkflowInfo(self.context) … … 554 578 @grok.action('Save') 555 579 def save(self, **data): 580 print "PW1: ", self.context.password 556 581 form = self.request.form 557 582 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 return562 IUserAccount(self.context).setPassword(form['password'])563 self.context.loggerInfo(ob_class, 'password changed')564 583 changed_fields = self.applyData(self.context, **data) 565 584 changed_fields = changed_fields.values() 566 fields_string = '+'.join(' + '.join( str(i) for i in b) for b in changed_fields)567 self.context._p_changed = True585 fields_string = '+'.join(' + '.join( 586 str(i) for i in b) for b in changed_fields) 568 587 self.flash('Form has been saved.') 569 588 if fields_string: 570 589 self.context.loggerInfo(ob_class, 'saved: % s' % fields_string) 590 print "PW2: ", self.context.password 571 591 return 572 592 … … 585 605 grok.name('cedit') 586 606 grok.require('waeup.handleStudent') 587 form_fields = grok.AutoFields(IStudentClearanceEdit).omit('clearance_locked') 607 form_fields = grok.AutoFields( 608 IStudentClearanceEdit).omit('clearance_locked') 588 609 #grok.template('clearanceeditpage') 589 610 label = 'Edit clerance data' -
main/waeup.sirp/branches/uli-studentpw/src/waeup/sirp/students/browser_templates/baseeditpage.pt
r6701 r6705 38 38 </tr> 39 39 </tal:block> 40 <!-- 40 41 <tr> 41 <td class="label"><label> Password:</label></td>42 <td class="label"><label>New password:</label></td> 42 43 <td> 43 44 <input name="password" type="password"/> … … 45 46 </tr> 46 47 <tr> 47 <td class="label"><label>Retype password:</label></td>48 <td class="label"><label>Retype new password:</label></td> 48 49 <td> 49 50 <input name="control_password" type="password" /> 50 51 </td> 51 52 </tr> 53 --> 52 54 </tbody> 53 55 </table> -
main/waeup.sirp/branches/uli-studentpw/src/waeup/sirp/students/interfaces.py
r6699 r6705 56 56 """ 57 57 58 class IStudentPasswordSetting(IWAeUPObject): 59 """Data needed for password setting. 60 """ 61 name = schema.TextLine( 62 title = u'Full Name', 63 default = u'Nobody', 64 required = True, 65 ) 66 67 password = schema.Password( 68 title = u'New password', 69 required = False, 70 ) 71 72 password_repeat = schema.Password( 73 title = u'Retype new password', 74 required = False, 75 ) 76 58 77 class IStudentBase(IWAeUPObject): 59 78 """Representation of student base data. … … 61 80 history = Attribute('Object history, a list of messages.') 62 81 state = Attribute('Returns the registration state of a student') 63 #student_id = Attribute('Randomly generated id')64 82 password = Attribute('Encrypted password of a student') 83 84 password = schema.Password( 85 title = u'Password', 86 required = False, 87 ) 65 88 66 89 def loggerInfo(ob_class, comment):
Note: See TracChangeset for help on using the changeset viewer.