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

Last change on this file since 13599 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
RevLine 
[7195]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##
[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,
[5995]32    )
[5004]33
[7819]34class IFaculty(IKofaContainer):
[5004]35    """Representation of a university faculty.
36    """
[5948]37    code = schema.TextLine(
[7707]38        title = _(u'Code'),
[5948]39        default = u'NA',
40        required = True,
[12414]41        constraint=validate_id,
[5948]42        )
43
[5004]44    title = schema.TextLine(
[7707]45        title = _(u'Name of faculty'),
[10787]46        default = u'Unnamed',
[5004]47        required = True,
48        )
49
[5988]50    title_prefix = schema.Choice(
[7707]51        title = _(u'Name prefix'),
[5004]52        default = u'faculty',
[7681]53        source = InstTypeSource(),
[5004]54        required = True,
55        )
[6561]56
57
[7819]58class IFacultiesContainer(IKofaContainer):
[5004]59    """A container for faculties.
60    """
61    def addFaculty(faculty):
62        """Add an IFactulty object.
63
64        """
[7819]65class IDepartment(IKofaObject):
[5004]66    """Representation of a department.
67    """
[5948]68    code = schema.TextLine(
[7707]69        title = _(u'Code'),
[5948]70        default = u'NA',
71        required = True,
[12414]72        constraint=validate_id,
[5948]73        )
74
[5004]75    title = schema.TextLine(
[7707]76        title = _(u'Name of department'),
[10787]77        default = u'Unnamed',
[5004]78        required = True,
79        )
80
[5988]81    title_prefix = schema.Choice(
[7707]82        title = _(u'Name prefix'),
[7681]83        source = InstTypeSource(),
[5004]84        default = u'department',
85        required = True,
86        )
87
[10634]88    score_editing_disabled = schema.Bool(
89        title = _(u'Score editing disabled'),
90        description = _(
[10642]91            u'Lectures can not edit scores if ticked.'),
[10634]92        required = False,
93        default = False,
94        )
95
[5004]96    courses = Attribute("A container for courses.")
97    certificates = Attribute("A container for certificates.")
[6561]98
99
[7819]100class ICoursesContainer(IKofaContainer):
[5004]101    """A container for faculties.
102    """
[6640]103    def addCourse(course):
[5004]104        """Add an ICourse object.
105
106        Returns the key, under which the object was stored.
107        """
108
[7819]109class ICourse(IKofaObject):
[5004]110    """Representation of a course.
111    """
112    code = schema.TextLine(
[7707]113        title = _(u'Code'),
[5004]114        default = u'NA',
115        required = True,
[12414]116        constraint=validate_id,
[5004]117        )
118
119    title = schema.TextLine(
[7707]120        title = _(u'Title of course'),
[10787]121        default = u'Unnamed',
[5004]122        required = True,
123        )
124
125    credits = schema.Int(
[7707]126        title = _(u'Credits'),
[5004]127        default = 0,
[9315]128        required = True,
[5004]129        )
[6561]130
[5004]131    passmark = schema.Int(
[7707]132        title = _(u'Passmark'),
[5004]133        default = 40,
[9315]134        required = True,
[5004]135        )
136
137    semester = schema.Choice(
[7707]138        title = _(u'Semester/Term'),
[7601]139        default = 9,
[7681]140        source = SemesterSource(),
[5004]141        required = True,
142        )
[6561]143
[9220]144    former_course = schema.Bool(
[10830]145        title = _(u'Former course'),
[9220]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
[5004]153
[7819]154class ICertificate(IKofaObject):
[5004]155    """Representation of a certificate.
156    """
157    code = schema.TextLine(
[7707]158        title = _(u'Code'),
[5004]159        default = u'NA',
160        required = True,
[12414]161        constraint=validate_id,
[5004]162        )
163
164    title = schema.TextLine(
[7707]165        title = _(u'Title'),
[11838]166        default = u'Unnamed',
[5004]167        required = True,
168        )
169
[5986]170    study_mode = schema.Choice(
[7707]171        title = _(u'Study Mode'),
[7681]172        source = StudyModeSource(),
[5951]173        default = u'ug_ft',
[5004]174        required = True,
175        )
176
[5977]177    start_level = schema.Choice(
[7707]178        title = _(u'Start Level'),
[5977]179        vocabulary = course_levels,
180        default = 100,
[5004]181        required = True,
182        )
[6561]183
[5977]184    end_level = schema.Choice(
[7707]185        title = _(u'End Level'),
[5977]186        vocabulary = course_levels,
187        default = 500,
[5004]188        required = True,
189        )
[6561]190
[5986]191    application_category = schema.Choice(
[7707]192        title = _(u'Application Category'),
[7681]193        source = AppCatSource(),
[5951]194        default = u'basic',
[5986]195        required = True,
[6561]196        )
[5004]197
[8299]198    school_fee_1 = schema.Float(
199        title = _(u'Initial School Fee'),
200        required = False,
[13399]201        default = 0.0,
[8299]202        )
203
204    school_fee_2 = schema.Float(
205        title = _(u'Returning School Fee'),
206        required = False,
[13399]207        default = 0.0,
[8299]208        )
209
[8967]210    school_fee_3 = schema.Float(
[8970]211        title = _(u'Foreigner Initial School Fee'),
[8967]212        required = False,
[13399]213        default = 0.0,
[8967]214        )
215
216    school_fee_4 = schema.Float(
[8970]217        title = _(u'Foreigner Returning School Fee'),
[8967]218        required = False,
[13399]219        default = 0.0,
[8967]220        )
221
[10166]222    ratio = schema.Float(
223        title = _(u'Installment Ratio'),
224        required = False,
225        min = 0.0,
226        max = 1.0,
227        )
228
[10185]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
[8472]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
[7819]263class ICertificatesContainer(IKofaContainer):
[5004]264    """A container for certificates.
265    """
[6640]266    def addCertificate(certificate):
[5004]267        """Add an ICertificate object.
268
269        Returns the key, under which the object was stored.
270        """
271
[7819]272class ICertificateCourse(IKofaObject):
[6561]273    """A certificatecourse is referring a course and provides some own
274       attributes.
[5004]275    """
276    course = schema.Choice(
[8920]277        title = _(u'Course'),
[5004]278        source = CourseSource(),
279        )
[6561]280
[5977]281    level = schema.Choice(
[7707]282        title = _(u'Level'),
[5004]283        required = True,
[5977]284        vocabulary = course_levels,
[5950]285        readonly = False,
[5004]286        )
287
[7665]288    mandatory = schema.Bool(
[9246]289        title = _(u'Registration required'),
[9035]290        required = False,
[5950]291        default = True,
[5004]292        )
293
294    def getCourseCode():
[5977]295        """Return the code of the course referred to.
[5004]296
297        This is needed for cataloging.
[10685]298        """
Note: See TracBrowser for help on using the repository browser.