source: main/waeup.custom/trunk/src/waeup/custom/students/browser.py @ 8077

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

See previous revision.

  • Property svn:keywords set to Id
File size: 5.1 KB
Line 
1## $Id: browser.py 8077 2012-04-09 11:07:20Z 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
20from waeup.kofa.widgets.datewidget import (
21    FriendlyDateWidget, FriendlyDateDisplayWidget
22    )
23from waeup.kofa.students.browser import (
24    StudentPersonalDisplayFormPage, StudentPersonalManageFormPage,
25    StudentClearanceManageFormPage, StudentClearanceEditFormPage,
26    StudentClearanceDisplayFormPage, OnlinePaymentCallbackPage,
27    ExportPDFClearanceSlipPage, StudentBaseManageFormPage,
28    StudentBaseEditFormPage)
29from waeup.kofa.students.viewlets import RequestCallbackActionButton
30from waeup.custom.students.interfaces import (
31    IStudentBase, IStudent, IStudentPersonal,
32    IUGStudentClearance,IPGStudentClearance,
33    )
34from waeup.custom.interfaces import MessageFactory as _
35from waeup.custom.widgets.phonewidget import PhoneWidget
36
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
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
63class StudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage):
64    """ Page to display student personal data
65    """
66    grok.context(IStudent)
67    form_fields = grok.AutoFields(IStudentPersonal)
68    form_fields['perm_address'].custom_widget = BytesDisplayWidget
69
70class StudentPersonalManageFormPage(StudentPersonalManageFormPage):
71    """ Page to edit student clearance data
72    """
73    grok.context(IStudent)
74    form_fields = grok.AutoFields(IStudentPersonal)
75
76class StudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage):
77    """ Page to display student clearance data
78    """
79    grok.context(IStudent)
80
81    @property
82    def form_fields(self):
83        cm = getattr(self.context,'current_mode', None)
84        if cm is not None and cm.startswith('pg'):
85            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
86        else:
87            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
88        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
89        return form_fields
90
91class ExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage):
92    """Deliver a PDF slip of the context.
93    """
94    grok.context(IStudent)
95
96    @property
97    def form_fields(self):
98        cm = getattr(self.context,'current_mode', None)
99        if cm is not None and cm.startswith('pg'):
100            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
101        else:
102            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
103        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
104        return form_fields
105
106class StudentClearanceManageFormPage(StudentClearanceManageFormPage):
107    """ Page to edit student clearance data
108    """
109    grok.context(IStudent)
110
111    @property
112    def form_fields(self):
113        cm = getattr(self.context,'current_mode', None)
114        if cm is not None and cm.startswith('pg'):
115            form_fields = grok.AutoFields(IPGStudentClearance)
116        else:
117            form_fields = grok.AutoFields(IUGStudentClearance)
118        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
119        return form_fields
120
121class StudentClearanceEditFormPage(StudentClearanceEditFormPage):
122    """ View to edit student clearance data by student
123    """
124    grok.context(IStudent)
125
126    @property
127    def form_fields(self):
128        cm = getattr(self.context,'current_mode', None)
129        if cm is not None and cm.startswith('pg'):
130            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
131        else:
132            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
133        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
134        return form_fields
135
Note: See TracBrowser for help on using the repository browser.