source: main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py @ 8107

Last change on this file since 8107 was 8076, checked in by Henrik Bettermann, 13 years ago

Customize PhoneWidget?.

  • Property svn:keywords set to Id
File size: 5.1 KB
RevLine 
[7505]1## $Id: browser.py 8076 2012-04-09 10:57:31Z henrik $
2##
3## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18import grok
19from zope.formlib.textwidgets import BytesDisplayWidget
[7822]20from waeup.kofa.widgets.datewidget import (
[7525]21    FriendlyDateWidget, FriendlyDateDisplayWidget
22    )
[7822]23from waeup.kofa.students.browser import (
[7525]24    StudentPersonalDisplayFormPage, StudentPersonalManageFormPage,
25    StudentClearanceManageFormPage, StudentClearanceEditFormPage,
[7998]26    StudentClearanceDisplayFormPage, OnlinePaymentCallbackPage,
[8076]27    ExportPDFClearanceSlipPage, StudentBaseManageFormPage,
28    StudentBaseEditFormPage)
[7879]29from waeup.kofa.students.viewlets import RequestCallbackActionButton
[8020]30from waeup.uniben.students.interfaces import (
[8076]31    IStudentBase, IStudent, IStudentPersonal,
[7995]32    IUGStudentClearance,IPGStudentClearance,
[7879]33    )
[8020]34from waeup.uniben.interfaces import MessageFactory as _
[8076]35from waeup.uniben.widgets.phonewidget import PhoneWidget
[7505]36
[7998]37class RequestCallbackActionButton(RequestCallbackActionButton):
38    """ Do not display the base package callback button in custom pages.
39    """
40    @property
41    def target_url(self):
42        return ''
43
44class OnlinePaymentCallbackPage(OnlinePaymentCallbackPage):
45    """ Neutralize callback simulation view
46    """
47    def update(self):
48        return
49
[8076]50class StudentBaseManageFormPage(StudentBaseManageFormPage):
51    """ View to manage student base data
52    """
53    form_fields = grok.AutoFields(IStudentBase).omit('student_id')
54    form_fields['phone'].custom_widget = PhoneWidget
55
56class StudentBaseEditFormPage(StudentBaseEditFormPage):
57    """ View to edit student base data
58    """
59    form_fields = grok.AutoFields(IStudentBase).select(
60        'email', 'phone')
61    form_fields['phone'].custom_widget = PhoneWidget
62
63
[7505]64class StudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage):
65    """ Page to display student personal data
66    """
67    grok.context(IStudent)
68    form_fields = grok.AutoFields(IStudentPersonal)
69    form_fields['perm_address'].custom_widget = BytesDisplayWidget
70
[7525]71class StudentPersonalManageFormPage(StudentPersonalManageFormPage):
72    """ Page to edit student clearance data
73    """
74    grok.context(IStudent)
75    form_fields = grok.AutoFields(IStudentPersonal)
[7505]76
[7525]77class StudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage):
78    """ Page to display student clearance data
79    """
80    grok.context(IStudent)
81
[7995]82    @property
83    def form_fields(self):
84        cm = getattr(self.context,'current_mode', None)
85        if cm is not None and cm.startswith('pg'):
86            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
87        else:
88            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
89        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
90        return form_fields
91
92class ExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage):
93    """Deliver a PDF slip of the context.
94    """
95    grok.context(IStudent)
96
97    @property
98    def form_fields(self):
99        cm = getattr(self.context,'current_mode', None)
100        if cm is not None and cm.startswith('pg'):
101            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
102        else:
103            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
104        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
105        return form_fields
106
[7525]107class StudentClearanceManageFormPage(StudentClearanceManageFormPage):
108    """ Page to edit student clearance data
109    """
110    grok.context(IStudent)
111
[7995]112    @property
113    def form_fields(self):
114        cm = getattr(self.context,'current_mode', None)
115        if cm is not None and cm.startswith('pg'):
116            form_fields = grok.AutoFields(IPGStudentClearance)
117        else:
118            form_fields = grok.AutoFields(IUGStudentClearance)
119        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
120        return form_fields
121
[7525]122class StudentClearanceEditFormPage(StudentClearanceEditFormPage):
123    """ View to edit student clearance data by student
124    """
125    grok.context(IStudent)
126
[7995]127    @property
128    def form_fields(self):
129        cm = getattr(self.context,'current_mode', None)
130        if cm is not None and cm.startswith('pg'):
131            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
132        else:
133            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
134        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
135        return form_fields
136
Note: See TracBrowser for help on using the repository browser.