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

Last change on this file since 17929 was 17869, checked in by Henrik Bettermann, 3 months ago

Hide final clearance button.

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