- Timestamp:
- 6 Jan 2010, 03:35:38 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-layout/src/waeup/browser/pages.py
r4679 r4687 11 11 from waeup.datacenter import Import 12 12 from waeup.interfaces import (IUniversity, IWAeUPObject, IUserContainer, 13 IUserAccount, IFacultyContainer, IDataCenter) 13 IUserAccount, IFacultyContainer, IDataCenter, 14 IFaculty) 14 15 from waeup.widgets.interfaces import ITableProvider 15 16 from zope.app.security.interfaces import (IAuthentication, 16 17 IUnauthenticatedPrincipal, 17 18 ILogout) 18 from zope.component import getUtility 19 from zope.component import getUtility, createObject 19 20 from zope.exceptions import DuplicationError 20 21 … … 338 339 339 340 class FacultyContainerPage(WAeUPPage): 341 """ Index page for faculty containers. 342 """ 340 343 grok.context(IFacultyContainer) 341 344 grok.name('index') … … 357 360 result.append(dict(id=key, name=val.title)) 358 361 return result 362 363 class AddFacultyFormPage(WAeUPAddFormPage): 364 """ Page form to add a new faculty to a faculty container. 365 """ 366 grok.context(IFacultyContainer) 367 grok.require('waeup.manageUniversity') 368 grok.name('add') 369 form_fields = grok.AutoFields(IFaculty) 370 label = 'Add a faculty' 371 title = 'Add a faculty' 372 pnav = 1 373 374 @grok.action('Add faculty') 375 def addFaculty(self, **data): 376 faculty = createObject(u'waeup.Faculty') 377 self.applyData(faculty, **data) 378 try: 379 self.context.addFaculty(faculty) 380 except DuplicationError: 381 self.status = Invalid('The name chosen already exists ' 382 'in the database') 383 return 384 self.redirect(self.url(self.context)) 385 386 class ManageFacultyContainerPage(WAeUPPage): 387 """ Manage Page 388 """ 389 grok.context(IFacultyContainer) 390 grok.require('waeup.manageUniversity') 391 grok.template('facultycontainermanagepage') 392 grok.name('manage') 393 title = "Manage Faculties" 394 pnav = 1 395 396 def update(self): 397 form = self.request.form 398 if 'CANCEL' in form.keys(): 399 self.redirect(self.url(self.context)) 400 if not 'DELETE' in form.keys(): 401 return 402 fac_id = form['fac_id'] 403 if not isinstance(fac_id, list): 404 fac_id = [fac_id] 405 deleted = [] 406 for id in fac_id: 407 try: 408 del self.context[id] 409 deleted.append(id) 410 except: 411 self.flash('Could not delete %s: %s: %s' % ( 412 id, sys.exc_info()[0], sys.exc_info()[1])) 413 if len(deleted): 414 self.flash('Successfully deleted: %s' % ', '.join(deleted)) 415 # We have to redirect to let flash messages appear immediately... 416 self.redirect(self.url()) 417 return
Note: See TracChangeset for help on using the changeset viewer.