[5004] | 1 | """Interfaces of academics specific objects. |
---|
| 2 | """ |
---|
| 3 | from zc.sourcefactory.basic import BasicSourceFactory |
---|
| 4 | from zope import schema |
---|
[5051] | 5 | try: |
---|
| 6 | from zope.catalog.interfaces import ICatalog |
---|
| 7 | except ImportError: |
---|
| 8 | # BBB |
---|
| 9 | from zope.app.catalog.interfaces import ICatalog |
---|
[5004] | 10 | from zope.component import getUtility |
---|
| 11 | from zope.interface import Attribute |
---|
| 12 | from waeup.sirp.interfaces import (IWAeUPObject, IWAeUPContainer, |
---|
| 13 | SimpleWAeUPVocabulary) |
---|
| 14 | |
---|
| 15 | class 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): |
---|
[5950] | 27 | return "%s - %s" % (value.code, value.title[:64]) |
---|
[5004] | 28 | |
---|
| 29 | class 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 | ) |
---|
[5951] | 51 | |
---|
| 52 | class IFacultyAdd(IFaculty): |
---|
| 53 | """Representation of a university faculty. |
---|
| 54 | """ |
---|
| 55 | code = schema.TextLine( |
---|
| 56 | title = u'Code', |
---|
| 57 | description = u'Abbreviated code of the faculty', |
---|
| 58 | default = u'NA', |
---|
| 59 | required = True, |
---|
| 60 | readonly = False, |
---|
| 61 | ) |
---|
| 62 | |
---|
| 63 | IFacultyAdd['code'].order = IFaculty['code'].order |
---|
[5004] | 64 | |
---|
| 65 | class IFacultyContainer(IWAeUPContainer): |
---|
| 66 | """A container for faculties. |
---|
| 67 | """ |
---|
| 68 | def addFaculty(faculty): |
---|
| 69 | """Add an IFactulty object. |
---|
| 70 | |
---|
| 71 | Returns the key, under which the object was stored. |
---|
| 72 | """ |
---|
| 73 | class IDepartment(IWAeUPObject): |
---|
| 74 | """Representation of a department. |
---|
| 75 | """ |
---|
[5948] | 76 | code = schema.TextLine( |
---|
| 77 | title = u'Code', |
---|
| 78 | default = u'NA', |
---|
| 79 | description = u'Abbreviated code of the department', |
---|
| 80 | required = True, |
---|
| 81 | readonly = True, |
---|
| 82 | ) |
---|
| 83 | |
---|
[5004] | 84 | title = schema.TextLine( |
---|
| 85 | title = u'Name of Department', |
---|
| 86 | default = u'Unnamed', |
---|
| 87 | required = True, |
---|
| 88 | ) |
---|
| 89 | |
---|
| 90 | title_prefix = schema.TextLine( |
---|
| 91 | title = u'Title prefix', |
---|
| 92 | default = u'department', |
---|
| 93 | required = True, |
---|
| 94 | ) |
---|
| 95 | |
---|
| 96 | courses = Attribute("A container for courses.") |
---|
| 97 | certificates = Attribute("A container for certificates.") |
---|
| 98 | |
---|
[5951] | 99 | class IDepartmentAdd(IDepartment): |
---|
| 100 | """Representation of a university department. |
---|
| 101 | """ |
---|
| 102 | code = schema.TextLine( |
---|
| 103 | title = u'Code', |
---|
| 104 | default = u'NA', |
---|
| 105 | description = u'Abbreviated code of the department', |
---|
| 106 | required = True, |
---|
| 107 | readonly = False, |
---|
| 108 | ) |
---|
| 109 | |
---|
| 110 | IDepartmentAdd['code'].order = IDepartment['code'].order |
---|
[5004] | 111 | |
---|
| 112 | class ICourseContainer(IWAeUPContainer): |
---|
| 113 | """A container for faculties. |
---|
| 114 | """ |
---|
| 115 | def addCourse(faculty): |
---|
| 116 | """Add an ICourse object. |
---|
| 117 | |
---|
| 118 | Returns the key, under which the object was stored. |
---|
| 119 | """ |
---|
| 120 | |
---|
| 121 | class ICourse(IWAeUPObject): |
---|
| 122 | """Representation of a course. |
---|
| 123 | """ |
---|
| 124 | code = schema.TextLine( |
---|
| 125 | title = u'Code', |
---|
| 126 | default = u'NA', |
---|
| 127 | description = u'Abbreviated code of the course', |
---|
| 128 | required = True, |
---|
| 129 | readonly = True, |
---|
| 130 | ) |
---|
| 131 | |
---|
| 132 | title = schema.TextLine( |
---|
| 133 | title = u'Title of course', |
---|
| 134 | default = u'Unnamed', |
---|
| 135 | required = True, |
---|
| 136 | ) |
---|
| 137 | |
---|
| 138 | credits = schema.Int( |
---|
| 139 | title = u'Credits', |
---|
| 140 | default = 0, |
---|
| 141 | required = False, |
---|
| 142 | ) |
---|
| 143 | |
---|
| 144 | passmark = schema.Int( |
---|
| 145 | title = u'Passmark', |
---|
| 146 | default = 40, |
---|
| 147 | required = False, |
---|
| 148 | ) |
---|
| 149 | |
---|
| 150 | semester = schema.Choice( |
---|
| 151 | title = u'Semester/Term', |
---|
| 152 | default = 0, |
---|
| 153 | vocabulary = SimpleWAeUPVocabulary( |
---|
| 154 | ('N/A', 0), ('First Semester', 1), |
---|
| 155 | ('Second Semester', 2), ('Combined', 3)), |
---|
| 156 | required = True, |
---|
| 157 | ) |
---|
| 158 | |
---|
[5951] | 159 | class ICourseAdd(ICourse): |
---|
| 160 | """Representation of a course. |
---|
| 161 | """ |
---|
| 162 | code = schema.TextLine( |
---|
| 163 | title = u'Code', |
---|
| 164 | default = u'NA', |
---|
| 165 | description = u'Abbreviated code of the course', |
---|
| 166 | required = True, |
---|
| 167 | readonly = False, |
---|
| 168 | ) |
---|
| 169 | |
---|
| 170 | ICourseAdd['code'].order = ICourse['code'].order |
---|
[5004] | 171 | |
---|
| 172 | class ICertificate(IWAeUPObject): |
---|
| 173 | """Representation of a certificate. |
---|
| 174 | """ |
---|
| 175 | code = schema.TextLine( |
---|
| 176 | title = u'Code', |
---|
| 177 | default = u'NA', |
---|
| 178 | description = u'Abbreviated code of the certificate.', |
---|
| 179 | required = True, |
---|
[5948] | 180 | readonly = True, |
---|
[5004] | 181 | ) |
---|
| 182 | |
---|
[5949] | 183 | #review_state = schema.Choice( |
---|
| 184 | # title = u'Review State', |
---|
| 185 | # default = 'unchecked', |
---|
| 186 | # values = ['unchecked', 'checked'] |
---|
| 187 | # ) |
---|
[5004] | 188 | |
---|
| 189 | title = schema.TextLine( |
---|
[5948] | 190 | title = u'Title', |
---|
[5951] | 191 | default = u'Unnamed', |
---|
[5004] | 192 | required = True, |
---|
| 193 | ) |
---|
| 194 | |
---|
| 195 | study_mode = schema.TextLine( |
---|
[5948] | 196 | title = u'Study Mode', |
---|
[5951] | 197 | default = u'ug_ft', |
---|
[5004] | 198 | required = True, |
---|
| 199 | ) |
---|
| 200 | |
---|
| 201 | start_level = schema.TextLine( |
---|
[5948] | 202 | title = u'Start Level', |
---|
[5951] | 203 | default = u'100', |
---|
[5004] | 204 | required = True, |
---|
| 205 | ) |
---|
| 206 | |
---|
| 207 | end_level = schema.TextLine( |
---|
[5948] | 208 | title = u'End Level', |
---|
[5951] | 209 | default = u'500', |
---|
[5004] | 210 | required = True, |
---|
| 211 | ) |
---|
| 212 | |
---|
| 213 | application_category = schema.TextLine( |
---|
[5949] | 214 | title = u'Application Category', |
---|
[5951] | 215 | default = u'basic', |
---|
[5004] | 216 | required = False, |
---|
[5948] | 217 | ) |
---|
[5004] | 218 | |
---|
[5951] | 219 | class ICertificateAdd(ICertificate): |
---|
| 220 | """Representation of a certificate. |
---|
| 221 | """ |
---|
| 222 | code = schema.TextLine( |
---|
| 223 | title = u'Code', |
---|
| 224 | default = u'NA', |
---|
| 225 | description = u'Abbreviated code of the certificate.', |
---|
| 226 | required = True, |
---|
| 227 | readonly = False, |
---|
| 228 | ) |
---|
| 229 | |
---|
| 230 | ICertificateAdd['code'].order = ICertificate['code'].order |
---|
[5004] | 231 | |
---|
| 232 | class ICertificateContainer(IWAeUPContainer): |
---|
| 233 | """A container for certificates. |
---|
| 234 | """ |
---|
| 235 | def addCertificate(faculty): |
---|
| 236 | """Add an ICertificate object. |
---|
| 237 | |
---|
| 238 | Returns the key, under which the object was stored. |
---|
| 239 | """ |
---|
| 240 | |
---|
| 241 | class ICertificateCourse(IWAeUPObject): |
---|
| 242 | """A certificatecourse is a course referenced by a certificate, which |
---|
| 243 | provides some own attributes. |
---|
| 244 | """ |
---|
| 245 | course = schema.Choice( |
---|
[5950] | 246 | title = u'Course referenced', |
---|
[5004] | 247 | source = CourseSource(), |
---|
[5950] | 248 | readonly = True, |
---|
[5004] | 249 | ) |
---|
| 250 | |
---|
| 251 | level = schema.Int( |
---|
[5951] | 252 | title = u'Level', |
---|
[5004] | 253 | required = True, |
---|
[5950] | 254 | default = 100, |
---|
| 255 | readonly = False, |
---|
[5004] | 256 | ) |
---|
| 257 | |
---|
| 258 | core_or_elective = schema.Bool( |
---|
| 259 | title = u'Is mandatory course (not elective)', |
---|
| 260 | required = True, |
---|
[5950] | 261 | default = True, |
---|
[5004] | 262 | ) |
---|
| 263 | |
---|
| 264 | def getCourseCode(): |
---|
| 265 | """Return the code of the referenced course. |
---|
| 266 | |
---|
| 267 | This is needed for cataloging. |
---|
| 268 | """ |
---|
[5951] | 269 | |
---|
| 270 | |
---|
| 271 | class ICertificateCourseAdd(ICertificateCourse): |
---|
| 272 | """A certificatecourse is a course referenced by a certificate, which |
---|
| 273 | provides some own attributes. |
---|
| 274 | """ |
---|
| 275 | course = schema.Choice( |
---|
| 276 | title = u'Course to be referenced', |
---|
| 277 | source = CourseSource(), |
---|
| 278 | readonly = False, |
---|
| 279 | ) |
---|
| 280 | |
---|
| 281 | ICertificateCourseAdd['course'].order = ICertificateCourse['course'].order |
---|