Ignore:
Timestamp:
7 Jan 2010, 22:57:16 (15 years ago)
Author:
uli
Message:

Add form pages to add departments and edit faculty settings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-layout/src/waeup/browser/pages.py

    r4707 r4711  
    1212from waeup.interfaces import (IUniversity, IWAeUPObject, IUserContainer,
    1313                              IUserAccount, IFacultyContainer, IDataCenter,
    14                               IFaculty)
     14                              IFaculty, IDepartment)
    1515from waeup.widgets.interfaces import ITableProvider
    1616from waeup.utils.helpers import getName
     
    435435        self.table = ITableProvider(self.context).getTables(view=self)[0]
    436436        self.table.need()
     437
     438class AddDepartmentFormPage(WAeUPAddFormPage):
     439    grok.context(IFaculty)
     440    grok.name('add')
     441    form_fields = grok.AutoFields(IDepartment)
     442    title = 'Add a department'
     443    pnav = 1
     444   
     445    @grok.action('Add department')
     446    def addDepartment(self, **data):
     447        department = createObject(u'waeup.Department')
     448        self.applyData(department, **data)
     449        try:
     450            self.context.addDepartment(department)
     451        except DuplicationError:
     452            self.status = Invalid('The name chosen already exists '
     453                                  'in the database')
     454            return
     455        self.redirect(self.url(self.context))
     456
     457class ManageDepartmentFormPage(WAeUPEditFormPage):
     458    """Manage the basic properties of a `Faculty` instance.
     459    """
     460    grok.context(IFaculty)
     461    grok.name('manage')
     462    form_fields = grok.AutoFields(IFaculty)
     463    title = 'Edit faculty'
     464    pnav = 1
     465
     466    @grok.action('Save')
     467    def save(self, **data):
     468        self.applyData(self.context, **data)
     469        return
     470   
     471    @grok.action('Save and return')
     472    def saveAndReturn(self, **data):
     473        self.applyData(self.context, **data)
     474        self.redirect(self.url(self.context))
     475        return
     476
     477    @grok.action('Cancel')
     478    def cancel(self, **data):
     479        self.redirect(self.url(self.context))
     480        return
Note: See TracChangeset for help on using the changeset viewer.