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

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

Add DegreeSource? and degree field to Certificate. Plugins must be updated!

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