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

Last change on this file since 8985 was 8970, checked in by Henrik Bettermann, 12 years ago

Rename school fees 3 and 4.

  • Property svn:keywords set to Id
File size: 8.7 KB
Line 
1## $Id: interfaces.py 8970 2012-07-10 12:06:23Z 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    def longtitle():
58        """
59        Returns the long title of a faculty.
60        """
61
62class IFacultyAdd(IFaculty):
63    """Representation of a university faculty.
64    """
65    code = schema.TextLine(
66        title = _(u'Code'),
67        description = _(u'This code will become part of the URL.'),
68        default = u'NA',
69        required = True,
70        readonly = False,
71        )
72
73IFacultyAdd['code'].order =  IFaculty['code'].order
74
75class IFacultiesContainer(IKofaContainer):
76    """A container for faculties.
77    """
78    def addFaculty(faculty):
79        """Add an IFactulty object.
80
81        """
82class IDepartment(IKofaObject):
83    """Representation of a department.
84    """
85    code = schema.TextLine(
86        title = _(u'Code'),
87        default = u'NA',
88        required = True,
89        readonly = True,
90        )
91
92    title = schema.TextLine(
93        title = _(u'Name of department'),
94        default = _(u'Unnamed'),
95        required = True,
96        )
97
98    title_prefix = schema.Choice(
99        title = _(u'Name prefix'),
100        source = InstTypeSource(),
101        default = u'department',
102        required = True,
103        )
104
105    courses = Attribute("A container for courses.")
106    certificates = Attribute("A container for certificates.")
107
108    def longtitle():
109        """
110        Returns the long title of a department.
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 = False,
155        )
156
157    passmark = schema.Int(
158        title = _(u'Passmark'),
159        default = 40,
160        required = False,
161        )
162
163    semester = schema.Choice(
164        title = _(u'Semester/Term'),
165        default = 9,
166        source = SemesterSource(),
167        required = True,
168        )
169
170    def longtitle():
171        """
172        Returns the long title of a course.
173        """
174
175class ICourseAdd(ICourse):
176    """Representation of a course.
177    """
178    code = schema.TextLine(
179        title = _(u'Code'),
180        description = _(u'Enter unique course code which will become part of the URL.'),
181        default = u'NA',
182        required = True,
183        readonly = False,
184        )
185
186ICourseAdd['code'].order =  ICourse['code'].order
187
188class ICertificate(IKofaObject):
189    """Representation of a certificate.
190    """
191    code = schema.TextLine(
192        title = _(u'Code'),
193        default = u'NA',
194        required = True,
195        readonly = True,
196        )
197
198    title = schema.TextLine(
199        title = _(u'Title'),
200        default = _(u'Unnamed Certificate'),
201        required = True,
202        )
203
204    study_mode = schema.Choice(
205        title = _(u'Study Mode'),
206        source = StudyModeSource(),
207        default = u'ug_ft',
208        required = True,
209        )
210
211    start_level = schema.Choice(
212        title = _(u'Start Level'),
213        vocabulary = course_levels,
214        default = 100,
215        required = True,
216        )
217
218    end_level = schema.Choice(
219        title = _(u'End Level'),
220        vocabulary = course_levels,
221        default = 500,
222        required = True,
223        )
224
225    application_category = schema.Choice(
226        title = _(u'Application Category'),
227        source = AppCatSource(),
228        default = u'basic',
229        required = True,
230        )
231
232    school_fee_1 = schema.Float(
233        title = _(u'Initial School Fee'),
234        required = False,
235        )
236
237    school_fee_2 = schema.Float(
238        title = _(u'Returning School Fee'),
239        required = False,
240        )
241
242    school_fee_3 = schema.Float(
243        title = _(u'Foreigner Initial School Fee'),
244        required = False,
245        )
246
247    school_fee_4 = schema.Float(
248        title = _(u'Foreigner Returning School Fee'),
249        required = False,
250        )
251
252    def longtitle():
253        """
254        Returns the long title of a certificate.
255        """
256
257    @invariant
258    def check_pg_conditions(cert):
259        if cert.start_level == 999 and not cert.end_level == 999:
260            raise Invalid(_("Start level and end level must correspond."))
261        if cert.end_level == 999 and not cert.start_level == 999:
262            raise Invalid(_("Start level and end level must correspond."))
263        if cert.study_mode.startswith('pg') and not cert.start_level == 999:
264            raise Invalid(_(
265                "Study mode, start level and end level must correspond."))
266        if cert.start_level == 999  and not cert.study_mode.startswith('pg'):
267            raise Invalid(_(
268                "Study mode, start level and end level must correspond."))
269
270
271class ICertificateAdd(ICertificate):
272    """Representation of a certificate.
273    """
274    code = schema.TextLine(
275        title = _(u'Code'),
276        default = u'NA',
277        description = _(u'Enter unique certificate code which will become part of the URL.'),
278        required = True,
279        readonly = False,
280        )
281
282ICertificateAdd['code'].order =  ICertificate['code'].order
283
284class ICertificatesContainer(IKofaContainer):
285    """A container for certificates.
286    """
287    def addCertificate(certificate):
288        """Add an ICertificate object.
289
290        Returns the key, under which the object was stored.
291        """
292
293class ICertificateCourse(IKofaObject):
294    """A certificatecourse is referring a course and provides some own
295       attributes.
296    """
297    course = schema.Choice(
298        title = _(u'Course'),
299        source = CourseSource(),
300        readonly = True,
301        )
302
303    level = schema.Choice(
304        title = _(u'Level'),
305        required = True,
306        vocabulary = course_levels,
307        readonly = False,
308        )
309
310    mandatory = schema.Bool(
311        title = _(u'Is mandatory course (not elective)'),
312        required = True,
313        default = True,
314        )
315
316    def getCourseCode():
317        """Return the code of the course referred to.
318
319        This is needed for cataloging.
320        """
321
322    def longtitle():
323        """
324        Returns the long title of a certificatecourse.
325        """
326
327
328class ICertificateCourseAdd(ICertificateCourse):
329    """A certificatecourse is referring a course and
330       provides some own attributes.
331    """
332    course = schema.Choice(
333        title = _(u'Course'),
334        source = CourseSource(),
335        readonly = False,
336        )
337
338ICertificateCourseAdd['course'].order =  ICertificateCourse['course'].order
Note: See TracBrowser for help on using the repository browser.