Changeset 6918 for main/waeup.sirp


Ignore:
Timestamp:
21 Oct 2011, 10:26:08 (13 years ago)
Author:
Henrik Bettermann
Message:

Add SessionConfigurationManageFormPage? and SessionConfigurationBreadcrumb?.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
4 edited

Legend:

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

    r6907 r6918  
    66from zope.publisher.browser import TestRequest
    77
    8 from waeup.sirp.interfaces import IConfigurationContainer
     8from waeup.sirp.interfaces import (
     9    IConfigurationContainer, ISessionConfiguration)
    910from waeup.sirp.browser import interfaces
    10 from waeup.sirp.browser.interfaces import (IBreadcrumb, IBreadcrumbIgnorable,
    11                                       IBreadcrumbContainer)
     11from waeup.sirp.browser.interfaces import (IBreadcrumb,
     12    IBreadcrumbIgnorable, IBreadcrumbContainer)
    1213       
    1314class Breadcrumb(grok.Adapter):
     
    108109    parent_viewname = 'administration'
    109110
     111class SessionConfigurationBreadcrumb(Breadcrumb):
     112    """A breadcrumb for the configuration container.
     113    """
     114    grok.context(ISessionConfiguration)
     115    title = u'Portal Session Configuration'
     116
     117    @property
     118    def title(self):
     119        session_string = self.context.getSessionString()
     120        return 'Session %s' % session_string
     121
    110122class UserContainerBreadcrumb(Breadcrumb):
    111123    """A breadcrumb for user containers.
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r6917 r6918  
    489489        for key, val in self.context.items():
    490490            url = self.url(val)
    491             session_string = academic_sessions_vocab.getTermByToken(key).title
    492             title = 'Session %s Configuration Data' % session_string
     491            session_string = val.getSessionString()
     492            title = 'Session %s Configuration' % session_string
    493493            yield(dict(url=url, name=key, title=title))
    494494
     
    531531    def cancel(self):
    532532        self.redirect(self.url(self.context, '@@index')+'#tab-2')
     533        return
     534
     535class SessionConfigurationManageFormPage(WAeUPEditFormPage):
     536    """Manage session configuration object.
     537    """
     538    grok.context(ISessionConfiguration)
     539    grok.name('index')
     540    grok.require('waeup.managePortalConfiguration')
     541    form_fields = grok.AutoFields(ISessionConfiguration)
     542    pnav = 0
     543
     544    @property
     545    def title(self):
     546        session_string = self.context.getSessionString()
     547        return 'Academic Session %s Configuration' % session_string
     548
     549    @property
     550    def label(self):
     551        session_string = self.context.getSessionString()
     552        return 'Edit academic session %s configuration' % session_string
     553
     554    @grok.action('Save')
     555    def save(self, **data):
     556        self.applyData(self.context, **data)
     557        self.flash('Settings have been saved.')
     558        self.redirect(self.url(self.context.__parent__, '@@index')+'#tab-2')
     559        return
     560
     561    @grok.action('Cancel', validator=NullValidator)
     562    def cancel(self):
     563        self.redirect(self.url(self.context.__parent__, '@@index')+'#tab-2')
    533564        return
    534565
  • main/waeup.sirp/trunk/src/waeup/sirp/configuration.py

    r6916 r6918  
    2020from zope.component.interfaces import IFactory
    2121from waeup.sirp.interfaces import (
    22     ISessionConfiguration, IConfigurationContainer, ISessionConfigurationAdd)
     22    ISessionConfiguration, IConfigurationContainer, ISessionConfigurationAdd,
     23    academic_sessions_vocab)
    2324from waeup.sirp.utils.helpers import attrs_to_fields
    2425
     
    4950    grok.implements(ISessionConfiguration, ISessionConfigurationAdd)
    5051
     52    def getSessionString(self):
     53        return academic_sessions_vocab.getTerm(self.academic_session).title
     54
    5155SessionConfiguration = attrs_to_fields(SessionConfiguration)
    5256
  • main/waeup.sirp/trunk/src/waeup/sirp/interfaces.py

    r6916 r6918  
    249249        )
    250250
     251    def getSessionString():
     252        """Returns the session string from the vocabulary.
     253        """
     254
     255
    251256class ISessionConfigurationAdd(ISessionConfiguration):
    252257    """A session configuration object in add mode.
Note: See TracChangeset for help on using the changeset viewer.