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

Last change on this file since 17931 was 17850, checked in by Henrik Bettermann, 4 months ago

Add ExportApplication permission which allows bursary officers
to access the application section and export application data.

  • Property svn:keywords set to Id
File size: 11.8 KB
RevLine 
[7438]1## $Id: viewlets.py 17850 2024-07-16 20:47:30Z 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
[7819]19from waeup.kofa.interfaces import IKofaObject
[7811]20from waeup.kofa.students.viewlets import PrimaryStudentNavTab
[8684]21from waeup.kofa.browser.viewlets import (
22    ManageActionButton, PrimaryNavTab, AddActionButton)
[7811]23from waeup.kofa.applicants.interfaces import (
[7438]24    IApplicant, IApplicantsRoot, IApplicantsContainer,
[16058]25    IApplicantOnlinePayment, IApplicantRefereeReport
[7438]26    )
[7811]27from waeup.kofa.applicants.browser import (
[7438]28    ApplicantsRootPage, ApplicantsContainerPage, ApplicantManageFormPage,
[8563]29    ApplicantDisplayFormPage, OnlinePaymentDisplayFormPage,
[16058]30    ApplicantsContainerManageFormPage, ApplicantsStatisticsPage,
31    RefereeReportDisplayFormPage
[7438]32    )
33
[7811]34from waeup.kofa.interfaces import MessageFactory as _
[7674]35
[7819]36grok.context(IKofaObject) # Make IKofaObject the default context
[7438]37grok.templatedir('browser_templates')
38
39class ApplicantsAuthTab(PrimaryNavTab):
40    """Applicants tab in primary navigation.
41    """
[7819]42    grok.context(IKofaObject)
[7438]43    grok.order(3)
44    grok.require('waeup.viewApplicantsTab')
45    pnav = 3
[7674]46    tab_title = _(u'Applicants')
[7438]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')
[7674]59    tab_title = _(u'Application')
[7438]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
[7714]75    tab_title = _(u'My Data')
[7438]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
[8406]86class ApplicantsRootSearchActionButton(ManageActionButton):
[8404]87    grok.order(1)
88    grok.context(IApplicantsRoot)
89    grok.view(ApplicantsRootPage)
90    grok.require('waeup.viewApplication')
[10644]91    text = _('Find applicants')
[8404]92    icon = 'actionicon_search.png'
93    target = '@@search'
94
[8406]95class ApplicantsRootManageActionButton(ManageActionButton):
[8404]96    grok.order(2)
[7438]97    grok.context(IApplicantsRoot)
98    grok.view(ApplicantsRootPage)
99    grok.require('waeup.manageApplication')
[13076]100    text = _('Manage applicants section')
[7438]101
102class ApplicantRegisterActionButton(ManageActionButton):
[8563]103    grok.order(1)
[7438]104    grok.context(IApplicantsContainer)
105    grok.view(ApplicantsContainerPage)
106    grok.require('waeup.Anonymous')
107    icon = 'actionicon_login.png'
[7714]108    text = _('Register for application')
[7438]109    target = 'register'
110
[8684]111class ApplicantsContainerAddActionButton(AddActionButton):
[8563]112    grok.order(1)
113    grok.context(IApplicantsContainer)
114    grok.view(ApplicantsContainerManageFormPage)
[8684]115    grok.require('waeup.manageApplication')
116    text = _('Add applicant')
117    target = 'addapplicant'
118
[13218]119class ApplicantsContainerPrefillActionButton(ManageActionButton):
[8684]120    grok.order(2)
121    grok.context(IApplicantsContainer)
122    grok.view(ApplicantsContainerManageFormPage)
[13217]123    grok.require('waeup.manageApplication')
124    icon = 'actionicon_bucketfill.png'
125    text = _('Pre-fill container')
126    target = 'prefill'
127
[13218]128class ApplicantsContainerPurgeActionButton(ManageActionButton):
[13217]129    grok.order(3)
130    grok.context(IApplicantsContainer)
131    grok.view(ApplicantsContainerManageFormPage)
[13218]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)
[8565]141    grok.require('waeup.viewApplicationStatistics')
[8563]142    icon = 'actionicon_statistics.png'
143    text = _('Container statistics')
144    target = 'statistics'
145
[9759]146class ApplicantsContainerStatisticsActionButton2(
147        ApplicantsContainerStatisticsActionButton):
[13218]148    grok.order(5)
[8563]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
[10655]159class ExportApplicantsActionButton(ManageActionButton):
[13951]160    """ 'Export data' button for faculties.
[10655]161    """
162    grok.context(IApplicantsContainer)
163    grok.view(ApplicantsContainerPage)
[17850]164    grok.require('waeup.exportApplication')
[10655]165    icon = 'actionicon_down.png'
[13951]166    text = _('Export application data')
[10655]167    target = 'exports'
168    grok.order(4)
169
[14934]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 "
[14935]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?'")
[14934]178
[9901]179class ApplicantsRootCreateStudentsActionButton(ManageActionButton):
[9900]180    grok.order(3)
181    grok.context(IApplicantsRoot)
182    grok.view(ApplicantsRootPage)
[14948]183    grok.require('waeup.createStudents')
[9759]184    icon = 'actionicon_entrance.png'
[9901]185    text = _('Create students')
[9759]186    target ='createallstudents'
187
[11874]188    @property
[14934]189    def onclick(self):
190        return "return window.confirm(%s);" % creation_warning
[11874]191
[9901]192class ApplicantsContainerCreateStudentsActionButton(ManageActionButton):
[13101]193    grok.order(5)
[9900]194    grok.context(IApplicantsContainer)
[13101]195    grok.view(ApplicantsContainerPage)
[14948]196    grok.require('waeup.createStudents')
[9901]197    icon = 'actionicon_entrance.png'
198    text = _('Create students')
199    target ='createallstudents'
[9900]200
[11874]201    @property
[14934]202    def onclick(self):
203        return "return window.confirm(%s);" % creation_warning
[11874]204
[7438]205class ApplicantViewActionButton(ManageActionButton):
206    grok.context(IApplicant)
207    grok.view(ApplicantManageFormPage)
208    grok.require('waeup.viewApplication')
209    icon = 'actionicon_view.png'
[7714]210    text = _('View application record')
[7438]211    target = 'index'
212
213class ApplicantManageActionButton(ManageActionButton):
214    grok.order(1)
215    grok.context(IApplicant)
216    grok.view(ApplicantDisplayFormPage)
217    grok.require('waeup.manageApplication')
[7714]218    text = _('Manage application record')
[7438]219    target = 'manage'
220
221class ApplicantEditActionButton(ManageActionButton):
222    grok.order(2)
223    grok.context(IApplicant)
224    grok.view(ApplicantDisplayFormPage)
225    grok.require('waeup.handleApplication')
[7714]226    text = _('Edit application record')
[7438]227    target ='edit'
228
229    @property
230    def target_url(self):
231        """Get a URL to the target...
232        """
[8665]233        if self.context.locked or (
234            self.context.__parent__.expired and
235            self.context.__parent__.strict_deadline):
[7438]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')
[10802]243    grok.name('pdfactionbutton')
[16231]244    grok.view(ApplicantDisplayFormPage)
[7438]245    icon = 'actionicon_pdf.png'
[7714]246    text = _('Download application slip')
[7438]247    target = 'application_slip.pdf'
248
[8666]249    @property
250    def target_url(self):
251        """Get a URL to the target...
252        """
[11599]253        if self.context.state in ('initialized', 'started', 'paid') \
254            or self.context.special:
[8666]255            return
256        return self.view.url(self.view.context, self.target)
257
[7438]258class StudentCreateActionButton(ManageActionButton):
259    grok.order(4)
260    grok.context(IApplicant)
[14948]261    grok.require('waeup.createStudents')
[7438]262    icon = 'actionicon_entrance.png'
[13108]263    text = _('Create student')
[7438]264    target ='createstudent'
265
266    @property
267    def target_url(self):
268        """Get a URL to the target...
269        """
[8666]270        if self.context.state != 'admitted':
[7438]271            return
272        return self.view.url(self.view.context, self.target)
273
[16214]274class RemindRefereesActionButton(ManageActionButton):
275    grok.order(5)
276    grok.context(IApplicant)
277    grok.require('waeup.manageApplication')
[16231]278    grok.view(ApplicantDisplayFormPage)
[16214]279    icon = 'actionicon_alarm.png'
280    text = _('Remind referees')
281    target ='remind_referees'
282
283    @property
284    def onclick(self):
285        return "return window.confirm(%s);" % _(
286            "'Those referees, who have not yet submitted their report, will be reminded by email. Are you sure?'")
287
288    @property
289    def target_url(self):
290        """Get a URL to the target...
291        """
292        if self.context.state != 'submitted':
293            return
294        if not self.context.referees:
295            return
296        return self.view.url(self.view.context, self.target)
297
[16231]298class ContactActionButton(ManageActionButton):
299    grok.order(6)
300    grok.context(IApplicant)
301    grok.view(ApplicantDisplayFormPage)
302    grok.require('waeup.viewApplication')
303    icon = 'actionicon_mail.png'
304    text = _('Send email')
305    target = 'contactapplicant'
306
[7438]307class PaymentReceiptActionButton(ManageActionButton):
[9070]308    grok.order(9) # This button should always be the last one.
[7438]309    grok.context(IApplicantOnlinePayment)
310    grok.view(OnlinePaymentDisplayFormPage)
311    grok.require('waeup.viewApplication')
312    icon = 'actionicon_pdf.png'
[8262]313    text = _('Download payment slip')
314    target = 'payment_slip.pdf'
[7438]315
316    @property
317    def target_url(self):
[8262]318        #if self.context.p_state != 'paid':
319        #    return ''
[7438]320        return self.view.url(self.view.context, self.target)
321
[8420]322class ApprovePaymentActionButton(ManageActionButton):
[17217]323    grok.order(20)
[7438]324    grok.context(IApplicantOnlinePayment)
325    grok.view(OnlinePaymentDisplayFormPage)
[8420]326    grok.require('waeup.managePortal')
[8435]327    icon = 'actionicon_accept.png'
[8420]328    text = _('Approve payment')
329    target = 'approve'
[7438]330
331    @property
332    def target_url(self):
[15843]333        if self.context.p_state in ('paid', 'waived', 'scholarship'):
[7438]334            return ''
[7811]335        return self.view.url(self.view.context, self.target)
[16059]336
337class ReportSlipActionButton(ManageActionButton):
338    grok.order(1)
339    grok.context(IApplicantRefereeReport)
340    grok.view(RefereeReportDisplayFormPage)
341    grok.require('waeup.manageApplication')
342    icon = 'actionicon_pdf.png'
343    text = _('Download referee report slip')
344    target = 'referee_report_slip.pdf'
345
346    @property
347    def target_url(self):
348        return self.view.url(self.view.context, self.target)
349
350deletion_warning = _(
351    "'The report will be irrevocably deleted. Are you sure?'")
352
353class ReportRemoveActionButton(ManageActionButton):
354    grok.order(2)
355    grok.context(IApplicantRefereeReport)
356    grok.view(RefereeReportDisplayFormPage)
357    grok.require('waeup.manageApplication')
358    icon = 'actionicon_reject.png'
359    text = _('Delete referee report')
360    target = 'remove'
361
362    @property
363    def onclick(self):
364        return "return window.confirm(%s);" % deletion_warning
Note: See TracBrowser for help on using the repository browser.