source: main/waeup.aaue/trunk/src/waeup/aaue/students/viewlets.py @ 13193

Last change on this file since 13193 was 13051, checked in by Henrik Bettermann, 10 years ago

Student are always allowed to download course registration slips of passed sessions.

  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1## $Id: viewlets.py 13051 2015-06-15 15:04:19Z 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 REGISTERED
22from waeup.kofa.students.interfaces import IStudent, IStudentsUtils
23from waeup.kofa.students.workflow import PAID
24from waeup.kofa.students.viewlets import (
25    AddPreviousPaymentActionButton, AddBalancePaymentActionButton,
26    ManageActionButton, StudentBaseDisplayFormPage)
27from waeup.kofa.students.browser import StudyLevelDisplayFormPage
28
29from waeup.aaue.students.interfaces import ICustomStudentStudyLevel
30from waeup.aaue.interfaces import MessageFactory as _
31
32class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton):
33
34    @property
35    def target_url(self):
36        return ''
37
38class AddBalancePaymentActionButton(AddBalancePaymentActionButton):
39
40    @property
41    def target_url(self):
42        return ''
43
44class GetMatricNumberActionButton(ManageActionButton):
45    grok.order(10)
46    grok.context(IStudent)
47    grok.view(StudentBaseDisplayFormPage)
48    grok.require('waeup.viewStudent')
49    #grok.require('waeup.manageStudent')
50    icon = 'actionicon_count.png'
51    text = _('Get Matriculation Number')
52
53    @property
54    def target_url(self):
55        students_utils = getUtility(IStudentsUtils)
56        if self.context.matric_number:
57            return ''
58        error, matric_number = students_utils.constructMatricNumber(
59            self.context)
60        if error:
61            return ''
62        return self.view.url(self.view.context, 'get_matric_number')
63
64class MatricNumberSlipActionButton(ManageActionButton):
65    grok.order(10)
66    grok.context(IStudent)
67    grok.view(StudentBaseDisplayFormPage)
68    grok.require('waeup.viewStudent')
69    icon = 'actionicon_pdf.png'
70    text = _('Download matriculation number slip')
71    target = 'matric_number_slip.pdf'
72
73    @property
74    def target_url(self):
75        if self.context.state not in (PAID,) or not self.context.is_fresh \
76            or not self.context.matric_number:
77            return ''
78        return self.view.url(self.view.context, self.target)
79
80class CourseRegistrationSlipActionButton(ManageActionButton):
81    grok.order(5)
82    grok.context(ICustomStudentStudyLevel)
83    grok.view(StudyLevelDisplayFormPage)
84    grok.require('waeup.viewStudent')
85    icon = 'actionicon_pdf.png'
86    text = _('Download course registration slip')
87    target = 'course_registration_slip.pdf'
88
89    @property
90    def target_url(self):
91        is_current = self.context.__parent__.is_current
92        if not is_current:
93            return ''
94        if self.context.student.state != REGISTERED \
95            and self.context.student.current_level == self.context.level:
96            return ''
97        return self.view.url(self.view.context, self.target)
Note: See TracBrowser for help on using the repository browser.