[6621] | 1 | ## |
---|
| 2 | ## interfaces.py |
---|
[6788] | 3 | from zope.interface import Attribute, invariant |
---|
[6756] | 4 | from zope.interface.exceptions import Invalid |
---|
[6621] | 5 | from zope import schema |
---|
| 6 | from waeup.sirp.interfaces import IWAeUPObject |
---|
[6788] | 7 | from waeup.sirp.schema import TextLineChoice |
---|
[6795] | 8 | from waeup.sirp.university.vocabularies import CourseSource |
---|
[6648] | 9 | from waeup.sirp.students.vocabularies import ( |
---|
[6788] | 10 | CertificateSource, academic_sessions_vocab, verdicts, StudyLevelSource, |
---|
| 11 | contextual_reg_num_source, contextual_mat_num_source, |
---|
[6648] | 12 | ) |
---|
[6621] | 13 | |
---|
[6692] | 14 | class IStudentsContainer(IWAeUPObject): |
---|
| 15 | """An students container contains university students. |
---|
| 16 | |
---|
| 17 | """ |
---|
| 18 | |
---|
| 19 | def addStudent(student): |
---|
| 20 | """Add an IStudent object and subcontainers. |
---|
| 21 | |
---|
| 22 | """ |
---|
| 23 | |
---|
| 24 | def archive(id=None): |
---|
| 25 | """Create on-dist archive of students. |
---|
| 26 | |
---|
| 27 | If id is `None`, all students are archived. |
---|
| 28 | |
---|
| 29 | If id contains a single id string, only the respective |
---|
| 30 | students are archived. |
---|
| 31 | |
---|
| 32 | If id contains a list of id strings all of the respective |
---|
| 33 | students types are saved to disk. |
---|
| 34 | """ |
---|
| 35 | |
---|
| 36 | def clear(id=None, archive=True): |
---|
| 37 | """Remove students of type given by 'id'. |
---|
| 38 | |
---|
| 39 | Optionally archive the students. |
---|
| 40 | |
---|
| 41 | If id is `None`, all students are archived. |
---|
| 42 | |
---|
| 43 | If id contains a single id string, only the respective |
---|
| 44 | students are archived. |
---|
| 45 | |
---|
| 46 | If id contains a list of id strings all of the respective |
---|
| 47 | student types are saved to disk. |
---|
| 48 | |
---|
| 49 | If `archive` is ``False`` none of the archive-handling is done |
---|
| 50 | and respective students are simply removed from the |
---|
| 51 | database. |
---|
| 52 | """ |
---|
| 53 | |
---|
[6642] | 54 | class IStudentNavigation(IWAeUPObject): |
---|
| 55 | """Interface needed for student navigation. |
---|
| 56 | """ |
---|
| 57 | |
---|
| 58 | def getStudent(): |
---|
| 59 | """Return student object. |
---|
| 60 | """ |
---|
| 61 | |
---|
[6756] | 62 | class IStudentPasswordSetting(IWAeUPObject): |
---|
| 63 | """Data needed for password setting. |
---|
| 64 | """ |
---|
| 65 | name = schema.TextLine( |
---|
| 66 | title = u'Full Name', |
---|
| 67 | default = u'Nobody', |
---|
| 68 | required = True, |
---|
[6764] | 69 | readonly = True |
---|
[6756] | 70 | ) |
---|
| 71 | |
---|
| 72 | password = schema.Password( |
---|
| 73 | title = u'New password', |
---|
| 74 | required = False, |
---|
| 75 | ) |
---|
| 76 | |
---|
| 77 | password_repeat = schema.Password( |
---|
| 78 | title = u'Retype new password', |
---|
| 79 | required = False, |
---|
| 80 | ) |
---|
| 81 | |
---|
| 82 | @invariant |
---|
| 83 | def passwords_match(obj): |
---|
| 84 | if obj.password == obj.password_repeat: |
---|
| 85 | return |
---|
| 86 | raise Invalid('passwords do not match') |
---|
| 87 | |
---|
[6631] | 88 | class IStudentBase(IWAeUPObject): |
---|
| 89 | """Representation of student base data. |
---|
[6621] | 90 | """ |
---|
[6637] | 91 | history = Attribute('Object history, a list of messages.') |
---|
| 92 | state = Attribute('Returns the registration state of a student') |
---|
[6699] | 93 | password = Attribute('Encrypted password of a student') |
---|
[6814] | 94 | certificate = Attribute('The certificate of any chosen study course') |
---|
[6637] | 95 | |
---|
| 96 | def loggerInfo(ob_class, comment): |
---|
| 97 | """Adds an INFO message to the log file |
---|
| 98 | """ |
---|
| 99 | |
---|
[6665] | 100 | student_id = schema.TextLine( |
---|
| 101 | title = u'Student ID', |
---|
| 102 | required = True, |
---|
| 103 | ) |
---|
| 104 | |
---|
[6818] | 105 | fullname = schema.TextLine( |
---|
[6631] | 106 | title = u'Full Name', |
---|
[6818] | 107 | default = None, |
---|
[6621] | 108 | required = True, |
---|
| 109 | ) |
---|
| 110 | |
---|
[6788] | 111 | reg_number = TextLineChoice( |
---|
[6696] | 112 | title = u'Registration Number', |
---|
[6818] | 113 | default = None, |
---|
[6696] | 114 | required = True, |
---|
| 115 | readonly = False, |
---|
[6788] | 116 | source = contextual_reg_num_source, |
---|
[6696] | 117 | ) |
---|
| 118 | |
---|
[6788] | 119 | matric_number = TextLineChoice( |
---|
[6750] | 120 | title = u'Matriculation Number', |
---|
[6788] | 121 | #default = u'', |
---|
[6750] | 122 | required = False, |
---|
| 123 | readonly = False, |
---|
[6788] | 124 | source = contextual_mat_num_source, |
---|
[6750] | 125 | ) |
---|
| 126 | |
---|
[6769] | 127 | adm_code = schema.TextLine( |
---|
[6771] | 128 | title = u'PWD Access Code', |
---|
[6769] | 129 | default = u'', |
---|
| 130 | required = False, |
---|
| 131 | readonly = True, |
---|
| 132 | ) |
---|
| 133 | |
---|
[6631] | 134 | class IStudentClearance(IWAeUPObject): |
---|
| 135 | """Representation of student clearance data. |
---|
| 136 | """ |
---|
[6622] | 137 | |
---|
[6631] | 138 | date_of_birth = schema.Date( |
---|
| 139 | title = u'Date of Birth', |
---|
| 140 | required = True, |
---|
| 141 | ) |
---|
| 142 | |
---|
[6695] | 143 | clearance_locked = schema.Bool( |
---|
| 144 | title = u'Clearance form locked', |
---|
| 145 | default = False, |
---|
| 146 | ) |
---|
| 147 | |
---|
[6769] | 148 | clr_code = schema.TextLine( |
---|
[6771] | 149 | title = u'CLR Access Code', |
---|
[6769] | 150 | default = u'', |
---|
| 151 | required = False, |
---|
| 152 | readonly = True, |
---|
| 153 | ) |
---|
| 154 | |
---|
[6631] | 155 | class IStudentPersonal(IWAeUPObject): |
---|
| 156 | """Representation of student personal data. |
---|
| 157 | """ |
---|
| 158 | |
---|
[6651] | 159 | perm_address = schema.Text( |
---|
[6631] | 160 | title = u'Permanent Address', |
---|
| 161 | required = False, |
---|
| 162 | ) |
---|
| 163 | |
---|
| 164 | class IStudent(IStudentBase,IStudentClearance,IStudentPersonal): |
---|
| 165 | """Representation of a student. |
---|
| 166 | """ |
---|
| 167 | |
---|
[6633] | 168 | class IStudentStudyCourse(IWAeUPObject): |
---|
| 169 | """A container for student study levels. |
---|
| 170 | |
---|
| 171 | """ |
---|
| 172 | |
---|
[6648] | 173 | certificate = schema.Choice( |
---|
| 174 | title = u'Certificate', |
---|
| 175 | source = CertificateSource(), |
---|
| 176 | default = None, |
---|
[6633] | 177 | required = True, |
---|
| 178 | ) |
---|
[6635] | 179 | |
---|
[6724] | 180 | current_session = schema.Choice( |
---|
| 181 | title = u'Current Session', |
---|
[6744] | 182 | source = academic_sessions_vocab, |
---|
[6724] | 183 | default = None, |
---|
| 184 | required = True, |
---|
| 185 | ) |
---|
| 186 | |
---|
| 187 | current_level = schema.Choice( |
---|
| 188 | title = u'Current Level', |
---|
[6725] | 189 | source = StudyLevelSource(), |
---|
[6724] | 190 | default = None, |
---|
[6725] | 191 | required = False, |
---|
[6724] | 192 | ) |
---|
| 193 | |
---|
| 194 | current_verdict = schema.Choice( |
---|
| 195 | title = u'Current Verdict', |
---|
| 196 | source = verdicts, |
---|
[6804] | 197 | default = '0', |
---|
[6725] | 198 | required = False, |
---|
[6724] | 199 | ) |
---|
| 200 | |
---|
| 201 | previous_verdict = schema.Choice( |
---|
| 202 | title = u'Previous Verdict', |
---|
| 203 | source = verdicts, |
---|
[6805] | 204 | default = '0', |
---|
[6725] | 205 | required = False, |
---|
[6724] | 206 | ) |
---|
| 207 | |
---|
[6825] | 208 | class IStudentStudyCourseImport(IStudentStudyCourse): |
---|
| 209 | """A container for student study levels. |
---|
| 210 | |
---|
| 211 | """ |
---|
| 212 | |
---|
| 213 | current_level = schema.Int( |
---|
| 214 | title = u'Current Level', |
---|
| 215 | default = None, |
---|
| 216 | ) |
---|
| 217 | |
---|
[6774] | 218 | class IStudentStudyLevel(IWAeUPObject): |
---|
| 219 | """A container for course tickets. |
---|
| 220 | |
---|
| 221 | """ |
---|
| 222 | level = Attribute('The level code') |
---|
[6793] | 223 | validation_date = Attribute('The date of validation') |
---|
| 224 | validated_by = Attribute('User Id of course adviser') |
---|
[6774] | 225 | |
---|
[6793] | 226 | level_session = schema.Choice( |
---|
| 227 | title = u'Session', |
---|
| 228 | source = academic_sessions_vocab, |
---|
| 229 | default = None, |
---|
| 230 | required = True, |
---|
| 231 | ) |
---|
[6781] | 232 | |
---|
[6793] | 233 | level_verdict = schema.Choice( |
---|
| 234 | title = u'Verdict', |
---|
| 235 | source = verdicts, |
---|
[6805] | 236 | default = '0', |
---|
[6793] | 237 | required = False, |
---|
| 238 | ) |
---|
| 239 | |
---|
[6781] | 240 | class ICourseTicket(IWAeUPObject): |
---|
| 241 | """A course ticket. |
---|
| 242 | |
---|
| 243 | """ |
---|
[6783] | 244 | code = Attribute('code of the original course') |
---|
| 245 | title = Attribute('title of the original course') |
---|
| 246 | credits = Attribute('credits of the original course') |
---|
| 247 | passmark = Attribute('passmark of the original course') |
---|
| 248 | semester = Attribute('semester of the original course') |
---|
| 249 | faculty = Attribute('faculty of the original course') |
---|
| 250 | department = Attribute('department of the original course') |
---|
[6781] | 251 | |
---|
[6795] | 252 | core_or_elective = schema.Bool( |
---|
| 253 | title = u'Mandatory', |
---|
| 254 | default = False, |
---|
| 255 | required = False, |
---|
| 256 | readonly = False, |
---|
| 257 | ) |
---|
| 258 | |
---|
[6781] | 259 | score = schema.Int( |
---|
| 260 | title = u'Score', |
---|
| 261 | default = 0, |
---|
| 262 | required = False, |
---|
| 263 | readonly = False, |
---|
| 264 | ) |
---|
| 265 | |
---|
[6806] | 266 | automatic = schema.Bool( |
---|
| 267 | title = u'Automatical Creation', |
---|
| 268 | default = False, |
---|
| 269 | required = False, |
---|
| 270 | readonly = True, |
---|
| 271 | ) |
---|
| 272 | |
---|
[6795] | 273 | class ICourseTicketAdd(ICourseTicket): |
---|
| 274 | """An interface for adding course tickets |
---|
| 275 | |
---|
| 276 | """ |
---|
| 277 | course = schema.Choice( |
---|
| 278 | title = u'Course', |
---|
| 279 | source = CourseSource(), |
---|
| 280 | readonly = False, |
---|
| 281 | ) |
---|
| 282 | |
---|
[6635] | 283 | class IStudentAccommodation(IWAeUPObject): |
---|
| 284 | """A container for student accommodation objects. |
---|
| 285 | |
---|
| 286 | """ |
---|
| 287 | |
---|
| 288 | class IStudentPayments(IWAeUPObject): |
---|
| 289 | """A container for student payment objects. |
---|
| 290 | |
---|
| 291 | """ |
---|
| 292 | |
---|
[6694] | 293 | # Interfaces for students only |
---|
| 294 | |
---|
| 295 | class IStudentClearanceEdit(IStudentClearance): |
---|
| 296 | """Interface needed for restricted editing of student clearance data. |
---|
| 297 | """ |
---|
| 298 | |
---|
| 299 | class IStudentPersonalEdit(IStudentPersonal): |
---|
| 300 | """Interface needed for restricted editing of student personal data. |
---|
| 301 | """ |
---|