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

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

Disable score editing on department manage page.

Add tests.

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