[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') |
---|
[6637] | 94 | |
---|
| 95 | def loggerInfo(ob_class, comment): |
---|
| 96 | """Adds an INFO message to the log file |
---|
| 97 | """ |
---|
| 98 | |
---|
[6665] | 99 | student_id = schema.TextLine( |
---|
| 100 | title = u'Student ID', |
---|
| 101 | required = True, |
---|
| 102 | ) |
---|
| 103 | |
---|
[6621] | 104 | name = schema.TextLine( |
---|
[6631] | 105 | title = u'Full Name', |
---|
[6621] | 106 | default = u'Nobody', |
---|
| 107 | required = True, |
---|
| 108 | ) |
---|
| 109 | |
---|
[6788] | 110 | reg_number = TextLineChoice( |
---|
[6696] | 111 | title = u'Registration Number', |
---|
[6788] | 112 | #default = u'', |
---|
[6696] | 113 | required = True, |
---|
| 114 | readonly = False, |
---|
[6788] | 115 | source = contextual_reg_num_source, |
---|
[6696] | 116 | ) |
---|
| 117 | |
---|
[6788] | 118 | matric_number = TextLineChoice( |
---|
[6750] | 119 | title = u'Matriculation Number', |
---|
[6788] | 120 | #default = u'', |
---|
[6750] | 121 | required = False, |
---|
| 122 | readonly = False, |
---|
[6788] | 123 | source = contextual_mat_num_source, |
---|
[6750] | 124 | ) |
---|
| 125 | |
---|
[6769] | 126 | adm_code = schema.TextLine( |
---|
[6771] | 127 | title = u'PWD Access Code', |
---|
[6769] | 128 | default = u'', |
---|
| 129 | required = False, |
---|
| 130 | readonly = True, |
---|
| 131 | ) |
---|
| 132 | |
---|
[6631] | 133 | class IStudentClearance(IWAeUPObject): |
---|
| 134 | """Representation of student clearance data. |
---|
| 135 | """ |
---|
[6622] | 136 | |
---|
[6631] | 137 | date_of_birth = schema.Date( |
---|
| 138 | title = u'Date of Birth', |
---|
| 139 | required = True, |
---|
| 140 | ) |
---|
| 141 | |
---|
[6695] | 142 | clearance_locked = schema.Bool( |
---|
| 143 | title = u'Clearance form locked', |
---|
| 144 | default = False, |
---|
| 145 | ) |
---|
| 146 | |
---|
[6769] | 147 | clr_code = schema.TextLine( |
---|
[6771] | 148 | title = u'CLR Access Code', |
---|
[6769] | 149 | default = u'', |
---|
| 150 | required = False, |
---|
| 151 | readonly = True, |
---|
| 152 | ) |
---|
| 153 | |
---|
[6631] | 154 | class IStudentPersonal(IWAeUPObject): |
---|
| 155 | """Representation of student personal data. |
---|
| 156 | """ |
---|
| 157 | |
---|
[6651] | 158 | perm_address = schema.Text( |
---|
[6631] | 159 | title = u'Permanent Address', |
---|
| 160 | required = False, |
---|
| 161 | ) |
---|
| 162 | |
---|
| 163 | class IStudent(IStudentBase,IStudentClearance,IStudentPersonal): |
---|
| 164 | """Representation of a student. |
---|
| 165 | """ |
---|
| 166 | |
---|
[6633] | 167 | class IStudentStudyCourse(IWAeUPObject): |
---|
| 168 | """A container for student study levels. |
---|
| 169 | |
---|
| 170 | """ |
---|
| 171 | |
---|
[6648] | 172 | certificate = schema.Choice( |
---|
| 173 | title = u'Certificate', |
---|
| 174 | source = CertificateSource(), |
---|
| 175 | default = None, |
---|
[6633] | 176 | required = True, |
---|
| 177 | ) |
---|
[6635] | 178 | |
---|
[6724] | 179 | current_session = schema.Choice( |
---|
| 180 | title = u'Current Session', |
---|
[6744] | 181 | source = academic_sessions_vocab, |
---|
[6724] | 182 | default = None, |
---|
| 183 | required = True, |
---|
| 184 | ) |
---|
| 185 | |
---|
| 186 | current_level = schema.Choice( |
---|
| 187 | title = u'Current Level', |
---|
[6725] | 188 | source = StudyLevelSource(), |
---|
[6724] | 189 | default = None, |
---|
[6725] | 190 | required = False, |
---|
[6724] | 191 | ) |
---|
| 192 | |
---|
| 193 | current_verdict = schema.Choice( |
---|
| 194 | title = u'Current Verdict', |
---|
| 195 | source = verdicts, |
---|
[6804] | 196 | default = '0', |
---|
[6725] | 197 | required = False, |
---|
[6724] | 198 | ) |
---|
| 199 | |
---|
| 200 | previous_verdict = schema.Choice( |
---|
| 201 | title = u'Previous Verdict', |
---|
| 202 | source = verdicts, |
---|
[6805] | 203 | default = '0', |
---|
[6725] | 204 | required = False, |
---|
[6724] | 205 | ) |
---|
| 206 | |
---|
[6774] | 207 | class IStudentStudyLevel(IWAeUPObject): |
---|
| 208 | """A container for course tickets. |
---|
| 209 | |
---|
| 210 | """ |
---|
| 211 | level = Attribute('The level code') |
---|
[6793] | 212 | validation_date = Attribute('The date of validation') |
---|
| 213 | validated_by = Attribute('User Id of course adviser') |
---|
[6774] | 214 | |
---|
[6793] | 215 | level_session = schema.Choice( |
---|
| 216 | title = u'Session', |
---|
| 217 | source = academic_sessions_vocab, |
---|
| 218 | default = None, |
---|
| 219 | required = True, |
---|
| 220 | ) |
---|
[6781] | 221 | |
---|
[6793] | 222 | level_verdict = schema.Choice( |
---|
| 223 | title = u'Verdict', |
---|
| 224 | source = verdicts, |
---|
[6805] | 225 | default = '0', |
---|
[6793] | 226 | required = False, |
---|
| 227 | ) |
---|
| 228 | |
---|
[6781] | 229 | class ICourseTicket(IWAeUPObject): |
---|
| 230 | """A course ticket. |
---|
| 231 | |
---|
| 232 | """ |
---|
[6783] | 233 | code = Attribute('code of the original course') |
---|
| 234 | title = Attribute('title of the original course') |
---|
| 235 | credits = Attribute('credits of the original course') |
---|
| 236 | passmark = Attribute('passmark of the original course') |
---|
| 237 | semester = Attribute('semester of the original course') |
---|
| 238 | faculty = Attribute('faculty of the original course') |
---|
| 239 | department = Attribute('department of the original course') |
---|
[6781] | 240 | |
---|
[6795] | 241 | core_or_elective = schema.Bool( |
---|
| 242 | title = u'Mandatory', |
---|
| 243 | default = False, |
---|
| 244 | required = False, |
---|
| 245 | readonly = False, |
---|
| 246 | ) |
---|
| 247 | |
---|
[6781] | 248 | score = schema.Int( |
---|
| 249 | title = u'Score', |
---|
| 250 | default = 0, |
---|
| 251 | required = False, |
---|
| 252 | readonly = False, |
---|
| 253 | ) |
---|
| 254 | |
---|
[6806] | 255 | automatic = schema.Bool( |
---|
| 256 | title = u'Automatical Creation', |
---|
| 257 | default = False, |
---|
| 258 | required = False, |
---|
| 259 | readonly = True, |
---|
| 260 | ) |
---|
| 261 | |
---|
[6795] | 262 | class ICourseTicketAdd(ICourseTicket): |
---|
| 263 | """An interface for adding course tickets |
---|
| 264 | |
---|
| 265 | """ |
---|
| 266 | course = schema.Choice( |
---|
| 267 | title = u'Course', |
---|
| 268 | source = CourseSource(), |
---|
| 269 | readonly = False, |
---|
| 270 | ) |
---|
| 271 | |
---|
[6635] | 272 | class IStudentAccommodation(IWAeUPObject): |
---|
| 273 | """A container for student accommodation objects. |
---|
| 274 | |
---|
| 275 | """ |
---|
| 276 | |
---|
| 277 | class IStudentPayments(IWAeUPObject): |
---|
| 278 | """A container for student payment objects. |
---|
| 279 | |
---|
| 280 | """ |
---|
| 281 | |
---|
[6694] | 282 | # Interfaces for students only |
---|
| 283 | |
---|
| 284 | class IStudentClearanceEdit(IStudentClearance): |
---|
| 285 | """Interface needed for restricted editing of student clearance data. |
---|
| 286 | """ |
---|
| 287 | |
---|
| 288 | class IStudentPersonalEdit(IStudentPersonal): |
---|
| 289 | """Interface needed for restricted editing of student personal data. |
---|
| 290 | """ |
---|