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

Last change on this file since 11062 was 10830, checked in by Henrik Bettermann, 11 years ago

Update pot file.

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