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

Last change on this file since 13621 was 13620, checked in by Henrik Bettermann, 9 years ago

Add fields, permissions, browser views and buttons to enable financial clearance by bursory officers.

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