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
RevLine 
[8862]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
[10022]20from zope.component import getUtility
[13620]21from waeup.kofa.browser.viewlets import ManageActionButton
[10022]22from waeup.kofa.students.interfaces import IStudentsUtils
[12422]23from waeup.kofa.students.fileviewlets import (
[12449]24    StudentFileDisplay, StudentFileUpload, StudentImage)
[13058]25from waeup.kofa.students.browser import ExportPDFClearanceSlip
[8862]26
[13620]27from kofacustom.nigeria.students.interfaces import INigeriaStudent
28from kofacustom.nigeria.students.browser import NigeriaStudentBaseDisplayFormPage
[8862]29from kofacustom.nigeria.interfaces import MessageFactory as _
30
[10022]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
[13856]40# Financial Clearance Officer buttons
[13620]41
[13856]42class StudentFinanciallyClearActionButton(ManageActionButton):
[13620]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
[13856]57class StudentWithdrawFinancialClearanceActionButton(ManageActionButton):
[13620]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
[13634]72class FinancialClearanceSlipActionButton(ManageActionButton):
[13623]73    grok.order(12)
74    grok.context(INigeriaStudent)
75    grok.view(NigeriaStudentBaseDisplayFormPage)
76    grok.require('waeup.viewStudent')
[13781]77    text = _('Download fee payment history')
78    target = 'fee_payment_history.pdf'
[13623]79    icon = 'actionicon_pdf.png'
[13620]80
[9236]81# Acceptance Letter
82
[12449]83class AcceptanceLetterDisplay(StudentFileDisplay):
[9236]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):
[13058]92    grok.view(ExportPDFClearanceSlip)
[9236]93
[12449]94class AcceptanceLetterUpload(StudentFileUpload):
[9236]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
[12449]104class AcceptanceLetterImage(StudentImage):
[9236]105    """Renders acceptance letter scan.
106    """
107    grok.name('acc_let')
108    download_name = u'acc_let'
109
[8862]110# LGA Identification
111
[12449]112class LGAIdentificationDisplay(StudentFileDisplay):
[8862]113    """LGA Identification display viewlet.
114    """
[9236]115    grok.order(3)
[8862]116    label = _(u'LGA Identification')
117    title = _(u'LGA Identification Scan')
118    download_name = u'lga_ident'
119
120class LGAIdentificationSlip(LGAIdentificationDisplay):
[13058]121    grok.view(ExportPDFClearanceSlip)
[8862]122
[12449]123class LGAIdentificationUpload(StudentFileUpload):
[8862]124    """LGA Identification upload viewlet.
125    """
[9236]126    grok.order(3)
[8862]127    label = _(u'LGA Identification')
128    title = _(u'LGA Identification Scan')
129    mus = 1024 * 150
130    download_name = u'lga_ident'
131
[12449]132class LGAIdentificationImage(StudentImage):
[8862]133    """Renders LGA Identification scan.
134    """
135    grok.name('lga_ident')
136    download_name = u'lga_ident'
137
138# First Sitting Result
139
[12449]140class FirstSittingResultDisplay(StudentFileDisplay):
[8862]141    """First Sitting Result display viewlet.
142    """
[9236]143    grok.order(4)
[8862]144    label = _(u'First Sitting Result')
145    title = _(u'First Sitting Result')
146    download_name = u'fst_sit_scan'
147
148class FirstSittingResultSlip(FirstSittingResultDisplay):
[13058]149    grok.view(ExportPDFClearanceSlip)
[8862]150
[12449]151class FirstSittingResultUpload(StudentFileUpload):
[8862]152    """First Sitting Result upload viewlet.
153    """
[9236]154    grok.order(4)
[8862]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
[12449]160class FirstSittingResultImage(StudentImage):
[8862]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
[12449]168class SecondSittingResultDisplay(StudentFileDisplay):
[8862]169    """Second Sitting Result display viewlet.
170    """
[9236]171    grok.order(5)
[8862]172    label = _(u'Second Sitting Result')
173    title = _(u'Second Sitting Result')
174    download_name = u'scd_sit_scan'
175
176class SecondSittingResultSlip(SecondSittingResultDisplay):
[13058]177    grok.view(ExportPDFClearanceSlip)
[8862]178
[12449]179class SecondSittingResultUpload(StudentFileUpload):
[8862]180    """Second Sitting Result upload viewlet.
181    """
[9236]182    grok.order(5)
[8862]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
[12449]188class SecondSittingResultImage(StudentImage):
[8862]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
[12449]196class HigherQualificationResultDisplay(StudentFileDisplay):
[8862]197    """Higher Qualification Result display viewlet.
198    """
[9236]199    grok.order(6)
[8862]200    label = _(u'Higher Qualification Result')
201    title = _(u'Higher Qualification Result')
202    download_name = u'hq_scan'
203
204class HigherQualificationResultSlip(HigherQualificationResultDisplay):
[13058]205    grok.view(ExportPDFClearanceSlip)
[8862]206
[12449]207class HigherQualificationResultUpload(StudentFileUpload):
[8862]208    """Higher Qualification Result upload viewlet.
209    """
[9236]210    grok.order(6)
[8862]211    label = _(u'Higher Qualification Result')
212    title = _(u'Higher Qualification Result Scan')
213    mus = 1024 * 150
214    download_name = u'hq_scan'
215
[12449]216class HigherQualificationResultImage(StudentImage):
[8862]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
[12449]224class SecondHigherQualificationResultDisplay(StudentFileDisplay):
[8862]225    """Second Higher Qualification Result display viewlet.
226    """
[9236]227    grok.order(7)
[8862]228    label = _(u'Second Higher Qualification Result')
229    title = _(u'Second Higher Qualification Result')
230    download_name = u'hq_scan2'
231
232class SecondHigherQualificationResultSlip(SecondHigherQualificationResultDisplay):
[13058]233    grok.view(ExportPDFClearanceSlip)
[8862]234
[12449]235class SecondHigherQualificationResultUpload(StudentFileUpload):
[8862]236    """Second Higher Qualification Result upload viewlet.
237    """
[9236]238    grok.order(7)
[8862]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):
[10022]246        return show_viewlet(self)
[8862]247
[12449]248class SecondHigherQualificationResultImage(StudentImage):
[8862]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
[12449]256class AdvancedLevelResultDisplay(StudentFileDisplay):
[8862]257    """Advanced Level Result display viewlet.
258    """
[9236]259    grok.order(8)
[8862]260    label = _(u'Advanced Level Result')
261    title = _(u'Advanced Level Result')
262    download_name = u'alr_scan'
263
264class AdvancedLevelResultSlip(AdvancedLevelResultDisplay):
[13058]265    grok.view(ExportPDFClearanceSlip)
[8862]266
[12449]267class AdvancedLevelResultUpload(StudentFileUpload):
[8862]268    """Advanced Level Result upload viewlet.
269    """
[9236]270    grok.order(8)
[8862]271    label = _(u'Advanced Level Result')
272    title = _(u'Advanced Level Result Scan')
273    mus = 1024 * 150
274    download_name = u'alr_scan'
275
[12449]276class AdvancedLevelResultImage(StudentImage):
[8862]277    """Renders Advanced Level Result scan.
278    """
279    grok.name('alr_scan')
280    download_name = u'alr_scan'
281
[9381]282# Certificate
[8862]283
[12449]284class CertificateDisplay(StudentFileDisplay):
[9381]285    """Certificate display viewlet.
[8862]286    """
[9236]287    grok.order(9)
[9381]288    label = _(u'Certificate')
289    title = _(u'Certificate')
[9236]290    download_name = u'cert'
[8862]291
292class CertificateSlip(CertificateDisplay):
[13058]293    grok.view(ExportPDFClearanceSlip)
[8862]294
[12449]295class CertificateUpload(StudentFileUpload):
[9381]296    """Certificate upload viewlet.
[8862]297    """
[9236]298    grok.order(9)
[9381]299    label = _(u'Certificate')
300    title = _(u'Certificate Scan')
[8862]301    mus = 1024 * 150
[9236]302    download_name = u'cert'
[8862]303
[12449]304class CertificateImage(StudentImage):
[9381]305    """Renders Certificate scan.
[8862]306    """
[9236]307    grok.name('cert')
308    download_name = u'cert'
[8862]309
310# Second Certificate (PG Students only)
311
[12449]312class SecondCertificateDisplay(StudentFileDisplay):
[8862]313    """ Second Certificate display viewlet.
314    """
[9236]315    grok.order(10)
[8862]316    label = _(u'Second Certificate')
317    title = _(u'Second Certificate')
[9236]318    download_name = u'cert2'
[8862]319
320class SecondCertificateSlip(SecondCertificateDisplay):
[13058]321    grok.view(ExportPDFClearanceSlip)
[8862]322
[12449]323class SecondCertificateUpload(StudentFileUpload):
[8862]324    """Second Certificate upload viewlet.
325    """
[9236]326    grok.order(10)
[8862]327    label = _(u'Second Certificate')
328    title = _(u'Second Certificate Scan')
329    mus = 1024 * 150
[9236]330    download_name = u'cert2'
[8862]331
332    @property
333    def show_viewlet(self):
[10022]334        return show_viewlet(self)
[8862]335
[12449]336class SecondCertificateImage(StudentImage):
[8862]337    """Renders Second Certificate scan.
338    """
[9236]339    grok.name('cert2')
340    download_name = u'cert2'
[8862]341
342# Third Certificate (PG Students only)
343
[12449]344class ThirdCertificateDisplay(StudentFileDisplay):
[8862]345    """ Third Certificate display viewlet.
346    """
[9236]347    grok.order(11)
[8862]348    label = _(u'Third Certificate')
349    title = _(u'Third Certificate')
[9236]350    download_name = u'cert3'
[8862]351
352class ThirdCertificateSlip(ThirdCertificateDisplay):
[13058]353    grok.view(ExportPDFClearanceSlip)
[8862]354
[12449]355class ThirdCertificateUpload(StudentFileUpload):
[8862]356    """Third Certificate upload viewlet.
357    """
[9236]358    grok.order(11)
[8862]359    label = _(u'Third Certificate')
360    title = _(u'Third Certificate Scan')
361    mus = 1024 * 150
[9236]362    download_name = u'cert3'
[8862]363
364    @property
365    def show_viewlet(self):
[10022]366        return show_viewlet(self)
[8862]367
[12449]368class ThirdCertificateImage(StudentImage):
[8862]369    """Renders Third Certificate scan.
370    """
[9236]371    grok.name('cert3')
372    download_name = u'cert3'
[8862]373
374# Evidence of Name
375
[12449]376class EvidenceNameDisplay(StudentFileDisplay):
[8862]377    """Evidence of Name display viewlet.
378    """
[9236]379    grok.order(12)
[8862]380    label = _(u'Evidence of Name')
381    title = _(u'Evidence of Name')
382    download_name = u'evid'
383
384class EvidenceNameSlip(EvidenceNameDisplay):
[13058]385    grok.view(ExportPDFClearanceSlip)
[8862]386
[12449]387class EvidenceNameUpload(StudentFileUpload):
[8862]388    """Evidence of Name upload viewlet.
389    """
[9236]390    grok.order(12)
[8862]391    label = _(u'Evidence of Name')
392    title = _(u'Evidence of Name Scan')
393    mus = 1024 * 150
394    download_name = u'evid'
395
[12449]396class EvidenceNameImage(StudentImage):
[8862]397    """Renders Evidence of Name scan.
398    """
399    grok.name('evid')
400    download_name = u'evid'
401
402# Result Statement
403
[12449]404class ResultStatementDisplay(StudentFileDisplay):
[8862]405    """Result Statement display viewlet.
406    """
[9236]407    grok.order(13)
[8862]408    label = _(u'Result Statement')
409    title = _(u'Result Statement')
410    download_name = u'res_stat'
411
412class ResultStatementSlip(ResultStatementDisplay):
[13058]413    grok.view(ExportPDFClearanceSlip)
[8862]414
[12449]415class ResultStatementUpload(StudentFileUpload):
[8862]416    """Result Statement upload viewlet.
417    """
[9236]418    grok.order(13)
[8862]419    label = _(u'Result Statement')
420    title = _(u'Result Statement Scan')
421    mus = 1024 * 150
422    download_name = u'res_stat'
423
[12449]424class ResultStatementImage(StudentImage):
[8862]425    """Renders Result Statement scan.
426    """
427    grok.name('res_stat')
428    download_name = u'res_stat'
429
430# Referee Letter
431
[12449]432class RefereeLetterDisplay(StudentFileDisplay):
[8862]433    """Referee Letter display viewlet.
434    """
[9236]435    grok.order(14)
[9377]436    label = _(u'Guarantor/Referee Letter')
437    title = _(u'Guarantor/Referee Letter')
[8862]438    download_name = u'ref_let'
439
440class RefereeLetterSlip(RefereeLetterDisplay):
[13058]441    grok.view(ExportPDFClearanceSlip)
[8862]442
[12449]443class RefereeLetterUpload(StudentFileUpload):
[8862]444    """Referee Letter upload viewlet.
445    """
[9236]446    grok.order(14)
[9377]447    label = _(u'Guarantor/Referee Letter')
448    title = _(u'Guarantor/Referee Letter Scan')
[8862]449    mus = 1024 * 150
450    download_name = u'ref_let'
451
[12449]452class RefereeLetterImage(StudentImage):
[8862]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
[12449]460class SecondRefereeLetterDisplay(StudentFileDisplay):
[8862]461    """Second Referee Letter display viewlet.
462    """
[9236]463    grok.order(15)
[8862]464    label = _(u'Second Referee Letter')
465    title = _(u'Second Referee Letter')
466    download_name = u'ref_let2'
467
468class SecondRefereeLetterSlip(SecondRefereeLetterDisplay):
[13058]469    grok.view(ExportPDFClearanceSlip)
[8862]470
[12449]471class SecondRefereeLetterUpload(StudentFileUpload):
[8862]472    """Referee Letter upload viewlet.
473    """
[9236]474    grok.order(15)
[8862]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):
[10022]482        return show_viewlet(self)
[8862]483
[12449]484class SecondRefereeLetterImage(StudentImage):
[8862]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
[12449]492class ThirdRefereeLetterDisplay(StudentFileDisplay):
[8862]493    """Third Referee Letter display viewlet.
494    """
[9236]495    grok.order(16)
[8862]496    label = _(u'Third Referee Letter')
497    title = _(u'Third Referee Letter')
498    download_name = u'ref_let3'
499
500class ThirdRefereeLetterSlip(ThirdRefereeLetterDisplay):
[13058]501    grok.view(ExportPDFClearanceSlip)
[8862]502
[12449]503class ThirdRefereeLetterUpload(StudentFileUpload):
[8862]504    """Referee Letter upload viewlet.
505    """
[9236]506    grok.order(16)
[8862]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):
[10022]514        return show_viewlet(self)
[8862]515
[12449]516class ThirdRefereeLetterImage(StudentImage):
[8862]517    """Renders Referee Letter scan.
518    """
519    grok.name('ref_let3')
520    download_name = u'ref_let3'
521
[9377]522# Affidavit (former Statutory Declaration) of Good Conduct
[8862]523
[12449]524class StatutoryDeclarationDisplay(StudentFileDisplay):
[8862]525    """Statutory Declaration of Good Conduct display viewlet.
526    """
[9236]527    grok.order(17)
[9377]528    label = _(u'Affidavit of Good Conduct')
529    title = _(u'Affidavit of Good Conduct')
[8862]530    download_name = u'stat_dec'
531
532class StatutoryDeclarationSlip(StatutoryDeclarationDisplay):
[13058]533    grok.view(ExportPDFClearanceSlip)
[8862]534
[12449]535class StatutoryDeclarationUpload(StudentFileUpload):
[8862]536    """Statutory Declaration of Good Conduct upload viewlet.
537    """
[9236]538    grok.order(17)
[9377]539    label = _(u'Affidavit of Good Conduct')
540    title = _(u'Affidavit of Good Conduct Scan')
[8862]541    mus = 1024 * 150
542    download_name = u'stat_dec'
543
[12449]544class StatutoryDeclarationImage(StudentImage):
[9377]545    """Renders Affidavit of Good Conduct scan.
[8862]546    """
547    grok.name('stat_dec')
548    download_name = u'stat_dec'
549
550# Letter of Admission (PG Students only)
551
[12449]552class LetterAdmissionDisplay(StudentFileDisplay):
[8862]553    """Letter of Admission display viewlet.
554    """
[9381]555    grok.order(18)
[8862]556    label = _(u'Letter of Admission')
557    title = _(u'Letter of Admission')
558    download_name = u'admission_let'
559
560class LetterAdmissionSlip(LetterAdmissionDisplay):
[13058]561    grok.view(ExportPDFClearanceSlip)
[8862]562
[12449]563class LetterAdmissionUpload(StudentFileUpload):
[8862]564    """Letter of Admission upload viewlet.
565    """
[9381]566    grok.order(18)
[8862]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):
[10022]574        return show_viewlet(self)
[8862]575
[12449]576class LetterAdmissionImage(StudentImage):
[8862]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.