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

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

Update pot file.

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