source: main/waeup.kofa/branches/uli-py3/src/waeup/kofa/university/interfaces.py @ 17650

Last change on this file since 17650 was 15629, checked in by Henrik Bettermann, 5 years ago

Add score_editing_disabled switch at course level. Plugins must be updated!

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