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

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

Remove level attribute from course class.

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    """
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    credits = schema.Int(
112        title = u'Credits',
113        default = 0,
114        required = False,
115        )
116   
117    passmark = schema.Int(
118        title = u'Passmark',
119        default = 40,
120        required = False,
121        )
122
123    semester = schema.Choice(
124        title = u'Semester/Term',
125        default = 0,
126        vocabulary = SimpleWAeUPVocabulary(
127            ('N/A', 0), ('First Semester', 1),
128            ('Second Semester', 2), ('Combined', 3)),
129        required = True,
130        )
131
132
133class ICertificate(IWAeUPObject):
134    """Representation of a certificate.
135    """
136    code = schema.TextLine(
137        title = u'Code',
138        default = u'NA',
139        description = u'Abbreviated code of the certificate.',
140        required = True,
141        )
142
143    review_state = schema.Choice(
144        title = u'review state',
145        default = 'unchecked',
146        values = ['unchecked', 'checked']
147        )
148
149    title = schema.TextLine(
150        title = u'title',
151        required = True,
152        )
153
154    study_mode = schema.TextLine(
155        title = u'study mode',
156        required = True,
157        )
158
159    start_level = schema.TextLine(
160        title = u'start level',
161        required = True,
162        )
163   
164    end_level = schema.TextLine(
165        title = u'end level',
166        required = True,
167        )
168   
169    application_category = schema.TextLine(
170        title = u'application category',
171        required = False,
172        )
173   
174    max_pass = schema.TextLine(
175        title = u'maximum pass',
176        required = False,
177        )
178   
179
180   
181class ICertificateContainer(IWAeUPContainer):
182    """A container for certificates.
183    """
184    def addCertificate(faculty):
185        """Add an ICertificate object.
186
187        Returns the key, under which the object was stored.
188        """
189
190class ICertificateCourse(IWAeUPObject):
191    """A certificatecourse is a course referenced by a certificate, which
192       provides some own attributes.
193    """
194    course = schema.Choice(
195        title = u'Course',
196        source = CourseSource(),
197        )
198   
199    level = schema.Int(
200        title = u'Level of this course',
201        required = True,
202        default = 100
203        )
204
205    core_or_elective = schema.Bool(
206        title = u'Is mandatory course (not elective)',
207        required = True,
208        default = True
209        )
210
211    def getCourseCode():
212        """Return the code of the referenced course.
213
214        This is needed for cataloging.
215        """
Note: See TracBrowser for help on using the repository browser.