[7195] | 1 | ## $Id: interfaces.py 7670 2012-02-19 18:42:02Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
[5004] | 18 | """Interfaces of academics specific objects. |
---|
| 19 | """ |
---|
[7670] | 20 | |
---|
[5004] | 21 | from zope import schema |
---|
| 22 | from zope.interface import Attribute |
---|
[7670] | 23 | import zope.i18nmessageid |
---|
[7321] | 24 | from waeup.sirp.interfaces import (ISIRPObject, ISIRPContainer) |
---|
[7670] | 25 | from waeup.sirp.interfaces import MessageFactory as _ |
---|
[5995] | 26 | from waeup.sirp.university.vocabularies import ( |
---|
| 27 | course_levels, |
---|
| 28 | semester, |
---|
[6189] | 29 | application_categories, |
---|
[6724] | 30 | study_modes, |
---|
[5995] | 31 | inst_types, |
---|
| 32 | CourseSource, |
---|
| 33 | ) |
---|
[5004] | 34 | |
---|
[5995] | 35 | |
---|
[7321] | 36 | class IFaculty(ISIRPContainer): |
---|
[5004] | 37 | """Representation of a university faculty. |
---|
| 38 | """ |
---|
[5948] | 39 | code = schema.TextLine( |
---|
| 40 | title = u'Code', |
---|
| 41 | default = u'NA', |
---|
| 42 | required = True, |
---|
| 43 | readonly = True, |
---|
| 44 | ) |
---|
| 45 | |
---|
[5004] | 46 | title = schema.TextLine( |
---|
[7667] | 47 | title = _(u'name_of_faculty', default=u'Name of faculty'), |
---|
[5004] | 48 | default = u'Unnamed', |
---|
| 49 | required = True, |
---|
| 50 | ) |
---|
| 51 | |
---|
[5988] | 52 | title_prefix = schema.Choice( |
---|
[6025] | 53 | title = u'Name prefix', |
---|
[5004] | 54 | default = u'faculty', |
---|
[5988] | 55 | vocabulary = inst_types, |
---|
[5004] | 56 | required = True, |
---|
| 57 | ) |
---|
[6561] | 58 | |
---|
[5988] | 59 | def longtitle(): |
---|
| 60 | """ |
---|
| 61 | Returns the long title of a faculty. |
---|
[6561] | 62 | """ |
---|
| 63 | |
---|
[5951] | 64 | class IFacultyAdd(IFaculty): |
---|
| 65 | """Representation of a university faculty. |
---|
| 66 | """ |
---|
| 67 | code = schema.TextLine( |
---|
| 68 | title = u'Code', |
---|
[6345] | 69 | description = u'This code will become part of the URL.', |
---|
[5951] | 70 | default = u'NA', |
---|
| 71 | required = True, |
---|
| 72 | readonly = False, |
---|
| 73 | ) |
---|
[6561] | 74 | |
---|
| 75 | IFacultyAdd['code'].order = IFaculty['code'].order |
---|
| 76 | |
---|
[7333] | 77 | class IFacultiesContainer(ISIRPContainer): |
---|
[5004] | 78 | """A container for faculties. |
---|
| 79 | """ |
---|
| 80 | def addFaculty(faculty): |
---|
| 81 | """Add an IFactulty object. |
---|
| 82 | |
---|
| 83 | """ |
---|
[7321] | 84 | class IDepartment(ISIRPObject): |
---|
[5004] | 85 | """Representation of a department. |
---|
| 86 | """ |
---|
[5948] | 87 | code = schema.TextLine( |
---|
| 88 | title = u'Code', |
---|
| 89 | default = u'NA', |
---|
| 90 | required = True, |
---|
| 91 | readonly = True, |
---|
| 92 | ) |
---|
| 93 | |
---|
[5004] | 94 | title = schema.TextLine( |
---|
[6025] | 95 | title = u'Name of department', |
---|
[5004] | 96 | default = u'Unnamed', |
---|
| 97 | required = True, |
---|
| 98 | ) |
---|
| 99 | |
---|
[5988] | 100 | title_prefix = schema.Choice( |
---|
[6025] | 101 | title = u'Name prefix', |
---|
[5988] | 102 | vocabulary = inst_types, |
---|
[5004] | 103 | default = u'department', |
---|
| 104 | required = True, |
---|
| 105 | ) |
---|
| 106 | |
---|
| 107 | courses = Attribute("A container for courses.") |
---|
| 108 | certificates = Attribute("A container for certificates.") |
---|
[6561] | 109 | |
---|
[5988] | 110 | def longtitle(): |
---|
| 111 | """ |
---|
| 112 | Returns the long title of a department. |
---|
| 113 | """ |
---|
[6561] | 114 | |
---|
[5951] | 115 | class IDepartmentAdd(IDepartment): |
---|
| 116 | """Representation of a university department. |
---|
| 117 | """ |
---|
| 118 | code = schema.TextLine( |
---|
| 119 | title = u'Code', |
---|
[6345] | 120 | description = u'This code will become part of the URL.', |
---|
[5951] | 121 | default = u'NA', |
---|
| 122 | required = True, |
---|
| 123 | readonly = False, |
---|
| 124 | ) |
---|
[5004] | 125 | |
---|
[6561] | 126 | IDepartmentAdd['code'].order = IDepartment['code'].order |
---|
| 127 | |
---|
[7333] | 128 | class ICoursesContainer(ISIRPContainer): |
---|
[5004] | 129 | """A container for faculties. |
---|
| 130 | """ |
---|
[6640] | 131 | def addCourse(course): |
---|
[5004] | 132 | """Add an ICourse object. |
---|
| 133 | |
---|
| 134 | Returns the key, under which the object was stored. |
---|
| 135 | """ |
---|
| 136 | |
---|
[7321] | 137 | class ICourse(ISIRPObject): |
---|
[5004] | 138 | """Representation of a course. |
---|
| 139 | """ |
---|
| 140 | code = schema.TextLine( |
---|
| 141 | title = u'Code', |
---|
| 142 | default = u'NA', |
---|
| 143 | required = True, |
---|
| 144 | readonly = True, |
---|
| 145 | ) |
---|
| 146 | |
---|
| 147 | title = schema.TextLine( |
---|
| 148 | title = u'Title of course', |
---|
| 149 | default = u'Unnamed', |
---|
| 150 | required = True, |
---|
| 151 | ) |
---|
| 152 | |
---|
| 153 | credits = schema.Int( |
---|
| 154 | title = u'Credits', |
---|
| 155 | default = 0, |
---|
| 156 | required = False, |
---|
| 157 | ) |
---|
[6561] | 158 | |
---|
[5004] | 159 | passmark = schema.Int( |
---|
| 160 | title = u'Passmark', |
---|
| 161 | default = 40, |
---|
| 162 | required = False, |
---|
| 163 | ) |
---|
| 164 | |
---|
| 165 | semester = schema.Choice( |
---|
| 166 | title = u'Semester/Term', |
---|
[7601] | 167 | default = 9, |
---|
[5977] | 168 | vocabulary = semester, |
---|
[5004] | 169 | required = True, |
---|
| 170 | ) |
---|
[6561] | 171 | |
---|
[6008] | 172 | def longtitle(): |
---|
| 173 | """ |
---|
| 174 | Returns the long title of a course. |
---|
[6561] | 175 | """ |
---|
[5004] | 176 | |
---|
[5951] | 177 | class ICourseAdd(ICourse): |
---|
| 178 | """Representation of a course. |
---|
| 179 | """ |
---|
| 180 | code = schema.TextLine( |
---|
| 181 | title = u'Code', |
---|
[6345] | 182 | description = u'Enter unique course code which will become part of the URL.', |
---|
[5951] | 183 | default = u'NA', |
---|
| 184 | required = True, |
---|
| 185 | readonly = False, |
---|
| 186 | ) |
---|
[5004] | 187 | |
---|
[6561] | 188 | ICourseAdd['code'].order = ICourse['code'].order |
---|
| 189 | |
---|
[7321] | 190 | class ICertificate(ISIRPObject): |
---|
[5004] | 191 | """Representation of a certificate. |
---|
| 192 | """ |
---|
| 193 | code = schema.TextLine( |
---|
| 194 | title = u'Code', |
---|
| 195 | default = u'NA', |
---|
| 196 | required = True, |
---|
[5948] | 197 | readonly = True, |
---|
[5004] | 198 | ) |
---|
| 199 | |
---|
| 200 | title = schema.TextLine( |
---|
[5948] | 201 | title = u'Title', |
---|
[5951] | 202 | default = u'Unnamed', |
---|
[5004] | 203 | required = True, |
---|
| 204 | ) |
---|
| 205 | |
---|
[5986] | 206 | study_mode = schema.Choice( |
---|
[5948] | 207 | title = u'Study Mode', |
---|
[6724] | 208 | vocabulary = study_modes, |
---|
[5951] | 209 | default = u'ug_ft', |
---|
[5004] | 210 | required = True, |
---|
| 211 | ) |
---|
| 212 | |
---|
[5977] | 213 | start_level = schema.Choice( |
---|
[5948] | 214 | title = u'Start Level', |
---|
[5977] | 215 | vocabulary = course_levels, |
---|
| 216 | default = 100, |
---|
[5004] | 217 | required = True, |
---|
| 218 | ) |
---|
[6561] | 219 | |
---|
[5977] | 220 | end_level = schema.Choice( |
---|
[5948] | 221 | title = u'End Level', |
---|
[5977] | 222 | vocabulary = course_levels, |
---|
| 223 | default = 500, |
---|
[5004] | 224 | required = True, |
---|
| 225 | ) |
---|
[6561] | 226 | |
---|
[5986] | 227 | application_category = schema.Choice( |
---|
[5949] | 228 | title = u'Application Category', |
---|
[6189] | 229 | vocabulary = application_categories, |
---|
[5951] | 230 | default = u'basic', |
---|
[5986] | 231 | required = True, |
---|
[6561] | 232 | ) |
---|
[5004] | 233 | |
---|
[6008] | 234 | def longtitle(): |
---|
| 235 | """ |
---|
| 236 | Returns the long title of a certificate. |
---|
[6561] | 237 | """ |
---|
[6008] | 238 | |
---|
[5951] | 239 | class ICertificateAdd(ICertificate): |
---|
| 240 | """Representation of a certificate. |
---|
| 241 | """ |
---|
| 242 | code = schema.TextLine( |
---|
| 243 | title = u'Code', |
---|
| 244 | default = u'NA', |
---|
[6345] | 245 | description = u'Enter unique certificate code which will become part of the URL.', |
---|
[5951] | 246 | required = True, |
---|
| 247 | readonly = False, |
---|
| 248 | ) |
---|
[6561] | 249 | |
---|
| 250 | ICertificateAdd['code'].order = ICertificate['code'].order |
---|
| 251 | |
---|
[7333] | 252 | class ICertificatesContainer(ISIRPContainer): |
---|
[5004] | 253 | """A container for certificates. |
---|
| 254 | """ |
---|
[6640] | 255 | def addCertificate(certificate): |
---|
[5004] | 256 | """Add an ICertificate object. |
---|
| 257 | |
---|
| 258 | Returns the key, under which the object was stored. |
---|
| 259 | """ |
---|
| 260 | |
---|
[7321] | 261 | class ICertificateCourse(ISIRPObject): |
---|
[6561] | 262 | """A certificatecourse is referring a course and provides some own |
---|
| 263 | attributes. |
---|
[5004] | 264 | """ |
---|
| 265 | course = schema.Choice( |
---|
[5977] | 266 | title = u'Course referrer', |
---|
[5004] | 267 | source = CourseSource(), |
---|
[5950] | 268 | readonly = True, |
---|
[5004] | 269 | ) |
---|
[6561] | 270 | |
---|
[5977] | 271 | level = schema.Choice( |
---|
[5951] | 272 | title = u'Level', |
---|
[5004] | 273 | required = True, |
---|
[5977] | 274 | vocabulary = course_levels, |
---|
[5950] | 275 | readonly = False, |
---|
[5004] | 276 | ) |
---|
| 277 | |
---|
[7665] | 278 | mandatory = schema.Bool( |
---|
[5004] | 279 | title = u'Is mandatory course (not elective)', |
---|
| 280 | required = True, |
---|
[5950] | 281 | default = True, |
---|
[5004] | 282 | ) |
---|
| 283 | |
---|
| 284 | def getCourseCode(): |
---|
[5977] | 285 | """Return the code of the course referred to. |
---|
[5004] | 286 | |
---|
| 287 | This is needed for cataloging. |
---|
| 288 | """ |
---|
[6561] | 289 | |
---|
[6008] | 290 | def longtitle(): |
---|
| 291 | """ |
---|
| 292 | Returns the long title of a certificatecourse. |
---|
[6561] | 293 | """ |
---|
| 294 | |
---|
| 295 | |
---|
[5951] | 296 | class ICertificateCourseAdd(ICertificateCourse): |
---|
[6561] | 297 | """A certificatecourse is referring a course and |
---|
[5951] | 298 | provides some own attributes. |
---|
| 299 | """ |
---|
| 300 | course = schema.Choice( |
---|
[5977] | 301 | title = u'Course', |
---|
[5951] | 302 | source = CourseSource(), |
---|
| 303 | readonly = False, |
---|
| 304 | ) |
---|
[6561] | 305 | |
---|
| 306 | ICertificateCourseAdd['course'].order = ICertificateCourse['course'].order |
---|