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

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

Add course_category attribute to certificate courses. Plugins must be updated!

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