source: main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py @ 7903

Last change on this file since 7903 was 7811, checked in by uli, 13 years ago

Rename all non-locales stuff from sirp to kofa.

  • Property svn:keywords set to Id
File size: 4.2 KB
Line 
1## $Id: studylevel.py 7811 2012-03-08 19:00:51Z uli $
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"""
19Container which holds the data of a student study level
20and contains the course tickets.
21"""
22import grok
23from zope.component.interfaces import IFactory
24from waeup.kofa.students.interfaces import (
25    IStudentStudyLevel, IStudentNavigation, ICourseTicket)
26from waeup.kofa.utils.helpers import attrs_to_fields
27from waeup.kofa.students.vocabularies import StudyLevelSource
28
29class StudentStudyLevel(grok.Container):
30    """This is a container for course tickets.
31    """
32    grok.implements(IStudentStudyLevel, IStudentNavigation)
33    grok.provides(IStudentStudyLevel)
34
35    def __init__(self):
36        super(StudentStudyLevel, self).__init__()
37        self.level = None
38        self.validation_date = None
39        self.validated_by = None
40        return
41
42    def getStudent(self):
43        return self.__parent__.__parent__
44
45    @property
46    def level_title(self):
47        studylevelsource = StudyLevelSource()
48        return studylevelsource.factory.getTitle(self.__parent__, self.level)
49
50    def addCourseTicket(self, courseticket):
51        """Add a course ticket object.
52        """
53        if not ICourseTicket.providedBy(courseticket):
54            raise TypeError(
55                'StudentStudyLeves contain only ICourseTicket instances')
56        self[courseticket.code] = courseticket
57        return
58
59StudentStudyLevel = attrs_to_fields(StudentStudyLevel)
60
61class StudentStudyLevelFactory(grok.GlobalUtility):
62    """A factory for student study levels.
63    """
64    grok.implements(IFactory)
65    grok.name(u'waeup.StudentStudyLevel')
66    title = u"Create a new student study level.",
67    description = u"This factory instantiates new student study level instances."
68
69    def __call__(self, *args, **kw):
70        return StudentStudyLevel()
71
72    def getInterfaces(self):
73        return implementedBy(StudentStudyLevel)
74
75class CourseTicket(grok.Model):
76    """This is a course ticket which allows the
77    student to attend the course. Lecturers will enter scores and more at
78    the end of the term.
79
80    A course ticket contains a copy of the original course and
81    course referrer data. If the courses and/or their referrers are removed, the
82    corresponding tickets remain unchanged. So we do not need any event
83    triggered actions on course tickets.
84    """
85    grok.implements(ICourseTicket, IStudentNavigation)
86    grok.provides(ICourseTicket)
87
88    def __init__(self):
89        super(CourseTicket, self).__init__()
90        self.code = None
91        self.title = None
92        self.fcode = None
93        self.dcode = None
94        self.credits = None
95        self.passmark = None
96        self.semester = None
97        return
98
99    def getStudent(self):
100        return self.__parent__.__parent__.__parent__
101
102    def getLevel(self):
103        """Returns the id of the level the ticket has been added to.
104        """
105        return self.__parent__.level
106
107    def getLevelSession(self):
108        """Returns the session of the level the ticket has been added to.
109        """
110        return self.__parent__.level_session
111
112
113CourseTicket = attrs_to_fields(CourseTicket)
114
115class CourseTicketFactory(grok.GlobalUtility):
116    """A factory for student study levels.
117    """
118    grok.implements(IFactory)
119    grok.name(u'waeup.CourseTicket')
120    title = u"Create a new course ticket.",
121    description = u"This factory instantiates new course ticket instances."
122
123    def __call__(self, *args, **kw):
124        return CourseTicket()
125
126    def getInterfaces(self):
127        return implementedBy(CourseTicket)
Note: See TracBrowser for help on using the repository browser.