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

Last change on this file since 14212 was 14207, checked in by Henrik Bettermann, 8 years ago

Students can view the transcript buttons.

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