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

Last change on this file since 15685 was 15629, checked in by Henrik Bettermann, 5 years ago

Add score_editing_disabled switch at course level. Plugins must be updated!

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