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

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

Rename custom to uniben.

  • Property svn:keywords set to Id
File size: 4.5 KB
Line 
1## $Id: browser.py 8020 2012-04-02 11:05:40Z 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)
28from waeup.kofa.students.viewlets import RequestCallbackActionButton
29from waeup.uniben.students.interfaces import (
30    IStudent, IStudentPersonal,
31    IUGStudentClearance,IPGStudentClearance,
32    )
33from waeup.uniben.interfaces import MessageFactory as _
34
35class RequestCallbackActionButton(RequestCallbackActionButton):
36    """ Do not display the base package callback button in custom pages.
37    """
38    @property
39    def target_url(self):
40        return ''
41
42class OnlinePaymentCallbackPage(OnlinePaymentCallbackPage):
43    """ Neutralize callback simulation view
44    """
45    def update(self):
46        return
47
48class StudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage):
49    """ Page to display student personal data
50    """
51    grok.context(IStudent)
52    form_fields = grok.AutoFields(IStudentPersonal)
53    form_fields['perm_address'].custom_widget = BytesDisplayWidget
54
55class StudentPersonalManageFormPage(StudentPersonalManageFormPage):
56    """ Page to edit student clearance data
57    """
58    grok.context(IStudent)
59    form_fields = grok.AutoFields(IStudentPersonal)
60
61class StudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage):
62    """ Page to display student clearance data
63    """
64    grok.context(IStudent)
65
66    @property
67    def form_fields(self):
68        cm = getattr(self.context,'current_mode', None)
69        if cm is not None and cm.startswith('pg'):
70            form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked')
71        else:
72            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
73        form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
74        return form_fields
75
76class ExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage):
77    """Deliver a PDF slip of the context.
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 StudentClearanceManageFormPage(StudentClearanceManageFormPage):
92    """ Page to edit student clearance data
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)
101        else:
102            form_fields = grok.AutoFields(IUGStudentClearance)
103        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
104        return form_fields
105
106class StudentClearanceEditFormPage(StudentClearanceEditFormPage):
107    """ View to edit student clearance data by student
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).omit('clearance_locked')
116        else:
117            form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked')
118        form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
119        return form_fields
120
Note: See TracBrowser for help on using the repository browser.