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

Last change on this file since 17811 was 17811, checked in by Henrik Bettermann, 5 months ago

Use allowPortraitChange utility method.

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