1 | ## $Id: studylevel.py 7191 2011-11-25 07:13:22Z 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 | """ |
---|
19 | Container which holds the data of a student study level |
---|
20 | and contains the course tickets. |
---|
21 | """ |
---|
22 | import grok |
---|
23 | from grok import index |
---|
24 | from zope.component.interfaces import IFactory |
---|
25 | from waeup.sirp.students.interfaces import ( |
---|
26 | IStudentStudyLevel, IStudentNavigation, ICourseTicket) |
---|
27 | from waeup.sirp.utils.helpers import attrs_to_fields |
---|
28 | from waeup.sirp.students.vocabularies import StudyLevelSource |
---|
29 | |
---|
30 | class StudentStudyLevel(grok.Container): |
---|
31 | """This is a container for course tickets. |
---|
32 | """ |
---|
33 | grok.implements(IStudentStudyLevel, IStudentNavigation) |
---|
34 | grok.provides(IStudentStudyLevel) |
---|
35 | |
---|
36 | def __init__(self): |
---|
37 | super(StudentStudyLevel, self).__init__() |
---|
38 | self.level = None |
---|
39 | self.validation_date = None |
---|
40 | self.validated_by = None |
---|
41 | return |
---|
42 | |
---|
43 | def getStudent(self): |
---|
44 | return self.__parent__.__parent__ |
---|
45 | |
---|
46 | @property |
---|
47 | def level_title(self): |
---|
48 | studylevelsource = StudyLevelSource() |
---|
49 | return studylevelsource.factory.getTitle(self.__parent__, self.level) |
---|
50 | |
---|
51 | def addCourseTicket(self, courseticket): |
---|
52 | """Add a course ticket object. |
---|
53 | """ |
---|
54 | if not ICourseTicket.providedBy(courseticket): |
---|
55 | raise TypeError( |
---|
56 | 'StudentStudyLeves contain only ICourseTicket instances') |
---|
57 | self[courseticket.code] = courseticket |
---|
58 | return |
---|
59 | |
---|
60 | StudentStudyLevel = attrs_to_fields(StudentStudyLevel) |
---|
61 | |
---|
62 | class CourseTicket(grok.Model): |
---|
63 | """This is a course ticket which allows the |
---|
64 | student to attend the course. Lecturers will enter scores and more at |
---|
65 | the end of the term. |
---|
66 | |
---|
67 | A course ticket contains a copy of the original course and |
---|
68 | course referrer data. If the courses and/or their referrers are removed, the |
---|
69 | corresponding tickets remain unchanged. So we do not need any event |
---|
70 | triggered actions on course tickets. |
---|
71 | """ |
---|
72 | grok.implements(ICourseTicket, IStudentNavigation) |
---|
73 | grok.provides(ICourseTicket) |
---|
74 | |
---|
75 | def __init__(self): |
---|
76 | super(CourseTicket, self).__init__() |
---|
77 | self.code = None |
---|
78 | self.title = None |
---|
79 | self.faculty = None |
---|
80 | self.department = None |
---|
81 | self.credits = None |
---|
82 | self.passmark = None |
---|
83 | self.semester = None |
---|
84 | return |
---|
85 | |
---|
86 | def getStudent(self): |
---|
87 | return self.__parent__.__parent__.__parent__ |
---|
88 | |
---|
89 | CourseTicket = attrs_to_fields(CourseTicket) |
---|