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

Last change on this file since 15309 was 14948, checked in by Henrik Bettermann, 7 years ago

Add CreateStudents permission and StudentsCreator role.

  • Property svn:keywords set to Id
File size: 9.8 KB
RevLine 
[7438]1## $Id: viewlets.py 14948 2018-02-08 06:52:37Z 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,
[8563]25    IApplicantOnlinePayment
[7438]26    )
[7811]27from waeup.kofa.applicants.browser import (
[7438]28    ApplicantsRootPage, ApplicantsContainerPage, ApplicantManageFormPage,
[8563]29    ApplicantDisplayFormPage, OnlinePaymentDisplayFormPage,
30    ApplicantsContainerManageFormPage, ApplicantsStatisticsPage
[7438]31    )
32
[7811]33from waeup.kofa.interfaces import MessageFactory as _
[7674]34
[7819]35grok.context(IKofaObject) # Make IKofaObject the default context
[7438]36grok.templatedir('browser_templates')
37
38class ApplicantsAuthTab(PrimaryNavTab):
39    """Applicants tab in primary navigation.
40    """
[7819]41    grok.context(IKofaObject)
[7438]42    grok.order(3)
43    grok.require('waeup.viewApplicantsTab')
44    pnav = 3
[7674]45    tab_title = _(u'Applicants')
[7438]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')
[7674]58    tab_title = _(u'Application')
[7438]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
[7714]74    tab_title = _(u'My Data')
[7438]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
[8406]85class ApplicantsRootSearchActionButton(ManageActionButton):
[8404]86    grok.order(1)
87    grok.context(IApplicantsRoot)
88    grok.view(ApplicantsRootPage)
89    grok.require('waeup.viewApplication')
[10644]90    text = _('Find applicants')
[8404]91    icon = 'actionicon_search.png'
92    target = '@@search'
93
[8406]94class ApplicantsRootManageActionButton(ManageActionButton):
[8404]95    grok.order(2)
[7438]96    grok.context(IApplicantsRoot)
97    grok.view(ApplicantsRootPage)
98    grok.require('waeup.manageApplication')
[13076]99    text = _('Manage applicants section')
[7438]100
101class ApplicantRegisterActionButton(ManageActionButton):
[8563]102    grok.order(1)
[7438]103    grok.context(IApplicantsContainer)
104    grok.view(ApplicantsContainerPage)
105    grok.require('waeup.Anonymous')
106    icon = 'actionicon_login.png'
[7714]107    text = _('Register for application')
[7438]108    target = 'register'
109
[8684]110class ApplicantsContainerAddActionButton(AddActionButton):
[8563]111    grok.order(1)
112    grok.context(IApplicantsContainer)
113    grok.view(ApplicantsContainerManageFormPage)
[8684]114    grok.require('waeup.manageApplication')
115    text = _('Add applicant')
116    target = 'addapplicant'
117
[13218]118class ApplicantsContainerPrefillActionButton(ManageActionButton):
[8684]119    grok.order(2)
120    grok.context(IApplicantsContainer)
121    grok.view(ApplicantsContainerManageFormPage)
[13217]122    grok.require('waeup.manageApplication')
123    icon = 'actionicon_bucketfill.png'
124    text = _('Pre-fill container')
125    target = 'prefill'
126
[13218]127class ApplicantsContainerPurgeActionButton(ManageActionButton):
[13217]128    grok.order(3)
129    grok.context(IApplicantsContainer)
130    grok.view(ApplicantsContainerManageFormPage)
[13218]131    grok.require('waeup.manageApplication')
132    icon = 'actionicon_sweep.png'
133    text = _('Purge container')
134    target = 'purge'
135
136class ApplicantsContainerStatisticsActionButton(ManageActionButton):
137    grok.order(4)
138    grok.context(IApplicantsContainer)
139    grok.view(ApplicantsContainerManageFormPage)
[8565]140    grok.require('waeup.viewApplicationStatistics')
[8563]141    icon = 'actionicon_statistics.png'
142    text = _('Container statistics')
143    target = 'statistics'
144
[9759]145class ApplicantsContainerStatisticsActionButton2(
146        ApplicantsContainerStatisticsActionButton):
[13218]147    grok.order(5)
[8563]148    grok.view(ApplicantsContainerPage)
149
150class ApplicantsContainerManageActionButton(ManageActionButton):
151    grok.order(2)
152    grok.context(IApplicantsContainer)
153    grok.view(ApplicantsContainerPage)
154    grok.require('waeup.manageApplication')
155    text = _('Manage container')
156    target = 'manage'
157
[10655]158class ExportApplicantsActionButton(ManageActionButton):
[13951]159    """ 'Export data' button for faculties.
[10655]160    """
161    grok.context(IApplicantsContainer)
162    grok.view(ApplicantsContainerPage)
163    grok.require('waeup.manageApplication')
164    icon = 'actionicon_down.png'
[13951]165    text = _('Export application data')
[10655]166    target = 'exports'
167    grok.order(4)
168
[14934]169creation_warning = _(
170    "'The creation process may take a considerably long time "
171    "depending on the number of student records to be created "
172    "(appr. 0.5s per student). "
173    "All users will be logged out and the portal will be in "
[14935]174    "maintenance mode during record creation. You will be automatically "
175    "logged in when the creation process is finished. "
176    "Do you really want to start now?'")
[14934]177
[9901]178class ApplicantsRootCreateStudentsActionButton(ManageActionButton):
[9900]179    grok.order(3)
180    grok.context(IApplicantsRoot)
181    grok.view(ApplicantsRootPage)
[14948]182    grok.require('waeup.createStudents')
[9759]183    icon = 'actionicon_entrance.png'
[9901]184    text = _('Create students')
[9759]185    target ='createallstudents'
186
[11874]187    @property
[14934]188    def onclick(self):
189        return "return window.confirm(%s);" % creation_warning
[11874]190
[9901]191class ApplicantsContainerCreateStudentsActionButton(ManageActionButton):
[13101]192    grok.order(5)
[9900]193    grok.context(IApplicantsContainer)
[13101]194    grok.view(ApplicantsContainerPage)
[14948]195    grok.require('waeup.createStudents')
[9901]196    icon = 'actionicon_entrance.png'
197    text = _('Create students')
198    target ='createallstudents'
[9900]199
[11874]200    @property
[14934]201    def onclick(self):
202        return "return window.confirm(%s);" % creation_warning
[11874]203
[7438]204class ApplicantViewActionButton(ManageActionButton):
205    grok.context(IApplicant)
206    grok.view(ApplicantManageFormPage)
207    grok.require('waeup.viewApplication')
208    icon = 'actionicon_view.png'
[7714]209    text = _('View application record')
[7438]210    target = 'index'
211
212class ApplicantManageActionButton(ManageActionButton):
213    grok.order(1)
214    grok.context(IApplicant)
215    grok.view(ApplicantDisplayFormPage)
216    grok.require('waeup.manageApplication')
[7714]217    text = _('Manage application record')
[7438]218    target = 'manage'
219
220class ApplicantEditActionButton(ManageActionButton):
221    grok.order(2)
222    grok.context(IApplicant)
223    grok.view(ApplicantDisplayFormPage)
224    grok.require('waeup.handleApplication')
[7714]225    text = _('Edit application record')
[7438]226    target ='edit'
227
228    @property
229    def target_url(self):
230        """Get a URL to the target...
231        """
[8665]232        if self.context.locked or (
233            self.context.__parent__.expired and
234            self.context.__parent__.strict_deadline):
[7438]235            return
236        return self.view.url(self.view.context, self.target)
237
238class PDFActionButton(ManageActionButton):
239    grok.order(3)
240    grok.context(IApplicant)
241    grok.require('waeup.viewApplication')
[10802]242    grok.name('pdfactionbutton')
[7438]243    icon = 'actionicon_pdf.png'
[7714]244    text = _('Download application slip')
[7438]245    target = 'application_slip.pdf'
246
[8666]247    @property
248    def target_url(self):
249        """Get a URL to the target...
250        """
[11599]251        if self.context.state in ('initialized', 'started', 'paid') \
252            or self.context.special:
[8666]253            return
254        return self.view.url(self.view.context, self.target)
255
[7438]256class StudentCreateActionButton(ManageActionButton):
257    grok.order(4)
258    grok.context(IApplicant)
[14948]259    grok.require('waeup.createStudents')
[7438]260    icon = 'actionicon_entrance.png'
[13108]261    text = _('Create student')
[7438]262    target ='createstudent'
263
264    @property
265    def target_url(self):
266        """Get a URL to the target...
267        """
[8666]268        if self.context.state != 'admitted':
[7438]269            return
270        return self.view.url(self.view.context, self.target)
271
272class PaymentReceiptActionButton(ManageActionButton):
[9070]273    grok.order(9) # This button should always be the last one.
[7438]274    grok.context(IApplicantOnlinePayment)
275    grok.view(OnlinePaymentDisplayFormPage)
276    grok.require('waeup.viewApplication')
277    icon = 'actionicon_pdf.png'
[8262]278    text = _('Download payment slip')
279    target = 'payment_slip.pdf'
[7438]280
281    @property
282    def target_url(self):
[8262]283        #if self.context.p_state != 'paid':
284        #    return ''
[7438]285        return self.view.url(self.view.context, self.target)
286
[8420]287class ApprovePaymentActionButton(ManageActionButton):
[9070]288    grok.order(8)
[7438]289    grok.context(IApplicantOnlinePayment)
290    grok.view(OnlinePaymentDisplayFormPage)
[8420]291    grok.require('waeup.managePortal')
[8435]292    icon = 'actionicon_accept.png'
[8420]293    text = _('Approve payment')
294    target = 'approve'
[7438]295
296    @property
297    def target_url(self):
[8243]298        if self.context.p_state == 'paid':
[7438]299            return ''
[7811]300        return self.view.url(self.view.context, self.target)
Note: See TracBrowser for help on using the repository browser.