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

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

Make max file size customizable.

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