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

Last change on this file since 16064 was 16059, checked in by Henrik Bettermann, 5 years ago

Improve referee reports.

  • Property svn:keywords set to Id
File size: 10.7 KB
Line 
1## $Id: viewlets.py 16059 2020-04-20 06:30:54Z 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, IApplicantRefereeReport
26    )
27from waeup.kofa.applicants.browser import (
28    ApplicantsRootPage, ApplicantsContainerPage, ApplicantManageFormPage,
29    ApplicantDisplayFormPage, OnlinePaymentDisplayFormPage,
30    ApplicantsContainerManageFormPage, ApplicantsStatisticsPage,
31    RefereeReportDisplayFormPage
32    )
33
34from waeup.kofa.interfaces import MessageFactory as _
35
36grok.context(IKofaObject) # Make IKofaObject the default context
37grok.templatedir('browser_templates')
38
39class ApplicantsAuthTab(PrimaryNavTab):
40    """Applicants tab in primary navigation.
41    """
42    grok.context(IKofaObject)
43    grok.order(3)
44    grok.require('waeup.viewApplicantsTab')
45    pnav = 3
46    tab_title = _(u'Applicants')
47
48    @property
49    def link_target(self):
50        return self.view.application_url('applicants')
51
52class ApplicantsAnonTab(ApplicantsAuthTab):
53    """Applicants tab in primary navigation.
54
55    Display tab only for anonymous. Authenticated users can call the
56    form from the user navigation bar.
57    """
58    grok.require('waeup.Anonymous')
59    tab_title = _(u'Application')
60
61    # Also zope.manager has role Anonymous.
62    # To avoid displaying this tab, we have to check the principal id too.
63    @property
64    def link_target(self):
65        if self.request.principal.id == 'zope.anybody':
66            return self.view.application_url('applicants')
67        return
68
69class MyApplicationDataTab(PrimaryStudentNavTab):
70    """MyData-tab in primary navigation.
71    """
72    grok.order(3)
73    grok.require('waeup.viewMyApplicationDataTab')
74    pnav = 3
75    tab_title = _(u'My Data')
76
77    @property
78    def link_target(self):
79        try:
80            container, application_number = self.request.principal.id.split('_')
81        except ValueError:
82            return
83        rel_link = '/applicants/%s/%s' % (container, application_number)
84        return self.view.application_url() + rel_link
85
86class ApplicantsRootSearchActionButton(ManageActionButton):
87    grok.order(1)
88    grok.context(IApplicantsRoot)
89    grok.view(ApplicantsRootPage)
90    grok.require('waeup.viewApplication')
91    text = _('Find applicants')
92    icon = 'actionicon_search.png'
93    target = '@@search'
94
95class ApplicantsRootManageActionButton(ManageActionButton):
96    grok.order(2)
97    grok.context(IApplicantsRoot)
98    grok.view(ApplicantsRootPage)
99    grok.require('waeup.manageApplication')
100    text = _('Manage applicants section')
101
102class ApplicantRegisterActionButton(ManageActionButton):
103    grok.order(1)
104    grok.context(IApplicantsContainer)
105    grok.view(ApplicantsContainerPage)
106    grok.require('waeup.Anonymous')
107    icon = 'actionicon_login.png'
108    text = _('Register for application')
109    target = 'register'
110
111class ApplicantsContainerAddActionButton(AddActionButton):
112    grok.order(1)
113    grok.context(IApplicantsContainer)
114    grok.view(ApplicantsContainerManageFormPage)
115    grok.require('waeup.manageApplication')
116    text = _('Add applicant')
117    target = 'addapplicant'
118
119class ApplicantsContainerPrefillActionButton(ManageActionButton):
120    grok.order(2)
121    grok.context(IApplicantsContainer)
122    grok.view(ApplicantsContainerManageFormPage)
123    grok.require('waeup.manageApplication')
124    icon = 'actionicon_bucketfill.png'
125    text = _('Pre-fill container')
126    target = 'prefill'
127
128class ApplicantsContainerPurgeActionButton(ManageActionButton):
129    grok.order(3)
130    grok.context(IApplicantsContainer)
131    grok.view(ApplicantsContainerManageFormPage)
132    grok.require('waeup.manageApplication')
133    icon = 'actionicon_sweep.png'
134    text = _('Purge container')
135    target = 'purge'
136
137class ApplicantsContainerStatisticsActionButton(ManageActionButton):
138    grok.order(4)
139    grok.context(IApplicantsContainer)
140    grok.view(ApplicantsContainerManageFormPage)
141    grok.require('waeup.viewApplicationStatistics')
142    icon = 'actionicon_statistics.png'
143    text = _('Container statistics')
144    target = 'statistics'
145
146class ApplicantsContainerStatisticsActionButton2(
147        ApplicantsContainerStatisticsActionButton):
148    grok.order(5)
149    grok.view(ApplicantsContainerPage)
150
151class ApplicantsContainerManageActionButton(ManageActionButton):
152    grok.order(2)
153    grok.context(IApplicantsContainer)
154    grok.view(ApplicantsContainerPage)
155    grok.require('waeup.manageApplication')
156    text = _('Manage container')
157    target = 'manage'
158
159class ExportApplicantsActionButton(ManageActionButton):
160    """ 'Export data' button for faculties.
161    """
162    grok.context(IApplicantsContainer)
163    grok.view(ApplicantsContainerPage)
164    grok.require('waeup.manageApplication')
165    icon = 'actionicon_down.png'
166    text = _('Export application data')
167    target = 'exports'
168    grok.order(4)
169
170creation_warning = _(
171    "'The creation process may take a considerably long time "
172    "depending on the number of student records to be created "
173    "(appr. 0.5s per student). "
174    "All users will be logged out and the portal will be in "
175    "maintenance mode during record creation. You will be automatically "
176    "logged in when the creation process is finished. "
177    "Do you really want to start now?'")
178
179class ApplicantsRootCreateStudentsActionButton(ManageActionButton):
180    grok.order(3)
181    grok.context(IApplicantsRoot)
182    grok.view(ApplicantsRootPage)
183    grok.require('waeup.createStudents')
184    icon = 'actionicon_entrance.png'
185    text = _('Create students')
186    target ='createallstudents'
187
188    @property
189    def onclick(self):
190        return "return window.confirm(%s);" % creation_warning
191
192class ApplicantsContainerCreateStudentsActionButton(ManageActionButton):
193    grok.order(5)
194    grok.context(IApplicantsContainer)
195    grok.view(ApplicantsContainerPage)
196    grok.require('waeup.createStudents')
197    icon = 'actionicon_entrance.png'
198    text = _('Create students')
199    target ='createallstudents'
200
201    @property
202    def onclick(self):
203        return "return window.confirm(%s);" % creation_warning
204
205class ApplicantViewActionButton(ManageActionButton):
206    grok.context(IApplicant)
207    grok.view(ApplicantManageFormPage)
208    grok.require('waeup.viewApplication')
209    icon = 'actionicon_view.png'
210    text = _('View application record')
211    target = 'index'
212
213class ApplicantManageActionButton(ManageActionButton):
214    grok.order(1)
215    grok.context(IApplicant)
216    grok.view(ApplicantDisplayFormPage)
217    grok.require('waeup.manageApplication')
218    text = _('Manage application record')
219    target = 'manage'
220
221class ApplicantEditActionButton(ManageActionButton):
222    grok.order(2)
223    grok.context(IApplicant)
224    grok.view(ApplicantDisplayFormPage)
225    grok.require('waeup.handleApplication')
226    text = _('Edit application record')
227    target ='edit'
228
229    @property
230    def target_url(self):
231        """Get a URL to the target...
232        """
233        if self.context.locked or (
234            self.context.__parent__.expired and
235            self.context.__parent__.strict_deadline):
236            return
237        return self.view.url(self.view.context, self.target)
238
239class PDFActionButton(ManageActionButton):
240    grok.order(3)
241    grok.context(IApplicant)
242    grok.require('waeup.viewApplication')
243    grok.name('pdfactionbutton')
244    icon = 'actionicon_pdf.png'
245    text = _('Download application slip')
246    target = 'application_slip.pdf'
247
248    @property
249    def target_url(self):
250        """Get a URL to the target...
251        """
252        if self.context.state in ('initialized', 'started', 'paid') \
253            or self.context.special:
254            return
255        return self.view.url(self.view.context, self.target)
256
257class StudentCreateActionButton(ManageActionButton):
258    grok.order(4)
259    grok.context(IApplicant)
260    grok.require('waeup.createStudents')
261    icon = 'actionicon_entrance.png'
262    text = _('Create student')
263    target ='createstudent'
264
265    @property
266    def target_url(self):
267        """Get a URL to the target...
268        """
269        if self.context.state != 'admitted':
270            return
271        return self.view.url(self.view.context, self.target)
272
273class PaymentReceiptActionButton(ManageActionButton):
274    grok.order(9) # This button should always be the last one.
275    grok.context(IApplicantOnlinePayment)
276    grok.view(OnlinePaymentDisplayFormPage)
277    grok.require('waeup.viewApplication')
278    icon = 'actionicon_pdf.png'
279    text = _('Download payment slip')
280    target = 'payment_slip.pdf'
281
282    @property
283    def target_url(self):
284        #if self.context.p_state != 'paid':
285        #    return ''
286        return self.view.url(self.view.context, self.target)
287
288class ApprovePaymentActionButton(ManageActionButton):
289    grok.order(8)
290    grok.context(IApplicantOnlinePayment)
291    grok.view(OnlinePaymentDisplayFormPage)
292    grok.require('waeup.managePortal')
293    icon = 'actionicon_accept.png'
294    text = _('Approve payment')
295    target = 'approve'
296
297    @property
298    def target_url(self):
299        if self.context.p_state in ('paid', 'waived', 'scholarship'):
300            return ''
301        return self.view.url(self.view.context, self.target)
302
303class ReportSlipActionButton(ManageActionButton):
304    grok.order(1)
305    grok.context(IApplicantRefereeReport)
306    grok.view(RefereeReportDisplayFormPage)
307    grok.require('waeup.manageApplication')
308    icon = 'actionicon_pdf.png'
309    text = _('Download referee report slip')
310    target = 'referee_report_slip.pdf'
311
312    @property
313    def target_url(self):
314        return self.view.url(self.view.context, self.target)
315
316deletion_warning = _(
317    "'The report will be irrevocably deleted. Are you sure?'")
318
319class ReportRemoveActionButton(ManageActionButton):
320    grok.order(2)
321    grok.context(IApplicantRefereeReport)
322    grok.view(RefereeReportDisplayFormPage)
323    grok.require('waeup.manageApplication')
324    icon = 'actionicon_reject.png'
325    text = _('Delete referee report')
326    target = 'remove'
327
328    @property
329    def onclick(self):
330        return "return window.confirm(%s);" % deletion_warning
Note: See TracBrowser for help on using the repository browser.