source: main/waeup.kofa/trunk/src/waeup/kofa/university/interfaces.py @ 14646

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

Add course_category attribute to certificate courses. Plugins must be updated!

  • Property svn:keywords set to Id
File size: 8.8 KB
Line 
1## $Id: interfaces.py 14638 2017-03-21 10:13:41Z 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, invariant, Invalid
23from waeup.kofa.interfaces import IKofaObject, IKofaContainer, validate_id
24from waeup.kofa.interfaces import MessageFactory as _
25from waeup.kofa.university.vocabularies import (
26    course_levels,
27    CourseSource,
28    StudyModeSource,
29    AppCatSource,
30    InstTypeSource,
31    SemesterSource,
32    DegreeSource,
33    CourseCategorySource
34    )
35
36class IFaculty(IKofaContainer):
37    """Representation of a university faculty.
38    """
39    code = schema.TextLine(
40        title = _(u'Code'),
41        default = u'NA',
42        required = True,
43        constraint=validate_id,
44        )
45
46    title = schema.TextLine(
47        title = _(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    officer_1 = schema.TextLine(
60        title = _(u'Faculty Officer 1'),
61        default = u'',
62        required = False,
63        )
64
65    officer_2 = schema.TextLine(
66        title = _(u'Faculty Officer 2'),
67        default = u'',
68        required = False,
69        )
70
71
72class IFacultiesContainer(IKofaContainer):
73    """A container for faculties.
74    """
75    def addFaculty(faculty):
76        """Add an IFactulty object.
77
78        """
79class IDepartment(IKofaObject):
80    """Representation of a department.
81    """
82    code = schema.TextLine(
83        title = _(u'Code'),
84        default = u'NA',
85        required = True,
86        constraint=validate_id,
87        )
88
89    title = schema.TextLine(
90        title = _(u'Name of department'),
91        default = u'Unnamed',
92        required = True,
93        )
94
95    title_prefix = schema.Choice(
96        title = _(u'Name prefix'),
97        source = InstTypeSource(),
98        default = u'department',
99        required = True,
100        )
101
102    score_editing_disabled = schema.Bool(
103        title = _(u'Score editing disabled'),
104        description = _(
105            u'Lectures can not edit scores if ticked.'),
106        required = False,
107        default = False,
108        )
109
110    officer_1 = schema.TextLine(
111        title = _(u'Department Officer 1'),
112        default = u'',
113        required = False,
114        )
115
116    officer_2 = schema.TextLine(
117        title = _(u'Department Officer 2'),
118        default = u'',
119        required = False,
120        )
121
122    officer_3 = schema.TextLine(
123        title = _(u'Department Officer 3'),
124        default = u'',
125        required = False,
126        )
127
128    officer_4 = schema.TextLine(
129        title = _(u'Department Officer 4'),
130        default = u'',
131        required = False,
132        )
133
134    courses = Attribute("A container for courses.")
135    certificates = Attribute("A container for certificates.")
136
137
138class ICoursesContainer(IKofaContainer):
139    """A container for faculties.
140    """
141    def addCourse(course):
142        """Add an ICourse object.
143
144        Returns the key, under which the object was stored.
145        """
146
147class ICourse(IKofaObject):
148    """Representation of a course.
149    """
150    code = schema.TextLine(
151        title = _(u'Code'),
152        default = u'NA',
153        required = True,
154        constraint=validate_id,
155        )
156
157    title = schema.TextLine(
158        title = _(u'Title of course'),
159        default = u'Unnamed',
160        required = True,
161        )
162
163    credits = schema.Int(
164        title = _(u'Credits'),
165        default = 0,
166        required = True,
167        )
168
169    passmark = schema.Int(
170        title = _(u'Passmark'),
171        default = 40,
172        required = True,
173        )
174
175    semester = schema.Choice(
176        title = _(u'Semester/Term'),
177        default = 9,
178        source = SemesterSource(),
179        required = True,
180        )
181
182    former_course = schema.Bool(
183        title = _(u'Former course'),
184        description = _(
185            u'If this attribute is being set all certificate courses '
186            'referring to this course will be automatically deleted.'),
187        required = False,
188        default = False,
189        )
190
191
192class ICertificate(IKofaObject):
193    """Representation of a certificate.
194    """
195    code = schema.TextLine(
196        title = _(u'Code'),
197        default = u'NA',
198        required = True,
199        constraint=validate_id,
200        )
201
202    title = schema.TextLine(
203        title = _(u'Title'),
204        default = u'Unnamed',
205        required = True,
206        )
207
208    study_mode = schema.Choice(
209        title = _(u'Study Mode'),
210        source = StudyModeSource(),
211        default = u'ug_ft',
212        required = True,
213        )
214
215    degree = schema.Choice(
216        title = _(u'Degree'),
217        source = DegreeSource(),
218        required = False,
219        )
220
221    start_level = schema.Choice(
222        title = _(u'Start Level'),
223        vocabulary = course_levels,
224        default = 100,
225        required = True,
226        )
227
228    end_level = schema.Choice(
229        title = _(u'End Level'),
230        vocabulary = course_levels,
231        default = 500,
232        required = True,
233        )
234
235    application_category = schema.Choice(
236        title = _(u'Application Category'),
237        source = AppCatSource(),
238        default = u'basic',
239        required = True,
240        )
241
242    school_fee_1 = schema.Float(
243        title = _(u'Initial School Fee'),
244        required = False,
245        default = 0.0,
246        )
247
248    school_fee_2 = schema.Float(
249        title = _(u'Returning School Fee'),
250        required = False,
251        default = 0.0,
252        )
253
254    school_fee_3 = schema.Float(
255        title = _(u'Foreigner Initial School Fee'),
256        required = False,
257        default = 0.0,
258        )
259
260    school_fee_4 = schema.Float(
261        title = _(u'Foreigner Returning School Fee'),
262        required = False,
263        default = 0.0,
264        )
265
266    ratio = schema.Float(
267        title = _(u'Installment Ratio'),
268        required = False,
269        min = 0.0,
270        max = 1.0,
271        )
272
273    custom_textline_1 = schema.TextLine(
274        title = _(u'Custom Textline 1 (not used)'),
275        required = False,
276        )
277
278    custom_textline_2 = schema.TextLine(
279        title = _(u'Custom Textline 2 (not used)'),
280        required = False,
281        )
282
283    custom_float_1 = schema.Float(
284        title = _(u'Custom Float 1 (not used)'),
285        required = False,
286        )
287
288    custom_float_2 = schema.Float(
289        title = _(u'Custom Float 2 (not used)'),
290        required = False,
291        )
292
293    @invariant
294    def check_pg_conditions(cert):
295        if cert.start_level == 999 and not cert.end_level == 999:
296            raise Invalid(_("Start level and end level must correspond."))
297        if cert.end_level == 999 and not cert.start_level == 999:
298            raise Invalid(_("Start level and end level must correspond."))
299        if cert.study_mode.startswith('pg') and not cert.start_level == 999:
300            raise Invalid(_(
301                "Study mode, start level and end level must correspond."))
302        if cert.start_level == 999  and not cert.study_mode.startswith('pg'):
303            raise Invalid(_(
304                "Study mode, start level and end level must correspond."))
305
306
307class ICertificatesContainer(IKofaContainer):
308    """A container for certificates.
309    """
310    def addCertificate(certificate):
311        """Add an ICertificate object.
312
313        Returns the key, under which the object was stored.
314        """
315
316class ICertificateCourse(IKofaObject):
317    """A certificatecourse is referring a course and provides some own
318       attributes.
319    """
320    course = schema.Choice(
321        title = _(u'Course'),
322        source = CourseSource(),
323        )
324
325    level = schema.Choice(
326        title = _(u'Level'),
327        required = True,
328        vocabulary = course_levels,
329        readonly = False,
330        )
331
332    course_category = schema.Choice(
333        title = _(u'Course Category'),
334        source = CourseCategorySource(),
335        required = False,
336        )
337
338    mandatory = schema.Bool(
339        title = _(u'Registration required'),
340        required = False,
341        default = True,
342        )
343
344    def getCourseCode():
345        """Return the code of the course referred to.
346
347        This is needed for cataloging.
348        """
Note: See TracBrowser for help on using the repository browser.