source: main/waeup.sirp/trunk/src/waeup/sirp/university/interfaces.py @ 5948

Last change on this file since 5948 was 5948, checked in by Henrik Bettermann, 14 years ago

Set all code attributes readonly but ensure that code can be filled in AddFormPages?.

File size: 5.2 KB
RevLine 
[5004]1"""Interfaces of academics specific objects.
2"""
3from zc.sourcefactory.basic import BasicSourceFactory
4from zope import schema
[5051]5try:
6    from zope.catalog.interfaces import ICatalog
7except ImportError:
8    # BBB
9    from zope.app.catalog.interfaces import ICatalog
[5004]10from zope.component import getUtility
11from zope.interface import Attribute
12from waeup.sirp.interfaces import (IWAeUPObject, IWAeUPContainer,
13                                   SimpleWAeUPVocabulary)
14
15class CourseSource(BasicSourceFactory):
16    """A course source delivers all courses inside the portal by looking
17       up a catalog.
18    """
19    def getValues(self):
20        catalog = getUtility(ICatalog, name='courses_catalog')
21        return list(catalog.searchResults(code=('', 'z*')))
22
23    def getToken(self, value):
24        return value.code
25       
26    def getTitle(self, value):
27        return "%s %s" % (value.code, value.title[:32])
28
29class IFaculty(IWAeUPContainer):
30    """Representation of a university faculty.
31    """
[5948]32    code = schema.TextLine(
33        title = u'Code',
34        description = u'Abbreviated code of the faculty',
35        default = u'NA',
36        required = True,
37        readonly = True,
38        )
39
[5004]40    title = schema.TextLine(
41        title = u'Name of Faculty',
42        default = u'Unnamed',
43        required = True,
44        )
45
46    title_prefix = schema.TextLine(
47        title = u'Title prefix',
48        default = u'faculty',
49        required = True,
50        )
51   
52class IFacultyContainer(IWAeUPContainer):
53    """A container for faculties.
54    """
55    def addFaculty(faculty):
56        """Add an IFactulty object.
57
58        Returns the key, under which the object was stored.
59        """
60class IDepartment(IWAeUPObject):
61    """Representation of a department.
62    """
[5948]63    code = schema.TextLine(
64        title = u'Code',
65        default = u'NA',
66        description = u'Abbreviated code of the department',
67        required = True,
68        readonly = True,
69        )
70
[5004]71    title = schema.TextLine(
72        title = u'Name of Department',
73        default = u'Unnamed',
74        required = True,
75        )
76
77    title_prefix = schema.TextLine(
78        title = u'Title prefix',
79        default = u'department',
80        required = True,
81        )
82
83    courses = Attribute("A container for courses.")
84    certificates = Attribute("A container for certificates.")
85
86
87class ICourseContainer(IWAeUPContainer):
88    """A container for faculties.
89    """
90    def addCourse(faculty):
91        """Add an ICourse object.
92
93        Returns the key, under which the object was stored.
94        """
95
96class ICourse(IWAeUPObject):
97    """Representation of a course.
98    """
99    code = schema.TextLine(
100        title = u'Code',
101        default = u'NA',
102        description = u'Abbreviated code of the course',
103        required = True,
104        readonly = True,
105        )
106
107    title = schema.TextLine(
108        title = u'Title of course',
109        default = u'Unnamed',
110        required = True,
111        )
112
113    credits = schema.Int(
114        title = u'Credits',
115        default = 0,
116        required = False,
117        )
118   
119    passmark = schema.Int(
120        title = u'Passmark',
121        default = 40,
122        required = False,
123        )
124
125    semester = schema.Choice(
126        title = u'Semester/Term',
127        default = 0,
128        vocabulary = SimpleWAeUPVocabulary(
129            ('N/A', 0), ('First Semester', 1),
130            ('Second Semester', 2), ('Combined', 3)),
131        required = True,
132        )
133
134
135class ICertificate(IWAeUPObject):
136    """Representation of a certificate.
137    """
138    code = schema.TextLine(
139        title = u'Code',
140        default = u'NA',
141        description = u'Abbreviated code of the certificate.',
142        required = True,
[5948]143        readonly = True,
[5004]144        )
145
146    review_state = schema.Choice(
[5948]147        title = u'Review State',
[5004]148        default = 'unchecked',
149        values = ['unchecked', 'checked']
150        )
151
152    title = schema.TextLine(
[5948]153        title = u'Title',
[5004]154        required = True,
155        )
156
157    study_mode = schema.TextLine(
[5948]158        title = u'Study Mode',
[5004]159        required = True,
160        )
161
162    start_level = schema.TextLine(
[5948]163        title = u'Start Level',
[5004]164        required = True,
165        )
166   
167    end_level = schema.TextLine(
[5948]168        title = u'End Level',
[5004]169        required = True,
170        )
171   
172    application_category = schema.TextLine(
[5948]173        title = u'aApplication Category',
[5004]174        required = False,
[5948]175        )   
[5004]176
177   
178class ICertificateContainer(IWAeUPContainer):
179    """A container for certificates.
180    """
181    def addCertificate(faculty):
182        """Add an ICertificate object.
183
184        Returns the key, under which the object was stored.
185        """
186
187class ICertificateCourse(IWAeUPObject):
188    """A certificatecourse is a course referenced by a certificate, which
189       provides some own attributes.
190    """
191    course = schema.Choice(
192        title = u'Course',
193        source = CourseSource(),
194        )
195   
196    level = schema.Int(
197        title = u'Level of this course',
198        required = True,
199        default = 100
200        )
201
202    core_or_elective = schema.Bool(
203        title = u'Is mandatory course (not elective)',
204        required = True,
205        default = True
206        )
207
208    def getCourseCode():
209        """Return the code of the referenced course.
210
211        This is needed for cataloging.
212        """
Note: See TracBrowser for help on using the repository browser.