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