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

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

Add ViewApplicationStatistics?.

  • Property svn:keywords set to Id
File size: 7.0 KB
Line 
1## $Id: viewlets.py 8565 2012-05-30 20:05:07Z 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 hurry.workflow.interfaces import IWorkflowState
20from waeup.kofa.interfaces import IKofaObject
21from waeup.kofa.students.viewlets import PrimaryStudentNavTab
22from waeup.kofa.browser.viewlets import ManageActionButton, PrimaryNavTab
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 = _('Search 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 ApplicantsContainerStatisticsActionButton(ManageActionButton):
111    grok.order(1)
112    grok.context(IApplicantsContainer)
113    grok.view(ApplicantsContainerManageFormPage)
114    grok.require('waeup.viewApplicationStatistics')
115    icon = 'actionicon_statistics.png'
116    text = _('Container statistics')
117    target = 'statistics'
118
119class ApplicantsContainerStatisticsActionButton2(ApplicantsContainerStatisticsActionButton):
120    grok.order(3)
121    grok.view(ApplicantsContainerPage)
122
123class ApplicantsContainerManageActionButton(ManageActionButton):
124    grok.order(2)
125    grok.context(IApplicantsContainer)
126    grok.view(ApplicantsContainerPage)
127    grok.require('waeup.manageApplication')
128    text = _('Manage container')
129    target = 'manage'
130
131class ApplicantViewActionButton(ManageActionButton):
132    grok.context(IApplicant)
133    grok.view(ApplicantManageFormPage)
134    grok.require('waeup.viewApplication')
135    icon = 'actionicon_view.png'
136    text = _('View application record')
137    target = 'index'
138
139class ApplicantManageActionButton(ManageActionButton):
140    grok.order(1)
141    grok.context(IApplicant)
142    grok.view(ApplicantDisplayFormPage)
143    grok.require('waeup.manageApplication')
144    text = _('Manage application record')
145    target = 'manage'
146
147class ApplicantEditActionButton(ManageActionButton):
148    grok.order(2)
149    grok.context(IApplicant)
150    grok.view(ApplicantDisplayFormPage)
151    grok.require('waeup.handleApplication')
152    text = _('Edit application record')
153    target ='edit'
154
155    @property
156    def target_url(self):
157        """Get a URL to the target...
158        """
159        if self.context.locked:
160            return
161        return self.view.url(self.view.context, self.target)
162
163class PDFActionButton(ManageActionButton):
164    grok.order(3)
165    grok.context(IApplicant)
166    grok.require('waeup.viewApplication')
167    icon = 'actionicon_pdf.png'
168    text = _('Download application slip')
169    target = 'application_slip.pdf'
170
171class StudentCreateActionButton(ManageActionButton):
172    grok.order(4)
173    grok.context(IApplicant)
174    grok.require('waeup.manageApplication')
175    icon = 'actionicon_entrance.png'
176    text = _('Create student record')
177    target ='createstudent'
178
179    @property
180    def target_url(self):
181        """Get a URL to the target...
182        """
183        if IWorkflowState(self.context).getState() != 'admitted':
184            return
185        return self.view.url(self.view.context, self.target)
186
187class PaymentReceiptActionButton(ManageActionButton):
188    grok.order(1)
189    grok.context(IApplicantOnlinePayment)
190    grok.view(OnlinePaymentDisplayFormPage)
191    grok.require('waeup.viewApplication')
192    icon = 'actionicon_pdf.png'
193    text = _('Download payment slip')
194    target = 'payment_slip.pdf'
195
196    @property
197    def target_url(self):
198        #if self.context.p_state != 'paid':
199        #    return ''
200        return self.view.url(self.view.context, self.target)
201
202class ApprovePaymentActionButton(ManageActionButton):
203    grok.order(2)
204    grok.context(IApplicantOnlinePayment)
205    grok.view(OnlinePaymentDisplayFormPage)
206    grok.require('waeup.managePortal')
207    icon = 'actionicon_accept.png'
208    text = _('Approve payment')
209    target = 'approve'
210
211    @property
212    def target_url(self):
213        if self.context.p_state == 'paid':
214            return ''
215        return self.view.url(self.view.context, self.target)
Note: See TracBrowser for help on using the repository browser.