source: main/waeup.sirp/trunk/src/waeup/sirp/university/interfaces.py @ 7681

Last change on this file since 7681 was 7681, checked in by Henrik Bettermann, 13 years ago

Uses sources instead of vocabularies and feed sources with dictionaries defined in SIRPUtils. This way we can easily customize the sources.

  • Property svn:keywords set to Id
File size: 7.5 KB
Line 
1## $Id: interfaces.py 7681 2012-02-22 21:14:09Z 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"""Interfaces of academics specific objects.
19"""
20
21from zope import schema
22from zope.interface import Attribute
23import zope.i18nmessageid
24from waeup.sirp.interfaces import (ISIRPObject, ISIRPContainer)
25from waeup.sirp.interfaces import MessageFactory as _
26from waeup.sirp.university.vocabularies import (
27    course_levels,
28    CourseSource,
29    StudyModeSource,
30    AppCatSource,
31    InstTypeSource,
32    SemesterSource,
33    )
34
35
36class IFaculty(ISIRPContainer):
37    """Representation of a university faculty.
38    """
39    code = schema.TextLine(
40        title = u'Code',
41        default = u'NA',
42        required = True,
43        readonly = True,
44        )
45
46    title = schema.TextLine(
47        title = _(u'name_of_faculty', default=u'Name of faculty'),
48        default = u'Unnamed',
49        required = True,
50        )
51
52    title_prefix = schema.Choice(
53        title = u'Name prefix',
54        default = u'faculty',
55        source = InstTypeSource(),
56        required = True,
57        )
58
59    def longtitle():
60        """
61        Returns the long title of a faculty.
62        """
63
64class IFacultyAdd(IFaculty):
65    """Representation of a university faculty.
66    """
67    code = schema.TextLine(
68        title = u'Code',
69        description = u'This code will become part of the URL.',
70        default = u'NA',
71        required = True,
72        readonly = False,
73        )
74
75IFacultyAdd['code'].order =  IFaculty['code'].order
76
77class IFacultiesContainer(ISIRPContainer):
78    """A container for faculties.
79    """
80    def addFaculty(faculty):
81        """Add an IFactulty object.
82
83        """
84class IDepartment(ISIRPObject):
85    """Representation of a department.
86    """
87    code = schema.TextLine(
88        title = u'Code',
89        default = u'NA',
90        required = True,
91        readonly = True,
92        )
93
94    title = schema.TextLine(
95        title = u'Name of department',
96        default = u'Unnamed',
97        required = True,
98        )
99
100    title_prefix = schema.Choice(
101        title = u'Name prefix',
102        source = InstTypeSource(),
103        default = u'department',
104        required = True,
105        )
106
107    courses = Attribute("A container for courses.")
108    certificates = Attribute("A container for certificates.")
109
110    def longtitle():
111        """
112        Returns the long title of a department.
113        """
114
115class IDepartmentAdd(IDepartment):
116    """Representation of a university department.
117    """
118    code = schema.TextLine(
119        title = u'Code',
120        description = u'This code will become part of the URL.',
121        default = u'NA',
122        required = True,
123        readonly = False,
124        )
125
126IDepartmentAdd['code'].order =  IDepartment['code'].order
127
128class ICoursesContainer(ISIRPContainer):
129    """A container for faculties.
130    """
131    def addCourse(course):
132        """Add an ICourse object.
133
134        Returns the key, under which the object was stored.
135        """
136
137class ICourse(ISIRPObject):
138    """Representation of a course.
139    """
140    code = schema.TextLine(
141        title = u'Code',
142        default = u'NA',
143        required = True,
144        readonly = True,
145        )
146
147    title = schema.TextLine(
148        title = u'Title of course',
149        default = u'Unnamed',
150        required = True,
151        )
152
153    credits = schema.Int(
154        title = u'Credits',
155        default = 0,
156        required = False,
157        )
158
159    passmark = schema.Int(
160        title = u'Passmark',
161        default = 40,
162        required = False,
163        )
164
165    semester = schema.Choice(
166        title = u'Semester/Term',
167        default = 9,
168        source = SemesterSource(),
169        required = True,
170        )
171
172    def longtitle():
173        """
174        Returns the long title of a course.
175        """
176
177class ICourseAdd(ICourse):
178    """Representation of a course.
179    """
180    code = schema.TextLine(
181        title = u'Code',
182        description = u'Enter unique course code which will become part of the URL.',
183        default = u'NA',
184        required = True,
185        readonly = False,
186        )
187
188ICourseAdd['code'].order =  ICourse['code'].order
189
190class ICertificate(ISIRPObject):
191    """Representation of a certificate.
192    """
193    code = schema.TextLine(
194        title = u'Code',
195        default = u'NA',
196        required = True,
197        readonly = True,
198        )
199
200    title = schema.TextLine(
201        title = u'Title',
202        default = u'Unnamed',
203        required = True,
204        )
205
206    study_mode = schema.Choice(
207        title = u'Study Mode',
208        source = StudyModeSource(),
209        default = u'ug_ft',
210        required = True,
211        )
212
213    start_level = schema.Choice(
214        title = u'Start Level',
215        vocabulary = course_levels,
216        default = 100,
217        required = True,
218        )
219
220    end_level = schema.Choice(
221        title = u'End Level',
222        vocabulary = course_levels,
223        default = 500,
224        required = True,
225        )
226
227    application_category = schema.Choice(
228        title = u'Application Category',
229        source = AppCatSource(),
230        default = u'basic',
231        required = True,
232        )
233
234    def longtitle():
235        """
236        Returns the long title of a certificate.
237        """
238
239class ICertificateAdd(ICertificate):
240    """Representation of a certificate.
241    """
242    code = schema.TextLine(
243        title = u'Code',
244        default = u'NA',
245        description = u'Enter unique certificate code which will become part of the URL.',
246        required = True,
247        readonly = False,
248        )
249
250ICertificateAdd['code'].order =  ICertificate['code'].order
251
252class ICertificatesContainer(ISIRPContainer):
253    """A container for certificates.
254    """
255    def addCertificate(certificate):
256        """Add an ICertificate object.
257
258        Returns the key, under which the object was stored.
259        """
260
261class ICertificateCourse(ISIRPObject):
262    """A certificatecourse is referring a course and provides some own
263       attributes.
264    """
265    course = schema.Choice(
266        title = u'Course referrer',
267        source = CourseSource(),
268        readonly = True,
269        )
270
271    level = schema.Choice(
272        title = u'Level',
273        required = True,
274        vocabulary = course_levels,
275        readonly = False,
276        )
277
278    mandatory = schema.Bool(
279        title = u'Is mandatory course (not elective)',
280        required = True,
281        default = True,
282        )
283
284    def getCourseCode():
285        """Return the code of the course referred to.
286
287        This is needed for cataloging.
288        """
289
290    def longtitle():
291        """
292        Returns the long title of a certificatecourse.
293        """
294
295
296class ICertificateCourseAdd(ICertificateCourse):
297    """A certificatecourse is referring a course and
298       provides some own attributes.
299    """
300    course = schema.Choice(
301        title = u'Course',
302        source = CourseSource(),
303        readonly = False,
304        )
305
306ICertificateCourseAdd['course'].order =  ICertificateCourse['course'].order
Note: See TracBrowser for help on using the repository browser.