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

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

Implement final clearance.

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