Changeset 6916 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 21 Oct 2011, 08:01:14 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r6908 r6916 34 34 IWAeUPObject, IUserContainer, IUserAccount, IDataCenter, 35 35 IWAeUPXMLImporter, IWAeUPXMLExporter, IBatchProcessor, 36 ILocalRolesAssignable, DuplicationError, IConfigurationContainer) 36 ILocalRolesAssignable, DuplicationError, IConfigurationContainer, 37 ISessionConfiguration, ISessionConfigurationAdd, academic_sessions_vocab) 37 38 from waeup.sirp.permissions import get_users_with_local_roles, getRoles 38 39 from waeup.sirp.university.catalog import search … … 417 418 form_fields['frontpage'].custom_widget = ReSTDisplayWidget 418 419 419 #def renderFrontpage(self):420 # self.setUpWidgets()421 # return widgets['frontpage']422 423 420 class ConfigurationContainerManageFormPage(WAeUPEditFormPage): 424 """Manage page of the configuration container. 421 """Manage page of the configuration container. We always use the 422 manage page in the UI not the view page, thus we use the index name here. 425 423 """ 426 424 grok.require('waeup.managePortalConfiguration') 427 425 grok.name('index') 428 426 grok.context(IConfigurationContainer) 427 grok.template('configurationmanagepage') 429 428 pnav = 0 430 429 label = u'Edit portal configuration' 431 430 title = u'Portal Configuration' 431 taboneactions = ['Save', 'Update plugins'] 432 tabtwoactions = [ 433 'Add session configuration', 434 'Remove selected sesson configurations'] 432 435 433 436 form_fields = grok.AutoFields(IConfigurationContainer) 437 438 def update(self): 439 tabs.need() 440 datatable.need() 441 return super(ConfigurationContainerManageFormPage, self).update() 434 442 435 443 @grok.action('Save') … … 439 447 return 440 448 449 @grok.action('Add session configuration', validator=NullValidator) 450 def addSubunit(self, **data): 451 self.redirect(self.url(self.context, '@@add')) 452 return 453 454 def getSessionConfigurations(self): 455 """Get a list of all stored session configuration objects. 456 """ 457 for key, val in self.context.items(): 458 url = self.url(val) 459 session_string = academic_sessions_vocab.getTermByToken(key).title 460 title = 'Session %s Configuration Data' % session_string 461 yield(dict(url=url, name=key, title=title)) 462 463 # ToDo: Show warning message before deletion 464 @grok.action('Remove selected sesson configurations') 465 def delSubobjects(self, **data): 466 form = self.request.form 467 if form.has_key('val_id'): 468 child_id = form['val_id'] 469 else: 470 self.flash('No item selected.') 471 self.redirect(self.url(self.context, '@@index')+'#tab-2') 472 return 473 if not isinstance(child_id, list): 474 child_id = [child_id] 475 deleted = [] 476 for id in child_id: 477 try: 478 del self.context[id] 479 deleted.append(id) 480 except: 481 self.flash('Could not delete %s: %s: %s' % ( 482 id, sys.exc_info()[0], sys.exc_info()[1])) 483 if len(deleted): 484 self.flash('Successfully removed: %s' % ', '.join(deleted)) 485 self.redirect(self.url(self.context, '@@index')+'#tab-2') 486 return 487 441 488 @grok.action('Update plugins', validator=NullValidator) 442 489 def updatePlugins(self, **data): … … 445 492 return 446 493 494 class SessionConfigurationAddFormPage(WAeUPAddFormPage): 495 """Add a session configuration object to configuration container. 496 """ 497 grok.context(IConfigurationContainer) 498 grok.name('add') 499 grok.require('waeup.managePortalConfiguration') 500 label = 'Add session configuration' 501 title = 'Configuration' 502 form_fields = grok.AutoFields(ISessionConfigurationAdd) 503 pnav = 0 504 505 @grok.action('Add Session Configuration') 506 def addSessionConfiguration(self, **data): 507 sessionconfiguration = createObject(u'waeup.SessionConfiguration') 508 self.applyData(sessionconfiguration, **data) 509 try: 510 self.context.addSessionConfiguration(sessionconfiguration) 511 except KeyError: 512 self.flash('The session chosen already exists ') 513 return 514 self.redirect(self.url(self.context, '@@index')+'#tab-2') 515 return 516 517 @grok.action('Cancel', validator=NullValidator) 518 def cancel(self): 519 self.redirect(self.url(self.context, '@@index')+'#tab-2') 520 return 447 521 448 522 # -
main/waeup.sirp/trunk/src/waeup/sirp/configuration.py
r6907 r6916 18 18 """ 19 19 import grok 20 from zope.component.interfaces import IFactory 20 21 from waeup.sirp.interfaces import ( 21 ISessionConfiguration, IConfigurationContainer )22 ISessionConfiguration, IConfigurationContainer, ISessionConfigurationAdd) 22 23 from waeup.sirp.utils.helpers import attrs_to_fields 23 24 … … 34 35 if not ISessionConfiguration.providedBy(sessionconfiguration): 35 36 raise TypeError( 36 'StudentsContainers contain only IStudent instances') 37 self[sessionconfiguration.year] = sessionconfiguration 37 'ConfigurationContainers contain only ISessionConfiguration instances') 38 code = unicode(sessionconfiguration.academic_session) 39 self[code] = sessionconfiguration 38 40 return 39 41 40 42 ConfigurationContainer = attrs_to_fields(ConfigurationContainer) 43 44 class SessionConfiguration(grok.Model): 45 """ 46 Session configuration model 47 """ 48 49 grok.implements(ISessionConfiguration, ISessionConfigurationAdd) 50 51 SessionConfiguration = attrs_to_fields(SessionConfiguration) 52 53 class SessionConfigurationFactory(grok.GlobalUtility): 54 """A factory for session configuration objects. 55 """ 56 grok.implements(IFactory) 57 grok.name(u'waeup.SessionConfiguration') 58 title = u"Create a new session configuration object.", 59 description = u"This factory instantiates new session configurations." 60 61 def __call__(self, *args, **kw): 62 return SessionConfiguration(*args, **kw) 63 64 def getInterfaces(self): 65 return implementedBy(SessionConfiguration) -
main/waeup.sirp/trunk/src/waeup/sirp/interfaces.py
r6915 r6916 244 244 ) 245 245 246 fee_2 = schema.Int( 247 title = u'Surcharge', 248 default = 0, 249 ) 250 251 class ISessionConfigurationAdd(ISessionConfiguration): 252 """A session configuration object in add mode. 253 """ 254 255 academic_session = schema.Choice( 256 title = u'Academic Session', 257 source = academic_sessions_vocab, 258 default = None, 259 required = True, 260 readonly = False, 261 ) 262 263 ISessionConfigurationAdd['academic_session'].order = ISessionConfiguration[ 264 'academic_session'].order 265 246 266 class IDataCenter(IWAeUPObject): 247 267 """A data center.
Note: See TracChangeset for help on using the changeset viewer.