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

Last change on this file since 5447 was 5051, checked in by uli, 15 years ago

BBB imports for older groktoolkit.

File size: 5.4 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    """
32    title = schema.TextLine(
33        title = u'Name of Faculty',
34        default = u'Unnamed',
35        required = True,
36        )
37
38    title_prefix = schema.TextLine(
39        title = u'Title prefix',
40        default = u'faculty',
41        required = True,
42        )
43   
44    code = schema.TextLine(
45        title = u'Code',
46        description = u'Abbreviated code of the faculty',
47        default = u'NA',
48        required = True,
49        )
50
51class IFacultyContainer(IWAeUPContainer):
52    """A container for faculties.
53    """
54    def addFaculty(faculty):
55        """Add an IFactulty object.
56
57        Returns the key, under which the object was stored.
58        """
59class IDepartment(IWAeUPObject):
60    """Representation of a department.
61    """
62    title = schema.TextLine(
63        title = u'Name of Department',
64        default = u'Unnamed',
65        required = True,
66        )
67
68    title_prefix = schema.TextLine(
69        title = u'Title prefix',
70        default = u'department',
71        required = True,
72        )
73   
74    code = schema.TextLine(
75        title = u'Code',
76        default = u'NA',
77        description = u'Abbreviated code of the department',
78        required = True,
79        )
80
81    courses = Attribute("A container for courses.")
82    certificates = Attribute("A container for certificates.")
83
84
85class ICourseContainer(IWAeUPContainer):
86    """A container for faculties.
87    """
88    def addCourse(faculty):
89        """Add an ICourse object.
90
91        Returns the key, under which the object was stored.
92        """
93
94class ICourse(IWAeUPObject):
95    """Representation of a course.
96    """
97    code = schema.TextLine(
98        title = u'Code',
99        default = u'NA',
100        description = u'Abbreviated code of the course',
101        required = True,
102        readonly = True,
103        )
104
105    title = schema.TextLine(
106        title = u'Title of course',
107        default = u'Unnamed',
108        required = True,
109        )
110
111    level = schema.TextLine(
112        title = u'Level',
113        default = u'100',
114        required = False,
115        )
116
117    credits = schema.Int(
118        title = u'Credits',
119        default = 0,
120        required = False,
121        )
122   
123    passmark = schema.Int(
124        title = u'Passmark',
125        default = 40,
126        required = False,
127        )
128
129    semester = schema.Choice(
130        title = u'Semester/Term',
131        default = 0,
132        vocabulary = SimpleWAeUPVocabulary(
133            ('N/A', 0), ('First Semester', 1),
134            ('Second Semester', 2), ('Combined', 3)),
135        required = True,
136        )
137
138
139class ICertificate(IWAeUPObject):
140    """Representation of a certificate.
141    """
142    code = schema.TextLine(
143        title = u'Code',
144        default = u'NA',
145        description = u'Abbreviated code of the certificate.',
146        required = True,
147        )
148
149    review_state = schema.Choice(
150        title = u'review state',
151        default = 'unchecked',
152        values = ['unchecked', 'checked']
153        )
154
155    title = schema.TextLine(
156        title = u'title',
157        required = True,
158        )
159
160    study_mode = schema.TextLine(
161        title = u'study mode',
162        required = True,
163        )
164
165    start_level = schema.TextLine(
166        title = u'start level',
167        required = True,
168        )
169   
170    end_level = schema.TextLine(
171        title = u'end level',
172        required = True,
173        )
174   
175    application_category = schema.TextLine(
176        title = u'application category',
177        required = False,
178        )
179   
180    max_pass = schema.TextLine(
181        title = u'maximum pass',
182        required = False,
183        )
184   
185
186   
187class ICertificateContainer(IWAeUPContainer):
188    """A container for certificates.
189    """
190    def addCertificate(faculty):
191        """Add an ICertificate object.
192
193        Returns the key, under which the object was stored.
194        """
195
196class ICertificateCourse(IWAeUPObject):
197    """A certificatecourse is a course referenced by a certificate, which
198       provides some own attributes.
199    """
200    course = schema.Choice(
201        title = u'Course',
202        source = CourseSource(),
203        )
204   
205    level = schema.Int(
206        title = u'Level of this course',
207        required = True,
208        default = 100
209        )
210
211    core_or_elective = schema.Bool(
212        title = u'Is mandatory course (not elective)',
213        required = True,
214        default = True
215        )
216
217    def getCourseCode():
218        """Return the code of the referenced course.
219
220        This is needed for cataloging.
221        """
Note: See TracBrowser for help on using the repository browser.