1 | ## $Id: studylevel.py 7548 2012-02-01 11:19:56Z 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 zope.component.interfaces import IFactory |
---|
24 | from waeup.sirp.students.interfaces import ( |
---|
25 | IStudentStudyLevel, IStudentNavigation, ICourseTicket) |
---|
26 | from waeup.sirp.utils.helpers import attrs_to_fields |
---|
27 | from waeup.sirp.students.vocabularies import StudyLevelSource |
---|
28 | |
---|
29 | class 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 | |
---|
59 | StudentStudyLevel = attrs_to_fields(StudentStudyLevel) |
---|
60 | |
---|
61 | class 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 | |
---|
75 | class 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.faculty = None |
---|
93 | self.department = None |
---|
94 | self.fcode = None |
---|
95 | self.dcode = None |
---|
96 | self.credits = None |
---|
97 | self.passmark = None |
---|
98 | self.semester = None |
---|
99 | return |
---|
100 | |
---|
101 | def getStudent(self): |
---|
102 | return self.__parent__.__parent__.__parent__ |
---|
103 | |
---|
104 | CourseTicket = attrs_to_fields(CourseTicket) |
---|
105 | |
---|
106 | class CourseTicketFactory(grok.GlobalUtility): |
---|
107 | """A factory for student study levels. |
---|
108 | """ |
---|
109 | grok.implements(IFactory) |
---|
110 | grok.name(u'waeup.CourseTicket') |
---|
111 | title = u"Create a new course ticket.", |
---|
112 | description = u"This factory instantiates new course ticket instances." |
---|
113 | |
---|
114 | def __call__(self, *args, **kw): |
---|
115 | return CourseTicket() |
---|
116 | |
---|
117 | def getInterfaces(self): |
---|
118 | return implementedBy(CourseTicket) |
---|