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

Last change on this file since 10669 was 10650, checked in by Henrik Bettermann, 12 years ago

Convert longtitle() into property attribute.

  • Property svn:keywords set to Id
File size: 9.4 KB
RevLine 
[7195]1## $Id: interfaces.py 10650 2013-09-25 06:46:53Z 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        readonly = True,
42        )
43
[5004]44    title = schema.TextLine(
[7707]45        title = _(u'Name of faculty'),
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
[5951]58class IFacultyAdd(IFaculty):
59    """Representation of a university faculty.
60    """
61    code = schema.TextLine(
[7707]62        title = _(u'Code'),
63        description = _(u'This code will become part of the URL.'),
[5951]64        default = u'NA',
65        required = True,
66        readonly = False,
67        )
[6561]68
69IFacultyAdd['code'].order =  IFaculty['code'].order
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,
85        readonly = True,
86        )
87
[5004]88    title = schema.TextLine(
[7707]89        title = _(u'Name of department'),
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
[5004]109    courses = Attribute("A container for courses.")
110    certificates = Attribute("A container for certificates.")
[6561]111
112
[5951]113class IDepartmentAdd(IDepartment):
114    """Representation of a university department.
115    """
116    code = schema.TextLine(
[7707]117        title = _(u'Code'),
118        description = _(u'This code will become part of the URL.'),
[5951]119        default = u'NA',
120        required = True,
121        readonly = False,
122        )
[5004]123
[6561]124IDepartmentAdd['code'].order =  IDepartment['code'].order
125
[7819]126class ICoursesContainer(IKofaContainer):
[5004]127    """A container for faculties.
128    """
[6640]129    def addCourse(course):
[5004]130        """Add an ICourse object.
131
132        Returns the key, under which the object was stored.
133        """
134
[7819]135class ICourse(IKofaObject):
[5004]136    """Representation of a course.
137    """
138    code = schema.TextLine(
[7707]139        title = _(u'Code'),
[5004]140        default = u'NA',
141        required = True,
142        readonly = True,
143        )
144
145    title = schema.TextLine(
[7707]146        title = _(u'Title of course'),
147        default = _(u'Unnamed'),
[5004]148        required = True,
149        )
150
151    credits = schema.Int(
[7707]152        title = _(u'Credits'),
[5004]153        default = 0,
[9315]154        required = True,
[5004]155        )
[6561]156
[5004]157    passmark = schema.Int(
[7707]158        title = _(u'Passmark'),
[5004]159        default = 40,
[9315]160        required = True,
[5004]161        )
162
163    semester = schema.Choice(
[7707]164        title = _(u'Semester/Term'),
[7601]165        default = 9,
[7681]166        source = SemesterSource(),
[5004]167        required = True,
168        )
[6561]169
[9220]170    former_course = schema.Bool(
171        title = _(u'Former Course'),
172        description = _(
173            u'If this attribute is being set all certificate courses '
174            'referring to this course will be automatically deleted.'),
175        required = False,
176        default = False,
177        )
178
[5004]179
[5951]180class ICourseAdd(ICourse):
181    """Representation of a course.
182    """
183    code = schema.TextLine(
[7707]184        title = _(u'Code'),
185        description = _(u'Enter unique course code which will become part of the URL.'),
[5951]186        default = u'NA',
187        required = True,
188        readonly = False,
189        )
[5004]190
[6561]191ICourseAdd['code'].order =  ICourse['code'].order
192
[7819]193class ICertificate(IKofaObject):
[5004]194    """Representation of a certificate.
195    """
196    code = schema.TextLine(
[7707]197        title = _(u'Code'),
[5004]198        default = u'NA',
199        required = True,
[5948]200        readonly = True,
[5004]201        )
202
203    title = schema.TextLine(
[7707]204        title = _(u'Title'),
[8299]205        default = _(u'Unnamed Certificate'),
[5004]206        required = True,
207        )
208
[5986]209    study_mode = schema.Choice(
[7707]210        title = _(u'Study Mode'),
[7681]211        source = StudyModeSource(),
[5951]212        default = u'ug_ft',
[5004]213        required = True,
214        )
215
[5977]216    start_level = schema.Choice(
[7707]217        title = _(u'Start Level'),
[5977]218        vocabulary = course_levels,
219        default = 100,
[5004]220        required = True,
221        )
[6561]222
[5977]223    end_level = schema.Choice(
[7707]224        title = _(u'End Level'),
[5977]225        vocabulary = course_levels,
226        default = 500,
[5004]227        required = True,
228        )
[6561]229
[5986]230    application_category = schema.Choice(
[7707]231        title = _(u'Application Category'),
[7681]232        source = AppCatSource(),
[5951]233        default = u'basic',
[5986]234        required = True,
[6561]235        )
[5004]236
[8299]237    school_fee_1 = schema.Float(
238        title = _(u'Initial School Fee'),
239        required = False,
240        )
241
242    school_fee_2 = schema.Float(
243        title = _(u'Returning School Fee'),
244        required = False,
245        )
246
[8967]247    school_fee_3 = schema.Float(
[8970]248        title = _(u'Foreigner Initial School Fee'),
[8967]249        required = False,
250        )
251
252    school_fee_4 = schema.Float(
[8970]253        title = _(u'Foreigner Returning School Fee'),
[8967]254        required = False,
255        )
256
[10166]257    ratio = schema.Float(
258        title = _(u'Installment Ratio'),
259        required = False,
260        min = 0.0,
261        max = 1.0,
262        )
263
[10185]264    custom_textline_1 = schema.TextLine(
265        title = _(u'Custom Textline 1 (not used)'),
266        required = False,
267        )
268
269    custom_textline_2 = schema.TextLine(
270        title = _(u'Custom Textline 2 (not used)'),
271        required = False,
272        )
273
274    custom_float_1 = schema.Float(
275        title = _(u'Custom Float 1 (not used)'),
276        required = False,
277        )
278
279    custom_float_2 = schema.Float(
280        title = _(u'Custom Float 2 (not used)'),
281        required = False,
282        )
283
[8472]284    @invariant
285    def check_pg_conditions(cert):
286        if cert.start_level == 999 and not cert.end_level == 999:
287            raise Invalid(_("Start level and end level must correspond."))
288        if cert.end_level == 999 and not cert.start_level == 999:
289            raise Invalid(_("Start level and end level must correspond."))
290        if cert.study_mode.startswith('pg') and not cert.start_level == 999:
291            raise Invalid(_(
292                "Study mode, start level and end level must correspond."))
293        if cert.start_level == 999  and not cert.study_mode.startswith('pg'):
294            raise Invalid(_(
295                "Study mode, start level and end level must correspond."))
296
297
[5951]298class ICertificateAdd(ICertificate):
299    """Representation of a certificate.
300    """
301    code = schema.TextLine(
[7707]302        title = _(u'Code'),
[5951]303        default = u'NA',
[7707]304        description = _(u'Enter unique certificate code which will become part of the URL.'),
[5951]305        required = True,
306        readonly = False,
307        )
[6561]308
309ICertificateAdd['code'].order =  ICertificate['code'].order
310
[7819]311class ICertificatesContainer(IKofaContainer):
[5004]312    """A container for certificates.
313    """
[6640]314    def addCertificate(certificate):
[5004]315        """Add an ICertificate object.
316
317        Returns the key, under which the object was stored.
318        """
319
[7819]320class ICertificateCourse(IKofaObject):
[6561]321    """A certificatecourse is referring a course and provides some own
322       attributes.
[5004]323    """
324    course = schema.Choice(
[8920]325        title = _(u'Course'),
[5004]326        source = CourseSource(),
[5950]327        readonly = True,
[5004]328        )
[6561]329
[5977]330    level = schema.Choice(
[7707]331        title = _(u'Level'),
[5004]332        required = True,
[5977]333        vocabulary = course_levels,
[5950]334        readonly = False,
[5004]335        )
336
[7665]337    mandatory = schema.Bool(
[9246]338        title = _(u'Registration required'),
[9035]339        required = False,
[5950]340        default = True,
[5004]341        )
342
343    def getCourseCode():
[5977]344        """Return the code of the course referred to.
[5004]345
346        This is needed for cataloging.
347        """
[6561]348
[5951]349class ICertificateCourseAdd(ICertificateCourse):
[6561]350    """A certificatecourse is referring a course and
[5951]351       provides some own attributes.
352    """
353    course = schema.Choice(
[7707]354        title = _(u'Course'),
[5951]355        source = CourseSource(),
356        readonly = False,
357        )
[6561]358
359ICertificateCourseAdd['course'].order =  ICertificateCourse['course'].order
Note: See TracBrowser for help on using the repository browser.