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

Last change on this file since 10650 was 10650, checked in by Henrik Bettermann, 11 years ago

Convert longtitle() into property attribute.

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