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

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

Payment slips must be printable in state 'paid'.

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