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

Last change on this file since 17253 was 16703, checked in by Henrik Bettermann, 3 years ago

Remove 'ratio' field. It's obviously not used.

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