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

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

Implement automatic matric_number assignment. Students can induce the
assignment if they have paid school fees by clicking the
'Get Matriculation Number' button. Numbering is per department and session.

  • Property svn:keywords set to Id
File size: 3.7 KB
Line 
1## $Id: viewlets.py 12907 2015-05-06 10:13:38Z 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.students.viewlets import (
22    AddPreviousPaymentActionButton, AddBalancePaymentActionButton,
23    ManageActionButton)
24from waeup.kofa.students.interfaces import IStudent, IStudentsUtils
25from waeup.kofa.students.browser import StudentBaseDisplayFormPage
26from waeup.kofa.students.workflow import (
27    ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED,
28    VALIDATED, GRADUATED, TRANSCRIPT, CREATED, CLEARANCE)
29from waeup.kwarapoly.interfaces import MessageFactory as _
30
31class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton):
32
33    @property
34    def target_url(self):
35        return ''
36
37class AddBalancePaymentActionButton(AddBalancePaymentActionButton):
38
39    @property
40    def target_url(self):
41        return ''
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 ''
72        return self.view.url(self.view.context, self.target)
73
74class RegistrationSlipActionButton(ManageActionButton):
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')
81    target = 'registration_slip.pdf'
82
83    @property
84    def target_url(self):
85        if self.context.state in (CREATED,ADMITTED,
86                                  CLEARANCE, REQUESTED, CLEARED):
87            return ''
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.