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

Last change on this file since 8204 was 8204, checked in by Henrik Bettermann, 12 years ago

Rename customized classes - part2.

Attention: All applicants and students on demo portals must be deleted.

  • Property svn:keywords set to Id
File size: 5.5 KB
Line 
1## $Id: browser.py 8204 2012-04-18 06:05:16Z 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 zope.component import getUtility
21from waeup.kofa.interfaces import IExtFileStore
22from waeup.kofa.students.browser import (
23    StudentPersonalDisplayFormPage,
24    StudentClearanceManageFormPage, StudentClearanceEditFormPage,
25    StudentClearanceDisplayFormPage, OnlinePaymentCallbackPage,
26    ExportPDFClearanceSlipPage, StudentBaseManageFormPage,
27    StudentBaseEditFormPage, StudentPersonalEditFormPage)
28from waeup.kofa.students.viewlets import RequestCallbackActionButton
29from waeup.uniben.students.interfaces import (
30    ICustomStudentBase, ICustomStudent, ICustomStudentPersonal,
31    ICustomUGStudentClearance,ICustomPGStudentClearance,
32    )
33from waeup.uniben.interfaces import MessageFactory as _
34
35class CustomRequestCallbackActionButton(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 CustomOnlinePaymentCallbackPage(OnlinePaymentCallbackPage):
43    """ Neutralize callback simulation view
44    """
45    def update(self):
46        return
47
48class CustomStudentBaseManageFormPage(StudentBaseManageFormPage):
49    """ View to manage student base data
50    """
51    form_fields = grok.AutoFields(ICustomStudentBase).omit('student_id')
52
53class CustomStudentBaseEditFormPage(StudentBaseEditFormPage):
54    """ View to edit student base data
55    """
56    form_fields = grok.AutoFields(ICustomStudentBase).select(
57        'email', 'phone')
58
59
60class CustomStudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage):
61    """ Page to display student personal data
62    """
63    grok.context(ICustomStudent)
64    form_fields = grok.AutoFields(ICustomStudentPersonal)
65    form_fields['perm_address'].custom_widget = BytesDisplayWidget
66
67
68class CustomStudentPersonalEditFormPage(StudentPersonalEditFormPage):
69    """ Page to edit personal data
70    """
71    form_fields = grok.AutoFields(ICustomStudentPersonal)
72
73
74class CustomStudentClearanceDisplayFormPage(StudentClearanceDisplayFormPage):
75    """ Page to display student clearance data
76    """
77    grok.context(ICustomStudent)
78
79    @property
80    def form_fields(self):
81        cm = getattr(self.context,'current_mode', None)
82        if cm is not None and cm.startswith('pg'):
83            form_fields = grok.AutoFields(
84                ICustomPGStudentClearance).omit('clearance_locked')
85        else:
86            form_fields = grok.AutoFields(
87                ICustomUGStudentClearance).omit('clearance_locked')
88        return form_fields
89
90class CustomExportPDFClearanceSlipPage(ExportPDFClearanceSlipPage):
91    """Deliver a PDF slip of the context.
92    """
93    grok.context(ICustomStudent)
94
95    @property
96    def form_fields(self):
97        cm = getattr(self.context,'current_mode', None)
98        if cm is not None and cm.startswith('pg'):
99            form_fields = grok.AutoFields(
100                ICustomPGStudentClearance).omit('clearance_locked')
101        else:
102            form_fields = grok.AutoFields(
103                ICustomUGStudentClearance).omit('clearance_locked')
104        return form_fields
105
106class CustomStudentClearanceManageFormPage(StudentClearanceManageFormPage):
107    """ Page to edit student clearance data
108    """
109    grok.context(ICustomStudent)
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(ICustomPGStudentClearance)
116        else:
117            form_fields = grok.AutoFields(ICustomUGStudentClearance)
118        return form_fields
119
120class CustomStudentClearanceEditFormPage(StudentClearanceEditFormPage):
121    """ View to edit student clearance data by student
122    """
123    grok.context(ICustomStudent)
124
125    @property
126    def form_fields(self):
127        cm = getattr(self.context,'current_mode', None)
128        if cm is not None and cm.startswith('pg'):
129            form_fields = grok.AutoFields(ICustomPGStudentClearance).omit('clearance_locked')
130        else:
131            form_fields = grok.AutoFields(ICustomUGStudentClearance).omit('clearance_locked')
132        return form_fields
133
134    def dataNotComplete(self):
135        store = getUtility(IExtFileStore)
136        if not store.getFileByContext(self.context, attr=u'birth_certicicate.jpg'):
137            return _('No birth certificate uploaded.')
138        if not store.getFileByContext(self.context, attr=u'ref_let.jpg'):
139            return _('No referee letter uploaded.')
140        if not store.getFileByContext(self.context, attr=u'acc_let.jpg'):
141            return _('No acceptance letter uploaded.')
142        if not store.getFileByContext(self.context, attr=u'fst_sit_scan.jpg'):
143            return _('No first sitting result uploaded.')
144        return False
145
Note: See TracBrowser for help on using the repository browser.