source: main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/viewlets.py @ 14292

Last change on this file since 14292 was 13856, checked in by Henrik Bettermann, 9 years ago

Add FinancialClearanceOfficer? role. Only Financial Clearance Officers are allowed to print slips with signature fields.

  • Property svn:keywords set to Id
File size: 16.3 KB
Line 
1## $Id: viewlets.py 13856 2016-05-04 07:14:34Z 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##
18
19import grok
20from zope.component import getUtility
21from waeup.kofa.browser.viewlets import ManageActionButton
22from waeup.kofa.students.interfaces import IStudentsUtils
23from waeup.kofa.students.fileviewlets import (
24    StudentFileDisplay, StudentFileUpload, StudentImage)
25from waeup.kofa.students.browser import ExportPDFClearanceSlip
26
27from kofacustom.nigeria.students.interfaces import INigeriaStudent
28from kofacustom.nigeria.students.browser import NigeriaStudentBaseDisplayFormPage
29from kofacustom.nigeria.interfaces import MessageFactory as _
30
31def show_viewlet(viewlet):
32    students_utils = getUtility(IStudentsUtils)
33    if viewlet.__name__ in students_utils.SKIP_UPLOAD_VIEWLETS:
34        return False
35    cm = getattr(viewlet.context,'current_mode', None)
36    if cm is not None and cm.startswith('pg'):
37        return True
38    return False
39
40# Financial Clearance Officer buttons
41
42class StudentFinanciallyClearActionButton(ManageActionButton):
43    grok.order(10)
44    grok.context(INigeriaStudent)
45    grok.view(NigeriaStudentBaseDisplayFormPage)
46    grok.require('waeup.clearStudentFinancially')
47    text = _('Clear student financially')
48    target = 'clear_financially'
49    icon = 'actionicon_accept.png'
50
51    @property
52    def target_url(self):
53        if self.context.financially_cleared_by:
54            return ''
55        return self.view.url(self.view.context, self.target)
56
57class StudentWithdrawFinancialClearanceActionButton(ManageActionButton):
58    grok.order(11)
59    grok.context(INigeriaStudent)
60    grok.view(NigeriaStudentBaseDisplayFormPage)
61    grok.require('waeup.clearStudentFinancially')
62    text = _('Withdraw financial clearance')
63    target = 'withdraw_financial_clearance'
64    icon = 'actionicon_reject.png'
65
66    @property
67    def target_url(self):
68        if not self.context.financially_cleared_by:
69            return ''
70        return self.view.url(self.view.context, self.target)
71
72class FinancialClearanceSlipActionButton(ManageActionButton):
73    grok.order(12)
74    grok.context(INigeriaStudent)
75    grok.view(NigeriaStudentBaseDisplayFormPage)
76    grok.require('waeup.viewStudent')
77    text = _('Download fee payment history')
78    target = 'fee_payment_history.pdf'
79    icon = 'actionicon_pdf.png'
80
81# Acceptance Letter
82
83class AcceptanceLetterDisplay(StudentFileDisplay):
84    """Acceptance Letter display viewlet.
85    """
86    grok.order(2)
87    label = _(u'Acceptance Letter')
88    title = _(u'Acceptance Letter Scan')
89    download_name = u'acc_let'
90
91class AcceptanceLetterSlip(AcceptanceLetterDisplay):
92    grok.view(ExportPDFClearanceSlip)
93
94class AcceptanceLetterUpload(StudentFileUpload):
95    """AcceptanceLetter upload viewlet.
96    """
97    grok.order(2)
98    label = _(u'Acceptance Letter')
99    title = _(u'Acceptance Letter Scan')
100    mus = 1024 * 150
101    download_name = u'acc_let'
102    tab_redirect = '?tab2'
103
104class AcceptanceLetterImage(StudentImage):
105    """Renders acceptance letter scan.
106    """
107    grok.name('acc_let')
108    download_name = u'acc_let'
109
110# LGA Identification
111
112class LGAIdentificationDisplay(StudentFileDisplay):
113    """LGA Identification display viewlet.
114    """
115    grok.order(3)
116    label = _(u'LGA Identification')
117    title = _(u'LGA Identification Scan')
118    download_name = u'lga_ident'
119
120class LGAIdentificationSlip(LGAIdentificationDisplay):
121    grok.view(ExportPDFClearanceSlip)
122
123class LGAIdentificationUpload(StudentFileUpload):
124    """LGA Identification upload viewlet.
125    """
126    grok.order(3)
127    label = _(u'LGA Identification')
128    title = _(u'LGA Identification Scan')
129    mus = 1024 * 150
130    download_name = u'lga_ident'
131
132class LGAIdentificationImage(StudentImage):
133    """Renders LGA Identification scan.
134    """
135    grok.name('lga_ident')
136    download_name = u'lga_ident'
137
138# First Sitting Result
139
140class FirstSittingResultDisplay(StudentFileDisplay):
141    """First Sitting Result display viewlet.
142    """
143    grok.order(4)
144    label = _(u'First Sitting Result')
145    title = _(u'First Sitting Result')
146    download_name = u'fst_sit_scan'
147
148class FirstSittingResultSlip(FirstSittingResultDisplay):
149    grok.view(ExportPDFClearanceSlip)
150
151class FirstSittingResultUpload(StudentFileUpload):
152    """First Sitting Result upload viewlet.
153    """
154    grok.order(4)
155    label = _(u'First Sitting Result')
156    title = _(u'First Sitting Result Scan')
157    mus = 1024 * 150
158    download_name = u'fst_sit_scan'
159
160class FirstSittingResultImage(StudentImage):
161    """Renders First Sitting Result scan.
162    """
163    grok.name('fst_sit_scan')
164    download_name = u'fst_sit_scan'
165
166# Second Sitting Result
167
168class SecondSittingResultDisplay(StudentFileDisplay):
169    """Second Sitting Result display viewlet.
170    """
171    grok.order(5)
172    label = _(u'Second Sitting Result')
173    title = _(u'Second Sitting Result')
174    download_name = u'scd_sit_scan'
175
176class SecondSittingResultSlip(SecondSittingResultDisplay):
177    grok.view(ExportPDFClearanceSlip)
178
179class SecondSittingResultUpload(StudentFileUpload):
180    """Second Sitting Result upload viewlet.
181    """
182    grok.order(5)
183    label = _(u'Second Sitting Result')
184    title = _(u'Second Sitting Result Scan')
185    mus = 1024 * 150
186    download_name = u'scd_sit_scan'
187
188class SecondSittingResultImage(StudentImage):
189    """Renders Second Sitting Result scan.
190    """
191    grok.name('scd_sit_scan')
192    download_name = u'scd_sit_scan'
193
194# Higher Qualification Result
195
196class HigherQualificationResultDisplay(StudentFileDisplay):
197    """Higher Qualification Result display viewlet.
198    """
199    grok.order(6)
200    label = _(u'Higher Qualification Result')
201    title = _(u'Higher Qualification Result')
202    download_name = u'hq_scan'
203
204class HigherQualificationResultSlip(HigherQualificationResultDisplay):
205    grok.view(ExportPDFClearanceSlip)
206
207class HigherQualificationResultUpload(StudentFileUpload):
208    """Higher Qualification Result upload viewlet.
209    """
210    grok.order(6)
211    label = _(u'Higher Qualification Result')
212    title = _(u'Higher Qualification Result Scan')
213    mus = 1024 * 150
214    download_name = u'hq_scan'
215
216class HigherQualificationResultImage(StudentImage):
217    """Renders Higher Qualification Result scan.
218    """
219    grok.name('hq_scan')
220    download_name = u'hq_scan'
221
222# 2nd Higher Qualification Result (PG Students only)
223
224class SecondHigherQualificationResultDisplay(StudentFileDisplay):
225    """Second Higher Qualification Result display viewlet.
226    """
227    grok.order(7)
228    label = _(u'Second Higher Qualification Result')
229    title = _(u'Second Higher Qualification Result')
230    download_name = u'hq_scan2'
231
232class SecondHigherQualificationResultSlip(SecondHigherQualificationResultDisplay):
233    grok.view(ExportPDFClearanceSlip)
234
235class SecondHigherQualificationResultUpload(StudentFileUpload):
236    """Second Higher Qualification Result upload viewlet.
237    """
238    grok.order(7)
239    label = _(u'Second Higher Qualification Result')
240    title = _(u'Second Higher Qualification Result Scan')
241    mus = 1024 * 150
242    download_name = u'hq_scan2'
243
244    @property
245    def show_viewlet(self):
246        return show_viewlet(self)
247
248class SecondHigherQualificationResultImage(StudentImage):
249    """Renders Second Higher Qualification Result scan.
250    """
251    grok.name('hq_scan2')
252    download_name = u'hq_scan2'
253
254# Advanced Level Result
255
256class AdvancedLevelResultDisplay(StudentFileDisplay):
257    """Advanced Level Result display viewlet.
258    """
259    grok.order(8)
260    label = _(u'Advanced Level Result')
261    title = _(u'Advanced Level Result')
262    download_name = u'alr_scan'
263
264class AdvancedLevelResultSlip(AdvancedLevelResultDisplay):
265    grok.view(ExportPDFClearanceSlip)
266
267class AdvancedLevelResultUpload(StudentFileUpload):
268    """Advanced Level Result upload viewlet.
269    """
270    grok.order(8)
271    label = _(u'Advanced Level Result')
272    title = _(u'Advanced Level Result Scan')
273    mus = 1024 * 150
274    download_name = u'alr_scan'
275
276class AdvancedLevelResultImage(StudentImage):
277    """Renders Advanced Level Result scan.
278    """
279    grok.name('alr_scan')
280    download_name = u'alr_scan'
281
282# Certificate
283
284class CertificateDisplay(StudentFileDisplay):
285    """Certificate display viewlet.
286    """
287    grok.order(9)
288    label = _(u'Certificate')
289    title = _(u'Certificate')
290    download_name = u'cert'
291
292class CertificateSlip(CertificateDisplay):
293    grok.view(ExportPDFClearanceSlip)
294
295class CertificateUpload(StudentFileUpload):
296    """Certificate upload viewlet.
297    """
298    grok.order(9)
299    label = _(u'Certificate')
300    title = _(u'Certificate Scan')
301    mus = 1024 * 150
302    download_name = u'cert'
303
304class CertificateImage(StudentImage):
305    """Renders Certificate scan.
306    """
307    grok.name('cert')
308    download_name = u'cert'
309
310# Second Certificate (PG Students only)
311
312class SecondCertificateDisplay(StudentFileDisplay):
313    """ Second Certificate display viewlet.
314    """
315    grok.order(10)
316    label = _(u'Second Certificate')
317    title = _(u'Second Certificate')
318    download_name = u'cert2'
319
320class SecondCertificateSlip(SecondCertificateDisplay):
321    grok.view(ExportPDFClearanceSlip)
322
323class SecondCertificateUpload(StudentFileUpload):
324    """Second Certificate upload viewlet.
325    """
326    grok.order(10)
327    label = _(u'Second Certificate')
328    title = _(u'Second Certificate Scan')
329    mus = 1024 * 150
330    download_name = u'cert2'
331
332    @property
333    def show_viewlet(self):
334        return show_viewlet(self)
335
336class SecondCertificateImage(StudentImage):
337    """Renders Second Certificate scan.
338    """
339    grok.name('cert2')
340    download_name = u'cert2'
341
342# Third Certificate (PG Students only)
343
344class ThirdCertificateDisplay(StudentFileDisplay):
345    """ Third Certificate display viewlet.
346    """
347    grok.order(11)
348    label = _(u'Third Certificate')
349    title = _(u'Third Certificate')
350    download_name = u'cert3'
351
352class ThirdCertificateSlip(ThirdCertificateDisplay):
353    grok.view(ExportPDFClearanceSlip)
354
355class ThirdCertificateUpload(StudentFileUpload):
356    """Third Certificate upload viewlet.
357    """
358    grok.order(11)
359    label = _(u'Third Certificate')
360    title = _(u'Third Certificate Scan')
361    mus = 1024 * 150
362    download_name = u'cert3'
363
364    @property
365    def show_viewlet(self):
366        return show_viewlet(self)
367
368class ThirdCertificateImage(StudentImage):
369    """Renders Third Certificate scan.
370    """
371    grok.name('cert3')
372    download_name = u'cert3'
373
374# Evidence of Name
375
376class EvidenceNameDisplay(StudentFileDisplay):
377    """Evidence of Name display viewlet.
378    """
379    grok.order(12)
380    label = _(u'Evidence of Name')
381    title = _(u'Evidence of Name')
382    download_name = u'evid'
383
384class EvidenceNameSlip(EvidenceNameDisplay):
385    grok.view(ExportPDFClearanceSlip)
386
387class EvidenceNameUpload(StudentFileUpload):
388    """Evidence of Name upload viewlet.
389    """
390    grok.order(12)
391    label = _(u'Evidence of Name')
392    title = _(u'Evidence of Name Scan')
393    mus = 1024 * 150
394    download_name = u'evid'
395
396class EvidenceNameImage(StudentImage):
397    """Renders Evidence of Name scan.
398    """
399    grok.name('evid')
400    download_name = u'evid'
401
402# Result Statement
403
404class ResultStatementDisplay(StudentFileDisplay):
405    """Result Statement display viewlet.
406    """
407    grok.order(13)
408    label = _(u'Result Statement')
409    title = _(u'Result Statement')
410    download_name = u'res_stat'
411
412class ResultStatementSlip(ResultStatementDisplay):
413    grok.view(ExportPDFClearanceSlip)
414
415class ResultStatementUpload(StudentFileUpload):
416    """Result Statement upload viewlet.
417    """
418    grok.order(13)
419    label = _(u'Result Statement')
420    title = _(u'Result Statement Scan')
421    mus = 1024 * 150
422    download_name = u'res_stat'
423
424class ResultStatementImage(StudentImage):
425    """Renders Result Statement scan.
426    """
427    grok.name('res_stat')
428    download_name = u'res_stat'
429
430# Referee Letter
431
432class RefereeLetterDisplay(StudentFileDisplay):
433    """Referee Letter display viewlet.
434    """
435    grok.order(14)
436    label = _(u'Guarantor/Referee Letter')
437    title = _(u'Guarantor/Referee Letter')
438    download_name = u'ref_let'
439
440class RefereeLetterSlip(RefereeLetterDisplay):
441    grok.view(ExportPDFClearanceSlip)
442
443class RefereeLetterUpload(StudentFileUpload):
444    """Referee Letter upload viewlet.
445    """
446    grok.order(14)
447    label = _(u'Guarantor/Referee Letter')
448    title = _(u'Guarantor/Referee Letter Scan')
449    mus = 1024 * 150
450    download_name = u'ref_let'
451
452class RefereeLetterImage(StudentImage):
453    """Renders Referee Letter scan.
454    """
455    grok.name('ref_let')
456    download_name = u'ref_let'
457
458# Second Referee Letter (PG Students only)
459
460class SecondRefereeLetterDisplay(StudentFileDisplay):
461    """Second Referee Letter display viewlet.
462    """
463    grok.order(15)
464    label = _(u'Second Referee Letter')
465    title = _(u'Second Referee Letter')
466    download_name = u'ref_let2'
467
468class SecondRefereeLetterSlip(SecondRefereeLetterDisplay):
469    grok.view(ExportPDFClearanceSlip)
470
471class SecondRefereeLetterUpload(StudentFileUpload):
472    """Referee Letter upload viewlet.
473    """
474    grok.order(15)
475    label = _(u'Second Referee Letter')
476    title = _(u'Second Referee Letter Scan')
477    mus = 1024 * 150
478    download_name = u'ref_let2'
479
480    @property
481    def show_viewlet(self):
482        return show_viewlet(self)
483
484class SecondRefereeLetterImage(StudentImage):
485    """Renders Referee Letter scan.
486    """
487    grok.name('ref_let2')
488    download_name = u'ref_let2'
489
490# Third Referee Letter (PG Students only)
491
492class ThirdRefereeLetterDisplay(StudentFileDisplay):
493    """Third Referee Letter display viewlet.
494    """
495    grok.order(16)
496    label = _(u'Third Referee Letter')
497    title = _(u'Third Referee Letter')
498    download_name = u'ref_let3'
499
500class ThirdRefereeLetterSlip(ThirdRefereeLetterDisplay):
501    grok.view(ExportPDFClearanceSlip)
502
503class ThirdRefereeLetterUpload(StudentFileUpload):
504    """Referee Letter upload viewlet.
505    """
506    grok.order(16)
507    label = _(u'Third Referee Letter')
508    title = _(u'Third Referee Letter Scan')
509    mus = 1024 * 150
510    download_name = u'ref_let3'
511
512    @property
513    def show_viewlet(self):
514        return show_viewlet(self)
515
516class ThirdRefereeLetterImage(StudentImage):
517    """Renders Referee Letter scan.
518    """
519    grok.name('ref_let3')
520    download_name = u'ref_let3'
521
522# Affidavit (former Statutory Declaration) of Good Conduct
523
524class StatutoryDeclarationDisplay(StudentFileDisplay):
525    """Statutory Declaration of Good Conduct display viewlet.
526    """
527    grok.order(17)
528    label = _(u'Affidavit of Good Conduct')
529    title = _(u'Affidavit of Good Conduct')
530    download_name = u'stat_dec'
531
532class StatutoryDeclarationSlip(StatutoryDeclarationDisplay):
533    grok.view(ExportPDFClearanceSlip)
534
535class StatutoryDeclarationUpload(StudentFileUpload):
536    """Statutory Declaration of Good Conduct upload viewlet.
537    """
538    grok.order(17)
539    label = _(u'Affidavit of Good Conduct')
540    title = _(u'Affidavit of Good Conduct Scan')
541    mus = 1024 * 150
542    download_name = u'stat_dec'
543
544class StatutoryDeclarationImage(StudentImage):
545    """Renders Affidavit of Good Conduct scan.
546    """
547    grok.name('stat_dec')
548    download_name = u'stat_dec'
549
550# Letter of Admission (PG Students only)
551
552class LetterAdmissionDisplay(StudentFileDisplay):
553    """Letter of Admission display viewlet.
554    """
555    grok.order(18)
556    label = _(u'Letter of Admission')
557    title = _(u'Letter of Admission')
558    download_name = u'admission_let'
559
560class LetterAdmissionSlip(LetterAdmissionDisplay):
561    grok.view(ExportPDFClearanceSlip)
562
563class LetterAdmissionUpload(StudentFileUpload):
564    """Letter of Admission upload viewlet.
565    """
566    grok.order(18)
567    label = _(u'Letter of Admission')
568    title = _(u'Letter of Admission Scan')
569    mus = 1024 * 150
570    download_name = u'admission_let'
571
572    @property
573    def show_viewlet(self):
574        return show_viewlet(self)
575
576class LetterAdmissionImage(StudentImage):
577    """Renders Letter of Admission scan.
578    """
579    grok.name('admission_let')
580    download_name = u'admission_let'
Note: See TracBrowser for help on using the repository browser.