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

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

Move viewlet classes.

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