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

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

Add officer name fields do IDepartment and IFaculty. Plugins must be updated!

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