source: main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/viewlets.py @ 15554

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

Adjust to changes in base package.

  • Property svn:keywords set to Id
File size: 3.7 KB
RevLine 
[9526]1## $Id: viewlets.py 15436 2019-05-29 12:06:23Z 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
[10691]19import grok
[12907]20from zope.component import getUtility
[9873]21from waeup.kofa.students.viewlets import (
[10691]22    AddPreviousPaymentActionButton, AddBalancePaymentActionButton,
23    ManageActionButton)
[12907]24from waeup.kofa.students.interfaces import IStudent, IStudentsUtils
[10691]25from waeup.kofa.students.browser import StudentBaseDisplayFormPage
26from waeup.kofa.students.workflow import (
27    ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED,
[15436]28    VALIDATED, GRADUATED, CREATED, CLEARANCE)
[10691]29from waeup.kwarapoly.interfaces import MessageFactory as _
[9526]30
31class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton):
32
33    @property
34    def target_url(self):
35        return ''
[9873]36
[14616]37#class AddBalancePaymentActionButton(AddBalancePaymentActionButton):
[9873]38
[14616]39#    @property
40#    def target_url(self):
41#        return ''
[10691]42
43class AdmissionNotificationActionButton(ManageActionButton):
44    grok.order(4)
45    grok.context(IStudent)
46    grok.view(StudentBaseDisplayFormPage)
47    grok.require('waeup.viewStudent')
48    icon = 'actionicon_pdf.png'
49    text = _('Download admission notification')
50    target = 'admission_notification.pdf'
51
52    @property
53    def target_url(self):
54        if self.context.state not in (ADMITTED, CLEARANCE, REQUESTED, CLEARED):
55            return ''
56        return self.view.url(self.view.context, self.target)
57
58class AdmissionSlipActionButton(ManageActionButton):
59    grok.order(4)
60    grok.context(IStudent)
61    grok.view(StudentBaseDisplayFormPage)
62    grok.require('waeup.viewStudent')
63    icon = 'actionicon_pdf.png'
64    text = _('Download admission letter')
65    target = 'admission_slip.pdf'
66
67    @property
68    def target_url(self):
69        if self.context.state in (CREATED, ADMITTED,
70                                  CLEARANCE, REQUESTED, CLEARED):
71            return ''
[10695]72        return self.view.url(self.view.context, self.target)
73
[10705]74class RegistrationSlipActionButton(ManageActionButton):
[10695]75    grok.order(4)
76    grok.context(IStudent)
77    grok.view(StudentBaseDisplayFormPage)
78    grok.require('waeup.viewStudent')
79    icon = 'actionicon_pdf.png'
80    text = _('Download registration form')
[10705]81    target = 'registration_slip.pdf'
[10695]82
83    @property
84    def target_url(self):
[11931]85        if self.context.state in (CREATED,ADMITTED,
86                                  CLEARANCE, REQUESTED, CLEARED):
[10695]87            return ''
[12907]88        return self.view.url(self.view.context, self.target)
89
90
91class GetMatricNumberActionButton(ManageActionButton):
92    grok.order(10)
93    grok.context(IStudent)
94    grok.view(StudentBaseDisplayFormPage)
95    grok.require('waeup.viewStudent')
96    icon = 'actionicon_count.png'
97    text = _('Get Matriculation Number')
98
99    @property
100    def target_url(self):
101        students_utils = getUtility(IStudentsUtils)
102        if self.context.matric_number:
103            return ''
104        error, matric_number = students_utils.constructMatricNumber(
105            self.context)
106        if error:
107            return ''
108        return self.view.url(self.view.context, 'get_matric_number')
Note: See TracBrowser for help on using the repository browser.