source: main/waeup.kofa/trunk/src/waeup/kofa/applicants/viewlets.py @ 10782

Last change on this file since 10782 was 10655, checked in by Henrik Bettermann, 11 years ago

Implement an VirtualApplicantsExportJobContainer? which allows to export applicants locally. On each container page there is now an'Export applicants' button which directs to the exports overview page. Unlike student exporters, the applicants exporter can't be configured. It just exports all applicants in the container.

  • Property svn:keywords set to Id
File size: 8.5 KB
Line 
1## $Id: viewlets.py 10655 2013-09-26 09:37:25Z henrik $
2##
3## Copyright (C) 2011 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 waeup.kofa.interfaces import IKofaObject
20from waeup.kofa.students.viewlets import PrimaryStudentNavTab
21from waeup.kofa.browser.viewlets import (
22    ManageActionButton, PrimaryNavTab, AddActionButton)
23from waeup.kofa.applicants.interfaces import (
24    IApplicant, IApplicantsRoot, IApplicantsContainer,
25    IApplicantOnlinePayment
26    )
27from waeup.kofa.applicants.browser import (
28    ApplicantsRootPage, ApplicantsContainerPage, ApplicantManageFormPage,
29    ApplicantDisplayFormPage, OnlinePaymentDisplayFormPage,
30    ApplicantsContainerManageFormPage, ApplicantsStatisticsPage
31    )
32
33from waeup.kofa.interfaces import MessageFactory as _
34
35grok.context(IKofaObject) # Make IKofaObject the default context
36grok.templatedir('browser_templates')
37
38class ApplicantsAuthTab(PrimaryNavTab):
39    """Applicants tab in primary navigation.
40    """
41    grok.context(IKofaObject)
42    grok.order(3)
43    grok.require('waeup.viewApplicantsTab')
44    pnav = 3
45    tab_title = _(u'Applicants')
46
47    @property
48    def link_target(self):
49        return self.view.application_url('applicants')
50
51class ApplicantsAnonTab(ApplicantsAuthTab):
52    """Applicants tab in primary navigation.
53
54    Display tab only for anonymous. Authenticated users can call the
55    form from the user navigation bar.
56    """
57    grok.require('waeup.Anonymous')
58    tab_title = _(u'Application')
59
60    # Also zope.manager has role Anonymous.
61    # To avoid displaying this tab, we have to check the principal id too.
62    @property
63    def link_target(self):
64        if self.request.principal.id == 'zope.anybody':
65            return self.view.application_url('applicants')
66        return
67
68class MyApplicationDataTab(PrimaryStudentNavTab):
69    """MyData-tab in primary navigation.
70    """
71    grok.order(3)
72    grok.require('waeup.viewMyApplicationDataTab')
73    pnav = 3
74    tab_title = _(u'My Data')
75
76    @property
77    def link_target(self):
78        try:
79            container, application_number = self.request.principal.id.split('_')
80        except ValueError:
81            return
82        rel_link = '/applicants/%s/%s' % (container, application_number)
83        return self.view.application_url() + rel_link
84
85class ApplicantsRootSearchActionButton(ManageActionButton):
86    grok.order(1)
87    grok.context(IApplicantsRoot)
88    grok.view(ApplicantsRootPage)
89    grok.require('waeup.viewApplication')
90    text = _('Find applicants')
91    icon = 'actionicon_search.png'
92    target = '@@search'
93
94class ApplicantsRootManageActionButton(ManageActionButton):
95    grok.order(2)
96    grok.context(IApplicantsRoot)
97    grok.view(ApplicantsRootPage)
98    grok.require('waeup.manageApplication')
99    text = _('Manage application section')
100
101class ApplicantRegisterActionButton(ManageActionButton):
102    grok.order(1)
103    grok.context(IApplicantsContainer)
104    grok.view(ApplicantsContainerPage)
105    grok.require('waeup.Anonymous')
106    icon = 'actionicon_login.png'
107    text = _('Register for application')
108    target = 'register'
109
110class ApplicantsContainerAddActionButton(AddActionButton):
111    grok.order(1)
112    grok.context(IApplicantsContainer)
113    grok.view(ApplicantsContainerManageFormPage)
114    grok.require('waeup.manageApplication')
115    text = _('Add applicant')
116    target = 'addapplicant'
117
118class ApplicantsContainerStatisticsActionButton(ManageActionButton):
119    grok.order(2)
120    grok.context(IApplicantsContainer)
121    grok.view(ApplicantsContainerManageFormPage)
122    grok.require('waeup.viewApplicationStatistics')
123    icon = 'actionicon_statistics.png'
124    text = _('Container statistics')
125    target = 'statistics'
126
127class ApplicantsContainerStatisticsActionButton2(
128        ApplicantsContainerStatisticsActionButton):
129    grok.order(3)
130    grok.view(ApplicantsContainerPage)
131
132class ApplicantsContainerManageActionButton(ManageActionButton):
133    grok.order(2)
134    grok.context(IApplicantsContainer)
135    grok.view(ApplicantsContainerPage)
136    grok.require('waeup.manageApplication')
137    text = _('Manage container')
138    target = 'manage'
139
140class ExportApplicantsActionButton(ManageActionButton):
141    """ 'Export applicants' button for faculties.
142    """
143    grok.context(IApplicantsContainer)
144    grok.view(ApplicantsContainerPage)
145    grok.require('waeup.manageApplication')
146    icon = 'actionicon_down.png'
147    text = _('Export applicants')
148    target = 'exports'
149    grok.order(4)
150
151class ApplicantsRootCreateStudentsActionButton(ManageActionButton):
152    grok.order(3)
153    grok.context(IApplicantsRoot)
154    grok.view(ApplicantsRootPage)
155    grok.require('waeup.managePortal')
156    icon = 'actionicon_entrance.png'
157    text = _('Create students')
158    target ='createallstudents'
159
160class ApplicantsContainerCreateStudentsActionButton(ManageActionButton):
161    grok.order(1)
162    grok.context(IApplicantsContainer)
163    grok.view(ApplicantsStatisticsPage)
164    grok.require('waeup.managePortal')
165    icon = 'actionicon_entrance.png'
166    text = _('Create students')
167    target ='createallstudents'
168
169class ApplicantViewActionButton(ManageActionButton):
170    grok.context(IApplicant)
171    grok.view(ApplicantManageFormPage)
172    grok.require('waeup.viewApplication')
173    icon = 'actionicon_view.png'
174    text = _('View application record')
175    target = 'index'
176
177class ApplicantManageActionButton(ManageActionButton):
178    grok.order(1)
179    grok.context(IApplicant)
180    grok.view(ApplicantDisplayFormPage)
181    grok.require('waeup.manageApplication')
182    text = _('Manage application record')
183    target = 'manage'
184
185class ApplicantEditActionButton(ManageActionButton):
186    grok.order(2)
187    grok.context(IApplicant)
188    grok.view(ApplicantDisplayFormPage)
189    grok.require('waeup.handleApplication')
190    text = _('Edit application record')
191    target ='edit'
192
193    @property
194    def target_url(self):
195        """Get a URL to the target...
196        """
197        if self.context.locked or (
198            self.context.__parent__.expired and
199            self.context.__parent__.strict_deadline):
200            return
201        return self.view.url(self.view.context, self.target)
202
203class PDFActionButton(ManageActionButton):
204    grok.order(3)
205    grok.context(IApplicant)
206    grok.require('waeup.viewApplication')
207    icon = 'actionicon_pdf.png'
208    text = _('Download application slip')
209    target = 'application_slip.pdf'
210
211    @property
212    def target_url(self):
213        """Get a URL to the target...
214        """
215        if self.context.state in ('initialized', 'started', 'paid'):
216            return
217        return self.view.url(self.view.context, self.target)
218
219class StudentCreateActionButton(ManageActionButton):
220    grok.order(4)
221    grok.context(IApplicant)
222    grok.require('waeup.manageApplication')
223    icon = 'actionicon_entrance.png'
224    text = _('Create student record')
225    target ='createstudent'
226
227    @property
228    def target_url(self):
229        """Get a URL to the target...
230        """
231        if self.context.state != 'admitted':
232            return
233        return self.view.url(self.view.context, self.target)
234
235class PaymentReceiptActionButton(ManageActionButton):
236    grok.order(9) # This button should always be the last one.
237    grok.context(IApplicantOnlinePayment)
238    grok.view(OnlinePaymentDisplayFormPage)
239    grok.require('waeup.viewApplication')
240    icon = 'actionicon_pdf.png'
241    text = _('Download payment slip')
242    target = 'payment_slip.pdf'
243
244    @property
245    def target_url(self):
246        #if self.context.p_state != 'paid':
247        #    return ''
248        return self.view.url(self.view.context, self.target)
249
250class ApprovePaymentActionButton(ManageActionButton):
251    grok.order(8)
252    grok.context(IApplicantOnlinePayment)
253    grok.view(OnlinePaymentDisplayFormPage)
254    grok.require('waeup.managePortal')
255    icon = 'actionicon_accept.png'
256    text = _('Approve payment')
257    target = 'approve'
258
259    @property
260    def target_url(self):
261        if self.context.p_state == 'paid':
262            return ''
263        return self.view.url(self.view.context, self.target)
Note: See TracBrowser for help on using the repository browser.