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

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

Move academics specific interfaces to university submodule.

File size: 5.3 KB
Line 
1"""Interfaces of academics specific objects.
2"""
3from zc.sourcefactory.basic import BasicSourceFactory
4from zope import schema
5from zope.app.catalog.interfaces import ICatalog
6from zope.component import getUtility
7from zope.interface import Attribute
8from waeup.sirp.interfaces import (IWAeUPObject, IWAeUPContainer,
9                                   SimpleWAeUPVocabulary)
10
11class CourseSource(BasicSourceFactory):
12    """A course source delivers all courses inside the portal by looking
13       up a catalog.
14    """
15    def getValues(self):
16        catalog = getUtility(ICatalog, name='courses_catalog')
17        return list(catalog.searchResults(code=('', 'z*')))
18
19    def getToken(self, value):
20        return value.code
21       
22    def getTitle(self, value):
23        return "%s %s" % (value.code, value.title[:32])
24
25class IFaculty(IWAeUPContainer):
26    """Representation of a university faculty.
27    """
28    title = schema.TextLine(
29        title = u'Name of Faculty',
30        default = u'Unnamed',
31        required = True,
32        )
33
34    title_prefix = schema.TextLine(
35        title = u'Title prefix',
36        default = u'faculty',
37        required = True,
38        )
39   
40    code = schema.TextLine(
41        title = u'Code',
42        description = u'Abbreviated code of the faculty',
43        default = u'NA',
44        required = True,
45        )
46
47class IFacultyContainer(IWAeUPContainer):
48    """A container for faculties.
49    """
50    def addFaculty(faculty):
51        """Add an IFactulty object.
52
53        Returns the key, under which the object was stored.
54        """
55class IDepartment(IWAeUPObject):
56    """Representation of a department.
57    """
58    title = schema.TextLine(
59        title = u'Name of Department',
60        default = u'Unnamed',
61        required = True,
62        )
63
64    title_prefix = schema.TextLine(
65        title = u'Title prefix',
66        default = u'department',
67        required = True,
68        )
69   
70    code = schema.TextLine(
71        title = u'Code',
72        default = u'NA',
73        description = u'Abbreviated code of the department',
74        required = True,
75        )
76
77    courses = Attribute("A container for courses.")
78    certificates = Attribute("A container for certificates.")
79
80
81class ICourseContainer(IWAeUPContainer):
82    """A container for faculties.
83    """
84    def addCourse(faculty):
85        """Add an ICourse object.
86
87        Returns the key, under which the object was stored.
88        """
89
90class ICourse(IWAeUPObject):
91    """Representation of a course.
92    """
93    code = schema.TextLine(
94        title = u'Code',
95        default = u'NA',
96        description = u'Abbreviated code of the course',
97        required = True,
98        readonly = True,
99        )
100
101    title = schema.TextLine(
102        title = u'Title of course',
103        default = u'Unnamed',
104        required = True,
105        )
106
107    level = schema.TextLine(
108        title = u'Level',
109        default = u'100',
110        required = False,
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,
143        )
144
145    review_state = schema.Choice(
146        title = u'review state',
147        default = 'unchecked',
148        values = ['unchecked', 'checked']
149        )
150
151    title = schema.TextLine(
152        title = u'title',
153        required = True,
154        )
155
156    study_mode = schema.TextLine(
157        title = u'study mode',
158        required = True,
159        )
160
161    start_level = schema.TextLine(
162        title = u'start level',
163        required = True,
164        )
165   
166    end_level = schema.TextLine(
167        title = u'end level',
168        required = True,
169        )
170   
171    application_category = schema.TextLine(
172        title = u'application category',
173        required = False,
174        )
175   
176    max_pass = schema.TextLine(
177        title = u'maximum pass',
178        required = False,
179        )
180   
181
182   
183class ICertificateContainer(IWAeUPContainer):
184    """A container for certificates.
185    """
186    def addCertificate(faculty):
187        """Add an ICertificate object.
188
189        Returns the key, under which the object was stored.
190        """
191
192class ICertificateCourse(IWAeUPObject):
193    """A certificatecourse is a course referenced by a certificate, which
194       provides some own attributes.
195    """
196    course = schema.Choice(
197        title = u'Course',
198        source = CourseSource(),
199        )
200   
201    level = schema.Int(
202        title = u'Level of this course',
203        required = True,
204        default = 100
205        )
206
207    core_or_elective = schema.Bool(
208        title = u'Is mandatory course (not elective)',
209        required = True,
210        default = True
211        )
212
213    def getCourseCode():
214        """Return the code of the referenced course.
215
216        This is needed for cataloging.
217        """
Note: See TracBrowser for help on using the repository browser.