Changeset 6694 for main/waeup.sirp/trunk/src/waeup/sirp/students
- Timestamp:
- 8 Sep 2011, 16:35:05 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r6682 r6694 65 65 IStudentsContainer, IStudent, IStudentClearance, 66 66 IStudentPersonal, IStudentBase, IStudentStudyCourse, 67 IStudentPayments, IStudentAccommodation, IStudentNavigation 67 IStudentPayments, IStudentAccommodation, IStudentNavigation, 68 IStudentBaseEdit, 68 69 ) 69 70 from waeup.sirp.students.student import Student … … 233 234 grok.require('waeup.viewStudent') 234 235 grok.template('studentpage') 235 form_fields = grok.AutoFields(IStudentBase) 236 form_fields = grok.AutoFields(IStudentBase).omit('password') 236 237 pnav = 4 237 238 title = 'Base Data' … … 447 448 def label(self): 448 449 return '%s: History' % self.context.name 450 451 # Pages for students only 452 453 class StudentBaseEditActionButton(ManageActionButton): 454 grok.order(1) 455 grok.context(IStudent) 456 grok.view(StudentBaseDisplayFormPage) 457 grok.require('waeup.handleStudent') 458 text = 'Change password' 459 target = 'bedit' 460 461 class StudentBaseEditFormPage(WAeUPEditFormPage): 462 """ View to edit student base data by student 463 """ 464 grok.context(IStudent) 465 grok.name('bedit') 466 grok.require('waeup.handleStudent') 467 form_fields = grok.AutoFields(IStudentBaseEdit).omit('student_id') 468 grok.template('studentbaseeditpage') 469 label = 'Change password' 470 title = 'Base Data' 471 pnav = 4 472 473 def update(self): 474 datepicker.need() # Enable jQuery datepicker in date fields. 475 super(StudentBaseEditFormPage, self).update() 476 self.wf_info = IWorkflowInfo(self.context) 477 return 478 479 @grok.action('Save') 480 def save(self, **data): 481 changed_fields = self.applyData(self.context, **data) 482 changed_fields = changed_fields.values() 483 fields_string = '+'.join(' + '.join(str(i) for i in b) for b in changed_fields) 484 self.context._p_changed = True 485 self.flash('Form has been saved.') 486 form = self.request.form 487 ob_class = self.__implemented__.__name__.replace('waeup.sirp.','') 488 if fields_string: 489 self.context.loggerInfo(ob_class, 'saved: % s' % fields_string) 490 if 'password' in fields_string: 491 IUserAccount(self.context).setPassword(form['form.password']) 492 return -
main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py
r6692 r6694 61 61 history = Attribute('Object history, a list of messages.') 62 62 state = Attribute('Returns the registration state of a student') 63 student_id = Attribute('Randomly generated id')63 #student_id = Attribute('Randomly generated id') 64 64 65 65 def loggerInfo(ob_class, comment): … … 78 78 ) 79 79 80 password = schema. TextLine(80 password = schema.Password( 81 81 title = u'Password', 82 82 ) … … 126 126 """ 127 127 128 # Interfaces for students only 129 130 class IStudentBaseEdit(IStudentBase): 131 """Interface needed for editing of student base data by students. 132 """ 133 134 name = schema.TextLine( 135 title = u'Full Name', 136 default = u'Nobody', 137 required = True, 138 readonly = True, 139 ) 140 141 IStudentBaseEdit['name'].order = IStudentBase['name'].order 142 143 class IStudentClearanceEdit(IStudentClearance): 144 """Interface needed for restricted editing of student clearance data. 145 """ 146 147 class IStudentPersonalEdit(IStudentPersonal): 148 """Interface needed for restricted editing of student personal data. 149 """ -
main/waeup.sirp/trunk/src/waeup/sirp/students/student.py
r6666 r6694 23 23 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 24 24 from waeup.sirp.interfaces import IObjectHistory 25 from waeup.sirp.students.interfaces import IStudent, IStudentNavigation 25 from waeup.sirp.students.interfaces import ( 26 IStudent, IStudentNavigation, IStudentBaseEdit, 27 ) 26 28 from waeup.sirp.utils.helpers import attrs_to_fields 27 29 from waeup.sirp.students.utils import generate_student_id … … 31 33 owned by students. 32 34 """ 33 grok.implements(IStudent, IStudentNavigation) 35 grok.implements(IStudent, IStudentNavigation, 36 IStudentBaseEdit) 34 37 grok.provides(IStudent) 35 38 -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r6667 r6694 39 39 from waeup.sirp.university.faculty import Faculty 40 40 from waeup.sirp.university.department import Department 41 from waeup.sirp.interfaces import IUserAccount 41 42 42 43 PH_LEN = 2059 # Length of placeholder file … … 75 76 student.name = u'Anna Tester' 76 77 self.test_student_id = self.app['students'].addStudent(student) 77 78 # Set password 79 IUserAccount(self.app['students'][self.test_student_id]).setPassword('spwd') 80 81 self.login_path = 'http://localhost/app/login' 78 82 self.container_path = 'http://localhost/app/students' 79 83 self.manage_container_path = self.container_path + '/@@manage' … … 244 248 self.assertMatches('...Student admitted by zope.mgr...', 245 249 self.browser.contents) 246 247 return 250 return 251 252 def test_student_access(self): 253 # Students can access their own objects 254 # and can perform actions 255 256 self.browser.open(self.login_path) 257 self.browser.getControl(name="form.login").value = self.test_student_id 258 self.browser.getControl(name="form.password").value = 'spwd' 259 self.browser.getControl("Login").click() 260 self.assertEqual(self.browser.url, self.student_path) 261 self.assertTrue('You logged in' in self.browser.contents) 262 # Change password 263 self.browser.getLink("Change password").click() 264 self.browser.getControl(name="form.password").value = 'new_password' 265 self.browser.getControl("Save").click() 266 self.assertTrue('Form has been saved' in self.browser.contents) 267 # We are still logged in. Changing the password hasn't thrown us out. 268 self.browser.getLink("My Data").click() 269 self.assertEqual(self.browser.url, self.student_path) 270 # We can logout 271 self.browser.getLink("Logout").click() 272 self.assertTrue('You have been logged out' in self.browser.contents) 273 self.assertEqual(self.browser.url, 'http://localhost/app') 274 # We can login again with the new password 275 self.browser.getLink("Login").click() 276 #self.browser.open(self.login_path) 277 self.browser.getControl(name="form.login").value = self.test_student_id 278 self.browser.getControl(name="form.password").value = 'new_password' 279 self.browser.getControl("Login").click() 280 self.assertEqual(self.browser.url, self.student_path) 281 self.assertTrue('You logged in' in self.browser.contents) 282 return
Note: See TracChangeset for help on using the changeset viewer.