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

Last change on this file since 16966 was 16703, checked in by Henrik Bettermann, 3 years ago

Remove 'ratio' field. It's obviously not used.

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