Ignore:
Timestamp:
18 Oct 2011, 17:56:51 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement a configuration container. Transfer attributes from University class to ConfigurationContainer? class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r6853 r6907  
    3434    IWAeUPObject, IUserContainer, IUserAccount, IDataCenter,
    3535    IWAeUPXMLImporter, IWAeUPXMLExporter, IBatchProcessor,
    36     ILocalRolesAssignable, DuplicationError)
     36    ILocalRolesAssignable, DuplicationError, IConfigurationContainer)
    3737from waeup.sirp.permissions import get_users_with_local_roles, getRoles
    3838from waeup.sirp.university.catalog import search
     
    153153    pnav = 0
    154154
    155     form_fields = grok.AutoFields(IUniversity)
    156     form_fields['frontpage'].custom_widget = ReSTDisplayWidget
    157 
    158155    @property
    159156    def title(self):
     
    162159    @property
    163160    def label(self):
    164         return self.context.title
    165 
    166 class UniversityManageFormPage(WAeUPEditFormPage):
    167     """Manage the basic properties of a `University` instance.
    168     """
    169     form_fields = grok.AutoFields(IUniversity)
    170     grok.context(IUniversity)
    171     grok.require('waeup.manageUniversity')
    172     title = u'Edit portal settings'
    173     pnav = 0
    174     grok.name('manage')
    175 
    176     @grok.action('Save')
    177     def save(self, **data):
    178         self.applyData(self.context, **data)
    179         self.flash('Settings have been saved.')
    180         return
    181 
    182     @grok.action('Save and return')
    183     def saveAndReturn(self, **data):
    184         self.applyData(self.context, **data)
    185         self.redirect(self.url(self.context))
    186         self.flash('Settings have been saved.')
    187         return
    188     @grok.action('Cancel', validator=NullValidator)
    189     def cancel(self, **data):
    190         self.flash('Action cancelled.')
    191         self.redirect(self.url(self.context))
    192         return
    193 
    194     @grok.action('Update plugins', validator=NullValidator)
    195     def updatePlugins(self, **data):
    196         self.context.updatePlugins()
    197         self.flash('Plugins were updated. See log file for details.')
    198         self.redirect(self.url(self.context))
    199         return
     161        return self.context['configuration'].title
     162
     163    @property
     164    def frontpage(self):
     165        view = ConfigurationContainerDisplayFormPage(
     166            self.context['configuration'],self.request)
     167        view.setUpWidgets()
     168        return view.widgets['frontpage']()
    200169
    201170class AdministrationPage(WAeUPPage):
     
    430399        self.flash('Your message has been sent.')
    431400        return
     401
     402
     403#
     404# Configuration pages...
     405#
     406
     407class ConfigurationContainerDisplayFormPage(WAeUPDisplayFormPage):
     408    """View page of the configuration container.
     409    """
     410    grok.require('waeup.managePortalConfiguration')
     411    grok.name('view')
     412    grok.context(IConfigurationContainer)
     413    pnav = 0
     414    label = u'View portal configuration'
     415    title = u'Portal Configuration'
     416    form_fields = grok.AutoFields(IConfigurationContainer)
     417    form_fields['frontpage'].custom_widget = ReSTDisplayWidget
     418
     419    #def renderFrontpage(self):
     420    #    self.setUpWidgets()
     421    #    return widgets['frontpage']
     422
     423class ConfigurationContainerManageFormPage(WAeUPEditFormPage):
     424    """Manage page of the configuration container.
     425    """
     426    grok.require('waeup.managePortalConfiguration')
     427    grok.name('index')
     428    grok.context(IConfigurationContainer)
     429    pnav = 0
     430    label = u'Edit portal configuration'
     431    title = u'Portal Configuration'
     432
     433    form_fields = grok.AutoFields(IConfigurationContainer)
     434
     435    @grok.action('Save')
     436    def save(self, **data):
     437        self.applyData(self.context, **data)
     438        self.flash('Settings have been saved.')
     439        return
     440
     441    @grok.action('Update plugins', validator=NullValidator)
     442    def updatePlugins(self, **data):
     443        grok.getSite().updatePlugins()
     444        self.flash('Plugins were updated. See log file for details.')
     445        return
     446
    432447
    433448#
Note: See TracChangeset for help on using the changeset viewer.