1 | ## $Id: viewlets.py 15176 2018-09-26 05:47:59Z 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 | |
---|
19 | import grok |
---|
20 | from waeup.kofa.interfaces import REQUESTED |
---|
21 | from waeup.kofa.browser.viewlets import ManageActionButton |
---|
22 | from waeup.kofa.students.fileviewlets import ( |
---|
23 | StudentFileDisplay, StudentFileUpload, StudentImage) |
---|
24 | from waeup.kofa.students.browser import ( |
---|
25 | ExportPDFClearanceSlip, StudyCourseDisplayFormPage, |
---|
26 | StudyLevelDisplayFormPage, StudentBaseDisplayFormPage) |
---|
27 | from waeup.kofa.students.interfaces import IStudent |
---|
28 | |
---|
29 | from kofacustom.edopoly.students.interfaces import ( |
---|
30 | ICustomStudentStudyCourse, ICustomStudentStudyLevel) |
---|
31 | |
---|
32 | from kofacustom.nigeria.interfaces import MessageFactory as _ |
---|
33 | |
---|
34 | class GetMatricNumberActionButton(ManageActionButton): |
---|
35 | grok.order(10) |
---|
36 | grok.context(IStudent) |
---|
37 | grok.view(StudentBaseDisplayFormPage) |
---|
38 | grok.require('waeup.viewStudent') |
---|
39 | #grok.require('waeup.manageStudent') |
---|
40 | icon = 'actionicon_count.png' |
---|
41 | text = _('Get Matriculation Number') |
---|
42 | |
---|
43 | @property |
---|
44 | def target_url(self): |
---|
45 | students_utils = getUtility(IStudentsUtils) |
---|
46 | if self.context.matric_number: |
---|
47 | return '' |
---|
48 | error, matric_number = students_utils.constructMatricNumber( |
---|
49 | self.context) |
---|
50 | if error: |
---|
51 | return '' |
---|
52 | return self.view.url(self.view.context, 'get_matric_number') |
---|
53 | |
---|
54 | class MatricNumberSlipActionButton(ManageActionButton): |
---|
55 | grok.order(10) |
---|
56 | grok.context(IStudent) |
---|
57 | grok.view(StudentBaseDisplayFormPage) |
---|
58 | grok.require('waeup.viewStudent') |
---|
59 | icon = 'actionicon_pdf.png' |
---|
60 | text = _('Download matriculation number slip') |
---|
61 | target = 'matric_number_slip.pdf' |
---|
62 | |
---|
63 | @property |
---|
64 | def target_url(self): |
---|
65 | if self.context.state not in (PAID,) or not self.context.is_fresh \ |
---|
66 | or not self.context.matric_number: |
---|
67 | return '' |
---|
68 | return self.view.url(self.view.context, self.target) |
---|