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

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

Add officer name fields do IDepartment and IFaculty. Plugins must be updated!

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