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

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

Add fields, permissions, browser views and buttons to enable financial clearance by bursory officers.

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