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

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

Add personal data slip.

  • Property svn:keywords set to Id
File size: 4.2 KB
RevLine 
[9527]1## $Id: viewlets.py 13489 2015-11-20 10:23:08Z 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
[11597]19import grok
20from zope.component import getUtility
[13039]21from waeup.kofa.interfaces import REGISTERED
[11597]22from waeup.kofa.students.interfaces import IStudent, IStudentsUtils
[11607]23from waeup.kofa.students.workflow import PAID
[9870]24from waeup.kofa.students.viewlets import (
[11597]25    AddPreviousPaymentActionButton, AddBalancePaymentActionButton,
[13380]26    ManageActionButton, StudentBaseDisplayFormPage,
27    StudentPassportActionButton)
[13039]28from waeup.kofa.students.browser import StudyLevelDisplayFormPage
[9527]29
[13489]30from waeup.aaue.students.interfaces import (
31    ICustomStudent, ICustomStudentStudyLevel)
32from waeup.aaue.students.browser import CustomStudentPersonalDisplayFormPage
[11597]33from waeup.aaue.interfaces import MessageFactory as _
34
[9527]35class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton):
36
37    @property
38    def target_url(self):
39        return ''
[9870]40
41class AddBalancePaymentActionButton(AddBalancePaymentActionButton):
42
43    @property
44    def target_url(self):
45        return ''
[11597]46
47class GetMatricNumberActionButton(ManageActionButton):
48    grok.order(10)
49    grok.context(IStudent)
50    grok.view(StudentBaseDisplayFormPage)
[11603]51    grok.require('waeup.viewStudent')
52    #grok.require('waeup.manageStudent')
[11597]53    icon = 'actionicon_count.png'
54    text = _('Get Matriculation Number')
55
56    @property
57    def target_url(self):
58        students_utils = getUtility(IStudentsUtils)
59        if self.context.matric_number:
60            return ''
[12975]61        error, matric_number = students_utils.constructMatricNumber(
62            self.context)
[11626]63        if error:
[11597]64            return ''
65        return self.view.url(self.view.context, 'get_matric_number')
[11607]66
67class MatricNumberSlipActionButton(ManageActionButton):
68    grok.order(10)
69    grok.context(IStudent)
70    grok.view(StudentBaseDisplayFormPage)
71    grok.require('waeup.viewStudent')
72    icon = 'actionicon_pdf.png'
73    text = _('Download matriculation number slip')
74    target = 'matric_number_slip.pdf'
75
76    @property
77    def target_url(self):
78        if self.context.state not in (PAID,) or not self.context.is_fresh \
79            or not self.context.matric_number:
80            return ''
[13039]81        return self.view.url(self.view.context, self.target)
82
83class CourseRegistrationSlipActionButton(ManageActionButton):
84    grok.order(5)
85    grok.context(ICustomStudentStudyLevel)
86    grok.view(StudyLevelDisplayFormPage)
87    grok.require('waeup.viewStudent')
88    icon = 'actionicon_pdf.png'
89    text = _('Download course registration slip')
90    target = 'course_registration_slip.pdf'
91
92    @property
93    def target_url(self):
94        is_current = self.context.__parent__.is_current
95        if not is_current:
96            return ''
97        if self.context.student.state != REGISTERED \
[13051]98            and self.context.student.current_level == self.context.level:
[13039]99            return ''
[13380]100        return self.view.url(self.view.context, self.target)
101
[13489]102class PersonalDataSlipActionButton(ManageActionButton):
103    grok.order(3)
104    grok.context(ICustomStudent)
105    grok.view(CustomStudentPersonalDisplayFormPage)
106    grok.require('waeup.viewStudent')
107    icon = 'actionicon_pdf.png'
108    text = _('Download personal data slip')
109    target = 'personal_data_slip.pdf'
110
111    @property
112    def target_url(self):
113        if not self.context.father_name:
114            return ''
115        return self.view.url(self.view.context, self.target)
116
[13380]117class StudentPassportActionButton(StudentPassportActionButton):
118    """Inherit from same class in base package, not from kofacustom.nigeria
119    which requires that no application slip exists.
120    """
Note: See TracBrowser for help on using the repository browser.