Ignore:
Timestamp:
10 Mar 2011, 16:35:07 (14 years ago)
Author:
uli
Message:

Add more views (pages) and a primary nav tab, which we can remove
later.

File:
1 edited

Legend:

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

    r5825 r5828  
    3131from waeup.sirp.browser.pages import LoginPage
    3232from waeup.sirp.interfaces import IWAeUPObject
    33 from waeup.sirp.browser.viewlets import AddActionButton
     33from waeup.sirp.browser.viewlets import (
     34    AddActionButton, ManageActionButton, PrimaryNavTab,
     35    )
    3436from waeup.sirp.applicants import get_applicant_data, ResultEntry
    3537from waeup.sirp.applicants.interfaces import (
     
    7072    grok.name('index')
    7173    title = 'Applicants'
    72     pnav = 1
     74    pnav = 2
    7375   
    7476    def getApplications(self):
     
    7981            yield(dict(url=url, name=key))
    8082
     83class ManageApplicantsRootActionButton(ManageActionButton):
     84    grok.context(IApplicantsRoot)
     85    grok.view(ApplicationsPage)
     86    text = 'Manage applicant containers'
     87
     88class ApplicantsRootEditPage(WAeUPPage):
     89    grok.context(IApplicantsRoot)
     90    grok.name('manage')
     91    grok.template('applicantsrooteditpage')
     92    title = 'Edit applicants containers'
     93    pnav = 2
     94
     95    def update(self, entries=None, DELETE=None, CANCEL=None):
     96        if CANCEL is not None:
     97            self.redirect(self.url(self.context))
     98            return
     99        if DELETE is None:
     100            return
     101        if entries is None:
     102            return
     103        if not isinstance(entries, list):
     104            entries = [entries]
     105        for name in entries:
     106            del self.context[name]
     107            self.flash('Deleted "%s"' % name)
     108        return
     109
     110    def getApplications(self):
     111        """Get a list of all stored applicant containers.
     112        """
     113        for key, val in self.context.items():
     114            url = self.url(val)
     115            yield(dict(url=url, name=key))
     116
    81117class AddApplicantsContainerActionButton(AddActionButton):
    82118    grok.context(IApplicantsRoot)
    83     grok.view(ApplicationsPage)
     119    grok.view(ApplicantsRootEditPage)
    84120    text = 'Add applicants container'
    85121
     
    89125    grok.template('addcontainer')
    90126    title = 'Add applicants container'
    91     pnav = 1
    92 
    93     def update(self, providername=None, name=None, ADD=None, CANCEL=None):
     127    pnav = 2
     128
     129    def update(self, providername=None, name=None, title=None,
     130               description=None, ADD=None, CANCEL=None):
    94131        if CANCEL is not None:
    95132            self.redirect(self.url(self.context))
     
    107144                              name=providername)
    108145        container = provider.factory()
     146        if title:
     147            container.title = title
     148        if description:
     149            container.description = description
    109150        self.context[name] = container
    110151        self.flash('Added "%s".' % name)
     
    140181            ]
    141182        return result
    142        
     183
     184
     185class ApplicantsTab(PrimaryNavTab):
     186    """Faculties-tab in primary navigation.
     187    """
     188    grok.context(IWAeUPObject)
     189    grok.order(3)
     190    grok.require('waeup.View')
     191    grok.template('primarynavtab')
     192
     193    pnav = 2
     194    tab_title = u'Applicants'
     195
     196    @property
     197    def link_target(self):
     198        return self.view.application_url('applicants')
     199
     200
    143201#class AddApplicant(WAeUPAddFormPage):
    144202#    grok.context(IApplicantContainer)
     
    174232    label = 'Applicant'
    175233    title = 'Applicant'
    176     pnav = 1
     234    pnav = 2
    177235
    178236class EditApplicant(WAeUPEditFormPage):
Note: See TracChangeset for help on using the changeset viewer.