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

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

Payment slips must be printable in state 'paid'.

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