Changeset 4735 for waeup/branches


Ignore:
Timestamp:
8 Jan 2010, 03:20:47 (15 years ago)
Author:
uli
Message:

Add missing forms and pages from former academics section. Looks like
we're done with migration of nearly all viewing components.

File:
1 edited

Legend:

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

    r4729 r4735  
    1515from waeup.interfaces import (IUniversity, IWAeUPObject, IUserContainer,
    1616                              IUserAccount, IFacultyContainer, IDataCenter,
    17                               IFaculty, IDepartment, ICourse, ICertificate)
     17                              IFaculty, IDepartment, ICourse, ICertificate,
     18                              ICertificateCourse)
    1819from waeup.widgets.interfaces import ITableProvider
    1920from waeup.utils.helpers import getName
     
    709710            levels[str(level)][str(semester)].append(new_entry)
    710711        return levels
     712
     713class CertificateManageForm(WAeUPEditFormPage):
     714    """Manage the basic properties of a `Certificate` instance.
     715    """
     716    grok.context(ICertificate)
     717    grok.name('manage')
     718    grok.require('waeup.manageUniversity')
     719    form_fields = grok.AutoFields(ICertificate)
     720    pnav = 1
     721
     722    @property
     723    def title(self):
     724        # Set certificate name as form label
     725        return self.form_fields['title'].field.get(self.context)
     726   
     727    @grok.action('Save')
     728    def save(self, **data):
     729        self.applyData(self.context, **data)
     730        return
     731   
     732    @grok.action('Save and return')
     733    def saveAndReturn(self, **data):
     734        self.applyData(self.context, **data)
     735        self.redirect(self.url(self.context))
     736        return
     737
     738    @grok.action('Cancel')
     739    def cancel(self, **data):
     740        self.redirect(self.url(self.context))
     741        return
     742
     743#
     744# Certificate course pages...
     745#
     746class CertificateCoursePage(WAeUPDisplayFormPage):
     747    """Course index page.
     748    """
     749    grok.context(ICertificateCourse)
     750    grok.name('index')
     751    grok.require('waeup.View')
     752    pnav = 1
     753    form_fields = grok.AutoFields(ICertificateCourse)
     754
     755    @property
     756    def title(self):
     757        return self.context.course.title
     758
     759class CertificateCourseFormPage(WAeUPEditFormPage):
     760    """Manage the basic properties of a `CertificateCourse` instance.
     761    """
     762    grok.context(ICertificateCourse)
     763    grok.name('manage')
     764    grok.require('waeup.manageUniversity')
     765    form_fields = grok.AutoFields(ICertificateCourse)
     766    pnav = 1
     767   
     768    @property
     769    def title(self):
     770        return 'Edit certificate course %s' % self.context.course.code
     771   
     772    @grok.action('Save and return')
     773    def saveAndReturn(self, **data):
     774        parent = self.context.__parent__
     775        if self.context.level == data['level']:
     776            self.applyData(self.context, **data)
     777        else:
     778            # The level changed. We have to create a new certcourse as
     779            # the key of the entry will change as well...
     780            old_level = self.context.level
     781            parent.addCourseRef(**data)
     782            parent.delCourseRef(data['course'].code, level=old_level)
     783        self.redirect(self.url(parent))
     784        return
     785
     786    @grok.action('Cancel')
     787    def cancel(self, **data):
     788        self.redirect(self.url(self.context))
     789        return
     790
     791class CertificateCourseAddFormPage(WAeUPAddFormPage):
     792    """Add-page to add a course ref to a certificate
     793    """
     794    grok.context(ICertificate)
     795    grok.name('addcertificatecourse')
     796    grok.require('waeup.manageUniversity')
     797    form_fields = grok.AutoFields(ICertificateCourse)
     798    pnav = 1
     799    title = 'Add a course'
     800
     801    @grok.action('Add course')
     802    def addCertcourse(self, **data):
     803        try:
     804            self.context.addCourseRef(**data)
     805        except DuplicationError:
     806            self.status = Invalid('The chosen course is already part of'
     807                                  'this certificate')
     808            return
     809        self.redirect(self.url(self.context))
     810
     811    @grok.action('Cancel')
     812    def cancel(self, **data):
     813        self.redirect(self.url(self.context))
     814        return
Note: See TracChangeset for help on using the changeset viewer.