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

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

Hide final clearance button.

  • Property svn:keywords set to Id
File size: 17.6 KB
Line 
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
20from zope.component import getUtility
21from waeup.kofa.interfaces import IExtFileStore
22from waeup.kofa.browser.viewlets import ManageActionButton
23from waeup.kofa.students.interfaces import IStudentsUtils
24from waeup.kofa.students.viewlets import (
25    PaymentReceiptActionButton,)
26from waeup.kofa.students.fileviewlets import (
27    StudentFileDisplay, StudentFileUpload, StudentImage)
28from waeup.kofa.students.browser import ExportPDFClearanceSlip
29from kofacustom.nigeria.students.interfaces import (
30    INigeriaStudent, INigeriaStudentOnlinePayment)
31from kofacustom.nigeria.students.browser import NigeriaStudentBaseDisplayFormPage
32from kofacustom.nigeria.interfaces import MessageFactory as _
33
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
43class PaymentReceiptActionButton(PaymentReceiptActionButton):
44    grok.order(4)
45    grok.context(INigeriaStudentOnlinePayment)
46
47    @property
48    def target_url(self):
49        if not self.context.p_state in ('paid', 'waived', 'scholarship') \
50            and not self.context.r_company:
51            return ''
52        return self.view.url(self.view.context, self.target)
53
54# Financial Clearance Officer buttons
55
56class StudentFinanciallyClearActionButton(ManageActionButton):
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
71class StudentWithdrawFinancialClearanceActionButton(ManageActionButton):
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
86class FinancialClearanceSlipActionButton(ManageActionButton):
87    grok.order(12)
88    grok.context(INigeriaStudent)
89    grok.view(NigeriaStudentBaseDisplayFormPage)
90    grok.require('waeup.viewStudent')
91    text = _('Download fee payment history')
92    target = 'fee_payment_history.pdf'
93    icon = 'actionicon_pdf.png'
94
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):
108        final_clearance_enabled = getUtility(
109            IStudentsUtils).final_clearance_enabled(self.context)
110        if not final_clearance_enabled:
111            return ''
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
131# Acceptance Letter
132
133class AcceptanceLetterDisplay(StudentFileDisplay):
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):
142    grok.view(ExportPDFClearanceSlip)
143
144class AcceptanceLetterUpload(StudentFileUpload):
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
153class AcceptanceLetterImage(StudentImage):
154    """Renders acceptance letter scan.
155    """
156    grok.name('acc_let')
157    download_name = u'acc_let'
158
159# LGA Identification
160
161class LGAIdentificationDisplay(StudentFileDisplay):
162    """LGA Identification display viewlet.
163    """
164    grok.order(3)
165    label = _(u'LGA Identification')
166    title = _(u'LGA Identification Scan')
167    download_name = u'lga_ident'
168
169class LGAIdentificationSlip(LGAIdentificationDisplay):
170    grok.view(ExportPDFClearanceSlip)
171
172class LGAIdentificationUpload(StudentFileUpload):
173    """LGA Identification upload viewlet.
174    """
175    grok.order(3)
176    label = _(u'LGA Identification')
177    title = _(u'LGA Identification Scan')
178    download_name = u'lga_ident'
179
180class LGAIdentificationImage(StudentImage):
181    """Renders LGA Identification scan.
182    """
183    grok.name('lga_ident')
184    download_name = u'lga_ident'
185
186# First Sitting Result
187
188class FirstSittingResultDisplay(StudentFileDisplay):
189    """First Sitting Result display viewlet.
190    """
191    grok.order(4)
192    label = _(u'First Sitting Result')
193    title = _(u'First Sitting Result')
194    download_name = u'fst_sit_scan'
195
196class FirstSittingResultSlip(FirstSittingResultDisplay):
197    grok.view(ExportPDFClearanceSlip)
198
199class FirstSittingResultUpload(StudentFileUpload):
200    """First Sitting Result upload viewlet.
201    """
202    grok.order(4)
203    label = _(u'First Sitting Result')
204    title = _(u'First Sitting Result Scan')
205    download_name = u'fst_sit_scan'
206
207class FirstSittingResultImage(StudentImage):
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
215class SecondSittingResultDisplay(StudentFileDisplay):
216    """Second Sitting Result display viewlet.
217    """
218    grok.order(5)
219    label = _(u'Second Sitting Result')
220    title = _(u'Second Sitting Result')
221    download_name = u'scd_sit_scan'
222
223class SecondSittingResultSlip(SecondSittingResultDisplay):
224    grok.view(ExportPDFClearanceSlip)
225
226class SecondSittingResultUpload(StudentFileUpload):
227    """Second Sitting Result upload viewlet.
228    """
229    grok.order(5)
230    label = _(u'Second Sitting Result')
231    title = _(u'Second Sitting Result Scan')
232    download_name = u'scd_sit_scan'
233
234class SecondSittingResultImage(StudentImage):
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
242class HigherQualificationResultDisplay(StudentFileDisplay):
243    """Higher Qualification Result display viewlet.
244    """
245    grok.order(6)
246    label = _(u'Higher Qualification Result')
247    title = _(u'Higher Qualification Result')
248    download_name = u'hq_scan'
249
250class HigherQualificationResultSlip(HigherQualificationResultDisplay):
251    grok.view(ExportPDFClearanceSlip)
252
253class HigherQualificationResultUpload(StudentFileUpload):
254    """Higher Qualification Result upload viewlet.
255    """
256    grok.order(6)
257    label = _(u'Higher Qualification Result')
258    title = _(u'Higher Qualification Result Scan')
259    download_name = u'hq_scan'
260
261class HigherQualificationResultImage(StudentImage):
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
269class SecondHigherQualificationResultDisplay(StudentFileDisplay):
270    """Second Higher Qualification Result display viewlet.
271    """
272    grok.order(7)
273    label = _(u'Second Higher Qualification Result')
274    title = _(u'Second Higher Qualification Result')
275    download_name = u'hq_scan2'
276
277class SecondHigherQualificationResultSlip(SecondHigherQualificationResultDisplay):
278    grok.view(ExportPDFClearanceSlip)
279
280class SecondHigherQualificationResultUpload(StudentFileUpload):
281    """Second Higher Qualification Result upload viewlet.
282    """
283    grok.order(7)
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):
290        return show_viewlet(self)
291
292class SecondHigherQualificationResultImage(StudentImage):
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
300class AdvancedLevelResultDisplay(StudentFileDisplay):
301    """Advanced Level Result display viewlet.
302    """
303    grok.order(8)
304    label = _(u'Advanced Level Result')
305    title = _(u'Advanced Level Result')
306    download_name = u'alr_scan'
307
308class AdvancedLevelResultSlip(AdvancedLevelResultDisplay):
309    grok.view(ExportPDFClearanceSlip)
310
311class AdvancedLevelResultUpload(StudentFileUpload):
312    """Advanced Level Result upload viewlet.
313    """
314    grok.order(8)
315    label = _(u'Advanced Level Result')
316    title = _(u'Advanced Level Result Scan')
317    download_name = u'alr_scan'
318
319class AdvancedLevelResultImage(StudentImage):
320    """Renders Advanced Level Result scan.
321    """
322    grok.name('alr_scan')
323    download_name = u'alr_scan'
324
325# Certificate
326
327class CertificateDisplay(StudentFileDisplay):
328    """Certificate display viewlet.
329    """
330    grok.order(9)
331    label = _(u'Certificate')
332    title = _(u'Certificate')
333    download_name = u'cert'
334
335class CertificateSlip(CertificateDisplay):
336    grok.view(ExportPDFClearanceSlip)
337
338class CertificateUpload(StudentFileUpload):
339    """Certificate upload viewlet.
340    """
341    grok.order(9)
342    label = _(u'Certificate')
343    title = _(u'Certificate Scan')
344    download_name = u'cert'
345
346class CertificateImage(StudentImage):
347    """Renders Certificate scan.
348    """
349    grok.name('cert')
350    download_name = u'cert'
351
352# Second Certificate (PG Students only)
353
354class SecondCertificateDisplay(StudentFileDisplay):
355    """ Second Certificate display viewlet.
356    """
357    grok.order(10)
358    label = _(u'Second Certificate')
359    title = _(u'Second Certificate')
360    download_name = u'cert2'
361
362class SecondCertificateSlip(SecondCertificateDisplay):
363    grok.view(ExportPDFClearanceSlip)
364
365class SecondCertificateUpload(StudentFileUpload):
366    """Second Certificate upload viewlet.
367    """
368    grok.order(10)
369    label = _(u'Second Certificate')
370    title = _(u'Second Certificate Scan')
371    download_name = u'cert2'
372
373    @property
374    def show_viewlet(self):
375        return show_viewlet(self)
376
377class SecondCertificateImage(StudentImage):
378    """Renders Second Certificate scan.
379    """
380    grok.name('cert2')
381    download_name = u'cert2'
382
383# Third Certificate (PG Students only)
384
385class ThirdCertificateDisplay(StudentFileDisplay):
386    """ Third Certificate display viewlet.
387    """
388    grok.order(11)
389    label = _(u'Third Certificate')
390    title = _(u'Third Certificate')
391    download_name = u'cert3'
392
393class ThirdCertificateSlip(ThirdCertificateDisplay):
394    grok.view(ExportPDFClearanceSlip)
395
396class ThirdCertificateUpload(StudentFileUpload):
397    """Third Certificate upload viewlet.
398    """
399    grok.order(11)
400    label = _(u'Third Certificate')
401    title = _(u'Third Certificate Scan')
402    download_name = u'cert3'
403
404    @property
405    def show_viewlet(self):
406        return show_viewlet(self)
407
408class ThirdCertificateImage(StudentImage):
409    """Renders Third Certificate scan.
410    """
411    grok.name('cert3')
412    download_name = u'cert3'
413
414# Evidence of Name
415
416class EvidenceNameDisplay(StudentFileDisplay):
417    """Evidence of Name display viewlet.
418    """
419    grok.order(12)
420    label = _(u'Evidence of Name')
421    title = _(u'Evidence of Name')
422    download_name = u'evid'
423
424class EvidenceNameSlip(EvidenceNameDisplay):
425    grok.view(ExportPDFClearanceSlip)
426
427class EvidenceNameUpload(StudentFileUpload):
428    """Evidence of Name upload viewlet.
429    """
430    grok.order(12)
431    label = _(u'Evidence of Name')
432    title = _(u'Evidence of Name Scan')
433    download_name = u'evid'
434
435class EvidenceNameImage(StudentImage):
436    """Renders Evidence of Name scan.
437    """
438    grok.name('evid')
439    download_name = u'evid'
440
441# Result Statement
442
443class ResultStatementDisplay(StudentFileDisplay):
444    """Result Statement display viewlet.
445    """
446    grok.order(13)
447    label = _(u'Result Statement')
448    title = _(u'Result Statement')
449    download_name = u'res_stat'
450
451class ResultStatementSlip(ResultStatementDisplay):
452    grok.view(ExportPDFClearanceSlip)
453
454class ResultStatementUpload(StudentFileUpload):
455    """Result Statement upload viewlet.
456    """
457    grok.order(13)
458    label = _(u'Result Statement')
459    title = _(u'Result Statement Scan')
460    download_name = u'res_stat'
461
462class ResultStatementImage(StudentImage):
463    """Renders Result Statement scan.
464    """
465    grok.name('res_stat')
466    download_name = u'res_stat'
467
468# Referee Letter
469
470class RefereeLetterDisplay(StudentFileDisplay):
471    """Referee Letter display viewlet.
472    """
473    grok.order(14)
474    label = _(u'Guarantor/Referee Letter')
475    title = _(u'Guarantor/Referee Letter')
476    download_name = u'ref_let'
477
478class RefereeLetterSlip(RefereeLetterDisplay):
479    grok.view(ExportPDFClearanceSlip)
480
481class RefereeLetterUpload(StudentFileUpload):
482    """Referee Letter upload viewlet.
483    """
484    grok.order(14)
485    label = _(u'Guarantor/Referee Letter')
486    title = _(u'Guarantor/Referee Letter Scan')
487    download_name = u'ref_let'
488
489class RefereeLetterImage(StudentImage):
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
497class SecondRefereeLetterDisplay(StudentFileDisplay):
498    """Second Referee Letter display viewlet.
499    """
500    grok.order(15)
501    label = _(u'Second Referee Letter')
502    title = _(u'Second Referee Letter')
503    download_name = u'ref_let2'
504
505class SecondRefereeLetterSlip(SecondRefereeLetterDisplay):
506    grok.view(ExportPDFClearanceSlip)
507
508class SecondRefereeLetterUpload(StudentFileUpload):
509    """Referee Letter upload viewlet.
510    """
511    grok.order(15)
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):
518        return show_viewlet(self)
519
520class SecondRefereeLetterImage(StudentImage):
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
528class ThirdRefereeLetterDisplay(StudentFileDisplay):
529    """Third Referee Letter display viewlet.
530    """
531    grok.order(16)
532    label = _(u'Third Referee Letter')
533    title = _(u'Third Referee Letter')
534    download_name = u'ref_let3'
535
536class ThirdRefereeLetterSlip(ThirdRefereeLetterDisplay):
537    grok.view(ExportPDFClearanceSlip)
538
539class ThirdRefereeLetterUpload(StudentFileUpload):
540    """Referee Letter upload viewlet.
541    """
542    grok.order(16)
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):
549        return show_viewlet(self)
550
551class ThirdRefereeLetterImage(StudentImage):
552    """Renders Referee Letter scan.
553    """
554    grok.name('ref_let3')
555    download_name = u'ref_let3'
556
557# Affidavit (former Statutory Declaration) of Good Conduct
558
559class StatutoryDeclarationDisplay(StudentFileDisplay):
560    """Statutory Declaration of Good Conduct display viewlet.
561    """
562    grok.order(17)
563    label = _(u'Affidavit of Good Conduct')
564    title = _(u'Affidavit of Good Conduct')
565    download_name = u'stat_dec'
566
567class StatutoryDeclarationSlip(StatutoryDeclarationDisplay):
568    grok.view(ExportPDFClearanceSlip)
569
570class StatutoryDeclarationUpload(StudentFileUpload):
571    """Statutory Declaration of Good Conduct upload viewlet.
572    """
573    grok.order(17)
574    label = _(u'Affidavit of Good Conduct')
575    title = _(u'Affidavit of Good Conduct Scan')
576    download_name = u'stat_dec'
577
578class StatutoryDeclarationImage(StudentImage):
579    """Renders Affidavit of Good Conduct scan.
580    """
581    grok.name('stat_dec')
582    download_name = u'stat_dec'
583
584# Letter of Admission (PG Students only)
585
586class LetterAdmissionDisplay(StudentFileDisplay):
587    """Letter of Admission display viewlet.
588    """
589    grok.order(18)
590    label = _(u'Letter of Admission')
591    title = _(u'Letter of Admission')
592    download_name = u'admission_let'
593
594class LetterAdmissionSlip(LetterAdmissionDisplay):
595    grok.view(ExportPDFClearanceSlip)
596
597class LetterAdmissionUpload(StudentFileUpload):
598    """Letter of Admission upload viewlet.
599    """
600    grok.order(18)
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):
607        return show_viewlet(self)
608
609class LetterAdmissionImage(StudentImage):
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.