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

Last change on this file since 15755 was 15651, checked in by Henrik Bettermann, 5 years ago

Make max file size customizable.

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