Changeset 12610 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 13 Feb 2015, 08:31:21 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_move.py
r12609 r12610 33 33 department = self.app['faculties']['fac1']['dep1'] 34 34 faculty = self.app['faculties']['fac1'] 35 department.moveDepartment('fac1', 'newdep') 35 36 # We move the depart using the UtilityView 37 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 38 self.browser.open('http://localhost/app/faculties/fac1/dep1/move_department?fac=fac1&dep=newdep') 36 39 37 40 # New department is created and old department is removed 38 41 self.assertEqual( 39 [key for key in self.app['faculties']['fac1']], 40 ['newdep']) 42 [key for key in self.app['faculties']['fac1']], ['newdep']) 41 43 42 44 # All subobjects have been moved too … … 79 81 assert len(results) == 1 80 82 assert results[0] is self.app['students'][self.student_id] 83 84 # Messages are found in two log files 81 85 logfile = os.path.join( 82 86 self.app['datacenter'].storage, 'logs', 'students.log') 83 87 logcontent = open(logfile).read() 84 self.assertTrue('INFO - system - K1000000 - Department moved' 88 self.assertTrue('INFO - zope.mgr - K1000000 - Department moved' 89 in logcontent) 90 logfile = os.path.join( 91 self.app['datacenter'].storage, 'logs', 'main.log') 92 logcontent = open(logfile).read() 93 self.assertTrue('INFO - zope.mgr - Department dep1 moved to fac1/newdep' 85 94 in logcontent) 86 95 -
main/waeup.kofa/trunk/src/waeup/kofa/utils/browser.py
r9127 r12610 24 24 from waeup.kofa.browser.layout import UtilityView 25 25 from waeup.kofa.interfaces import IObjectHistory 26 27 26 from waeup.kofa.interfaces import IUniversity 27 from waeup.kofa.university.interfaces import IDepartment 28 28 29 29 def replaceStudentMessages(old, new): … … 199 199 self.redirect(self.url(self.context, '@@index')) 200 200 return 201 202 203 class MoveDepartment(UtilityView, grok.View): 204 """ View to move a department. 205 206 """ 207 grok.context(IDepartment) 208 grok.name('move_department') 209 grok.require('waeup.managePortal') 210 211 def update(self,fac=None, dep=None): 212 if None in (fac, dep): 213 self.flash('Syntax: /move_department?fac=[new faculty code]&dep=[new department code]') 214 return 215 oldcode = self.context.code 216 try: 217 self.context.moveDepartment(fac, dep) 218 except: 219 self.flash('Error') 220 return 221 grok.getSite().logger.info( 222 "Department %s moved to %s/%s" % (oldcode, fac, dep)) 223 self.flash('Finished') 224 return 225 226 def render(self): 227 self.redirect(self.url(self.context, '@@index')) 228 return
Note: See TracChangeset for help on using the changeset viewer.