Changeset 6907 for main/waeup.sirp/trunk


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.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
1 added
11 edited

Legend:

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

    r6839 r6907  
    1414from waeup.sirp.utils.logger import Logger
    1515from waeup.sirp.utils.helpers import attrs_to_fields
     16from waeup.sirp.configuration import ConfigurationContainer
    1617
    1718class University(grok.Application, grok.Container, Logger):
     
    4445        self['images'] = ImageStorage()
    4546        self['students'] = StudentsContainer()
     47        self['configuration'] = ConfigurationContainer()
    4648        self._createPlugins()
    4749
  • main/waeup.sirp/trunk/src/waeup/sirp/app.txt

    r6897 r6907  
    5555    >>> from waeup.sirp.app import University
    5656    >>> myuniversity = University()
    57     >>> myuniversity.name
     57    >>> myuniversity['configuration'].name
    5858    u'Sample University'
    5959
     
    6969  >>> myuniversity['datacenter']
    7070  <waeup.sirp.datacenter.DataCenter object at 0x...>
     71
     72  >>> myuniversity['configuration']
     73  <waeup.sirp.configuration.ConfigurationContainer object at 0x...>
    7174
    7275We can export universities. For this we lookup an appropriate exporter
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/breadcrumbs.py

    r6008 r6907  
    66from zope.publisher.browser import TestRequest
    77
     8from waeup.sirp.interfaces import IConfigurationContainer
    89from waeup.sirp.browser import interfaces
    910from waeup.sirp.browser.interfaces import (IBreadcrumb, IBreadcrumbIgnorable,
     
    100101    viewname = 'administration'
    101102
     103class ConfigurationContainerBreadcrumb(Breadcrumb):
     104    """A breadcrumb for the configuration container.
     105    """
     106    grok.context(IConfigurationContainer)
     107    title = u'Portal Configuration'
     108    parent_viewname = 'administration'
     109
    102110class UserContainerBreadcrumb(Breadcrumb):
    103111    """A breadcrumb for user containers.
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/browser.txt

    r6734 r6907  
    6262  >>> browser.handleErrors = False
    6363
    64 We can then get an edit view of a university::
    65 
    66   >>> browser.open('http://localhost/myuniversity/manage')
    67   >>> print browser.contents
    68   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
    69   ...<form action="http://localhost/myuniversity/manage"
     64We can then get an edit view of the configuration container::
     65
     66  >>> browser.open('http://localhost/myuniversity/configuration')
     67  >>> print browser.contents
     68  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
     69  ...<form action="http://localhost/myuniversity/configuration/@@index"
    7070  ...
    7171
     
    8888  ...
    8989
    90   >>> browser.getControl("Cancel").click()
    91   >>> print browser.contents
    92   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
    93   ...<li class="message">Action cancelled.</li>
    94   ...
    95 
    96   >>> browser.open('http://localhost/myuniversity/manage')
    97   >>> browser.getControl("Save and return").click()
    98   >>> print browser.contents
    99   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
    100   ...<li class="message">Settings have been saved.</li>
    101   ...
    102 
    103   >>> browser.open('http://localhost/myuniversity/manage')
     90  >>> browser.open('http://localhost/myuniversity/configuration')
    10491  >>> browser.getControl("Update plugins").click()
    10592  >>> print browser.contents
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/layout.py

    r6818 r6907  
    133133
    134134    def getAppTitle(self):
    135         return getattr(grok.getSite(), 'name', u'Sample University')
     135        return getattr(grok.getSite()['configuration'], 'name', u'Sample University')
    136136
    137137    def isAuthenticated(self):
     
    184184        """
    185185        mode('minified')
    186         theme_name = getattr(grok.getSite(), 'skin', '')
     186        theme_name = getattr(grok.getSite()['configuration'], 'skin', '')
    187187        theme = queryUtility(ITheme, name=theme_name,
    188188                             default=self.default_theme)
  • 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#
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/administrationpage.pt

    r5396 r6907  
    1 <h3>Administration</h3>
     1<h2>Administration</h2>
    22
    33<p>
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/universitypage.pt

    r6065 r6907  
    11<h2 tal:content="view/label">Title</h2>
    22
    3 <span tal:replace="structure view/widgets/frontpage">Frontpage</span>
     3<span tal:replace="structure view/frontpage">Frontpage</span>
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py

    r6685 r6907  
    301301    # This link is only displayed, if the user is
    302302    # allowed to use it!
    303     grok.require('waeup.managePortalSettings')
    304 
    305     link = '@@manage'
    306     text = u'Portal Settings'
     303    grok.require('waeup.managePortalConfiguration')
     304
     305    link = 'configuration'
     306    text = u'Portal Configuration'
    307307   
    308308    def render(self):
     
    332332# Manage ("Edit settings") actions...
    333333#
    334 class ManageUniversityActionButton(ManageActionButton):
    335     """ 'Edit' button for University instances.
    336     """
    337     grok.context(IUniversity)
    338     grok.view(UniversityPage)
    339     text = 'Edit portal settings'
     334#class ManageUniversityActionButton(ManageActionButton):
     335#    """ 'Edit' button for University instances.
     336#    """
     337#    grok.context(IUniversity)
     338#    grok.view(UniversityPage)
     339#    text = 'Edit portal settings'
    340340   
    341341#class ManageFacultiesActionButton(ManageActionButton):
     
    618618        return self.view.url(self.context[self.target_viewname])
    619619
    620 class AdminTaskPortalSettings(AdminTask):
     620class AdminTaskPortalConfiguration(AdminTask):
    621621    """Entry on administration page that link to portal settings.
    622622    """
    623623    grok.order(1)
    624     grok.require('waeup.managePortalSettings')
    625 
    626     link_title = 'Portal Settings'
     624    grok.require('waeup.managePortalConfiguration')
     625
     626    link_title = 'Portal Configuration'
    627627    def link_target(self):
    628         return self.view.url(self.view.context, '@@manage')
     628        return self.view.url(self.view.context, 'configuration')
    629629
    630630class AdminTaskUsers(AdminTask):
  • main/waeup.sirp/trunk/src/waeup/sirp/interfaces.py

    r6905 r6907  
    6767    """Representation of a university.
    6868    """
    69     name = schema.TextLine(
    70         title = u'Name of University',
    71         default = u'Sample University',
    72         required = True,
    73         )
    74 
    75     title = schema.TextLine(
    76         title = u'Title of frontpage',
    77         default = u'Welcome to the Student Information and Registration ' +
    78                   u'Portal of Sample University',
    79         required = False,
    80         )
    81 
    82     skin = schema.Choice(
    83         title = u'Skin',
    84         default = u'waeuptheme-gray1.css',
    85         vocabulary = 'waeup.sirp.browser.theming.ThemesVocabulary',
    86         required = True,
    87         )
    88 
    89     frontpage = schema.Text(
    90         title = u'Content in reST format',
    91         required = False,
    92         default = default_frontpage,
    93         )
    9469
    9570
     
    210185        """
    211186
     187class IConfigurationContainer(IWAeUPObject):
     188    """A container for session configuration objects.
     189    """
     190
     191    name = schema.TextLine(
     192        title = u'Name of University',
     193        default = u'Sample University',
     194        required = True,
     195        )
     196
     197    title = schema.TextLine(
     198        title = u'Title of frontpage',
     199        default = u'Welcome to the Student Information and Registration ' +
     200                  u'Portal of Sample University',
     201        required = False,
     202        )
     203
     204    skin = schema.Choice(
     205        title = u'Skin',
     206        default = u'gray waeup theme',
     207        vocabulary = 'waeup.sirp.browser.theming.ThemesVocabulary',
     208        required = True,
     209        )
     210
     211    frontpage = schema.Text(
     212        title = u'Content in reST format',
     213        required = False,
     214        default = default_frontpage,
     215        )
     216
     217class ISessionConfiguration(IWAeUPObject):
     218    """A container for session configuration objects.
     219    """
     220
    212221class IDataCenter(IWAeUPObject):
    213222    """A data center.
  • main/waeup.sirp/trunk/src/waeup/sirp/permissions.py

    r6655 r6907  
    3434    grok.name('waeup.manageDataCenter')
    3535
    36 class ManagePortalSettings(grok.Permission):
    37     grok.name('waeup.managePortalSettings')
     36class ManagePortalConfiguration(grok.Permission):
     37    grok.name('waeup.managePortalConfiguration')
    3838
    3939# Local Roles
     
    6767                     'waeup.View', 'waeup.Public','waeup.manageACBatches',
    6868                     'waeup.manageDataCenter','waeup.managePortalSettings',
     69                     'waeup.managePortalConfiguration',
    6970                     'waeup.manageApplications', 'waeup.handleApplication',
    7071                     'waeup.viewStudents', 'waeup.manageStudents')
Note: See TracChangeset for help on using the changeset viewer.