Changeset 9124 for main/waeup.kofa/trunk/src
- Timestamp:
- 30 Aug 2012, 06:28:17 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r9028 r9124 42 42 from waeup.kofa.interfaces import ( 43 43 IKofaObject, IUserAccount, IExtFileStore, IPasswordValidator, IContactForm, 44 IKofaUtils, IUniversity )44 IKofaUtils, IUniversity, IObjectHistory) 45 45 from waeup.kofa.interfaces import MessageFactory as _ 46 46 from waeup.kofa.widgets.datewidget import ( … … 299 299 def label(self): 300 300 if self.context.suspended: 301 return _('${a}: Base Data (account suspended)',301 return _('${a}: Base Data (account deactivated)', 302 302 mapping = {'a':self.context.display_fullname}) 303 303 return _('${a}: Base Data', … … 353 353 grok.name('manage_base') 354 354 grok.require('waeup.manageStudent') 355 form_fields = grok.AutoFields(IStudentBase).omit('student_id', 'adm_code') 355 form_fields = grok.AutoFields(IStudentBase).omit( 356 'student_id', 'adm_code', 'suspended') 356 357 grok.template('basemanagepage') 357 358 label = _('Manage base data') … … 414 415 if fields_string: 415 416 self.context.writeLogMessage(self, 'saved: % s' % fields_string) 417 return 418 419 class StudentActivatePage(UtilityView, grok.View): 420 """ Activate student account 421 """ 422 grok.context(IStudent) 423 grok.name('activate') 424 grok.require('waeup.manageStudent') 425 426 def update(self): 427 self.context.suspended = False 428 self.context.writeLogMessage(self, 'account activated') 429 history = IObjectHistory(self.context) 430 history.addMessage('Student account activated') 431 self.flash(_('Student account has been activated.')) 432 self.redirect(self.url(self.context)) 433 return 434 435 def render(self): 436 return 437 438 class StudentDeactivatePage(UtilityView, grok.View): 439 """ Deactivate student account 440 """ 441 grok.context(IStudent) 442 grok.name('deactivate') 443 grok.require('waeup.manageStudent') 444 445 def update(self): 446 self.context.suspended = True 447 self.context.writeLogMessage(self, 'account deactivated') 448 history = IObjectHistory(self.context) 449 history.addMessage('Student account deactivated') 450 self.flash(_('Student account has been deactivated.')) 451 self.redirect(self.url(self.context)) 452 return 453 454 def render(self): 416 455 return 417 456 -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r9123 r9124 1918 1918 self.assertTrue('Employer' in self.browser.contents) 1919 1919 1920 def test_activate_deactivate_buttons(self): 1921 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1922 self.browser.open(self.student_path) 1923 self.browser.getLink("Deactivate").click() 1924 self.assertTrue( 1925 'Student account has been deactivated.' in self.browser.contents) 1926 self.assertTrue( 1927 'Base Data (account deactivated)' in self.browser.contents) 1928 self.assertTrue(self.student.suspended) 1929 self.browser.getLink("Activate").click() 1930 self.assertTrue( 1931 'Student account has been activated.' in self.browser.contents) 1932 self.assertFalse( 1933 'Base Data (account deactivated)' in self.browser.contents) 1934 self.assertFalse(self.student.suspended) 1935 # History messages have been added ... 1936 self.browser.getLink("History").click() 1937 self.assertTrue( 1938 'Student account deactivated by Manager<br />' in self.browser.contents) 1939 self.assertTrue( 1940 'Student account activated by Manager<br />' in self.browser.contents) 1941 # ... and actions have been logged. 1942 logfile = os.path.join( 1943 self.app['datacenter'].storage, 'logs', 'students.log') 1944 logcontent = open(logfile).read() 1945 self.assertTrue('zope.mgr - students.browser.StudentDeactivatePage - ' 1946 'K1000000 - account deactivated' in logcontent) 1947 self.assertTrue('zope.mgr - students.browser.StudentActivatePage - ' 1948 'K1000000 - account activated' in logcontent) 1949 1920 1950 class StudentRequestPWTests(StudentsFullSetup): 1921 1951 # Tests for student registration -
main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py
r9070 r9124 166 166 target = 'manage_base' 167 167 168 class StudentDeactivateActionButton(ManageActionButton): 169 grok.order(5) 170 grok.context(IStudent) 171 grok.view(StudentBaseDisplayFormPage) 172 grok.require('waeup.manageStudent') 173 text = _('Deactivate account') 174 target = 'deactivate' 175 icon = 'actionicon_traffic_lights_red.png' 176 177 @property 178 def target_url(self): 179 if self.context.suspended: 180 return '' 181 return self.view.url(self.view.context, self.target) 182 183 class StudentActivateActionButton(ManageActionButton): 184 grok.order(5) 185 grok.context(IStudent) 186 grok.view(StudentBaseDisplayFormPage) 187 grok.require('waeup.manageStudent') 188 text = _('Activate account') 189 target = 'activate' 190 icon = 'actionicon_traffic_lights_green.png' 191 192 @property 193 def target_url(self): 194 if not self.context.suspended: 195 return '' 196 return self.view.url(self.view.context, self.target) 197 168 198 class StudentClearanceManageActionButton(ManageActionButton): 169 199 grok.order(1)
Note: See TracChangeset for help on using the changeset viewer.