Ignore:
Timestamp:
27 Mar 2012, 20:59:30 (13 years ago)
Author:
Henrik Bettermann
Message:

Use different clearance form field interfaces for undergraduate and postgraduate students.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r7878 r7993  
    4949from waeup.kofa.widgets.phonewidget import PhoneWidget
    5050from waeup.kofa.students.interfaces import (
    51     IStudentsContainer, IStudent, IStudentClearance,
     51    IStudentsContainer, IStudent,
     52    IUGStudentClearance,IPGStudentClearance,
    5253    IStudentPersonal, IStudentBase, IStudentStudyCourse,
    5354    IStudentAccommodation, IStudentStudyLevel,
     
    393394    grok.name('view_clearance')
    394395    grok.require('waeup.viewStudent')
    395     form_fields = grok.AutoFields(IStudentClearance).omit('clearance_locked')
    396     form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
    397     pnav = 4
     396    pnav = 4
     397
     398    @property
     399    def form_fields(self):
     400        cm = getattr(self.context,'current_mode', None)
     401        if cm is not None and cm.startswith('pg'):
     402            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
     403        else:
     404            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
     405        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
     406        return form_fields
    398407
    399408    @property
     
    408417    grok.name('clearance.pdf')
    409418    grok.require('waeup.viewStudent')
    410     form_fields = grok.AutoFields(IStudentClearance).omit('clearance_locked')
    411     form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
    412419    prefix = 'form'
     420
     421    @property
     422    def form_fields(self):
     423        cm = getattr(self.context,'current_mode', None)
     424        if cm is not None and cm.startswith('pg'):
     425            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
     426        else:
     427            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
     428        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
     429        return form_fields
    413430
    414431    @property
     
    440457    grok.require('waeup.manageStudent')
    441458    grok.template('clearanceeditpage')
    442     form_fields = grok.AutoFields(IStudentClearance)
    443459    label = _('Manage clearance data')
    444460    pnav = 4
    445     form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     461
     462    @property
     463    def form_fields(self):
     464        cm = getattr(self.context,'current_mode', None)
     465        if cm is not None and cm.startswith('pg'):
     466            form_fields = grok.AutoFields(IPGStudentClearance)
     467        else:
     468            form_fields = grok.AutoFields(IUGStudentClearance)
     469        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     470        return form_fields
    446471
    447472    def update(self):
     
    15611586    grok.name('cedit')
    15621587    grok.require('waeup.handleStudent')
    1563     form_fields = grok.AutoFields(
    1564         IStudentClearance).omit('clearance_locked')
    15651588    label = _('Edit clearance data')
    1566     form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     1589
     1590    @property
     1591    def form_fields(self):
     1592        cm = getattr(self.context,'current_mode', None)
     1593        if cm is not None and cm.startswith('pg'):
     1594            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
     1595        else:
     1596            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
     1597        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
     1598        return form_fields
    15671599
    15681600    def update(self):
Note: See TracChangeset for help on using the changeset viewer.