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

Last change on this file since 13480 was 13399, checked in by Henrik Bettermann, 9 years ago

Set schoolfee default values.

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