[6621] | 1 | ## |
---|
| 2 | ## interfaces.py |
---|
[6756] | 3 | from zope.interface import Interface, Attribute, invariant |
---|
| 4 | from zope.interface.exceptions import Invalid |
---|
[6621] | 5 | from zope import schema |
---|
| 6 | from waeup.sirp.interfaces import IWAeUPObject |
---|
[6724] | 7 | from waeup.sirp.university.vocabularies import study_modes |
---|
[6648] | 8 | from waeup.sirp.students.vocabularies import ( |
---|
| 9 | year_range, lgas_vocab, CertificateSource, GenderSource, |
---|
[6744] | 10 | academic_sessions_vocab, verdicts, StudyLevelSource, |
---|
[6648] | 11 | ) |
---|
[6621] | 12 | |
---|
[6692] | 13 | class IStudentsContainer(IWAeUPObject): |
---|
| 14 | """An students container contains university students. |
---|
| 15 | |
---|
| 16 | """ |
---|
| 17 | |
---|
| 18 | def addStudent(student): |
---|
| 19 | """Add an IStudent object and subcontainers. |
---|
| 20 | |
---|
| 21 | """ |
---|
| 22 | |
---|
| 23 | def archive(id=None): |
---|
| 24 | """Create on-dist archive of students. |
---|
| 25 | |
---|
| 26 | If id is `None`, all students are archived. |
---|
| 27 | |
---|
| 28 | If id contains a single id string, only the respective |
---|
| 29 | students are archived. |
---|
| 30 | |
---|
| 31 | If id contains a list of id strings all of the respective |
---|
| 32 | students types are saved to disk. |
---|
| 33 | """ |
---|
| 34 | |
---|
| 35 | def clear(id=None, archive=True): |
---|
| 36 | """Remove students of type given by 'id'. |
---|
| 37 | |
---|
| 38 | Optionally archive the students. |
---|
| 39 | |
---|
| 40 | If id is `None`, all students are archived. |
---|
| 41 | |
---|
| 42 | If id contains a single id string, only the respective |
---|
| 43 | students are archived. |
---|
| 44 | |
---|
| 45 | If id contains a list of id strings all of the respective |
---|
| 46 | student types are saved to disk. |
---|
| 47 | |
---|
| 48 | If `archive` is ``False`` none of the archive-handling is done |
---|
| 49 | and respective students are simply removed from the |
---|
| 50 | database. |
---|
| 51 | """ |
---|
| 52 | |
---|
[6642] | 53 | class IStudentNavigation(IWAeUPObject): |
---|
| 54 | """Interface needed for student navigation. |
---|
| 55 | """ |
---|
| 56 | |
---|
| 57 | def getStudent(): |
---|
| 58 | """Return student object. |
---|
| 59 | """ |
---|
| 60 | |
---|
[6756] | 61 | class IStudentPasswordSetting(IWAeUPObject): |
---|
| 62 | """Data needed for password setting. |
---|
| 63 | """ |
---|
| 64 | name = schema.TextLine( |
---|
| 65 | title = u'Full Name', |
---|
| 66 | default = u'Nobody', |
---|
| 67 | required = True, |
---|
| 68 | ) |
---|
| 69 | |
---|
| 70 | password = schema.Password( |
---|
| 71 | title = u'New password', |
---|
| 72 | required = False, |
---|
| 73 | ) |
---|
| 74 | |
---|
| 75 | password_repeat = schema.Password( |
---|
| 76 | title = u'Retype new password', |
---|
| 77 | required = False, |
---|
| 78 | ) |
---|
| 79 | |
---|
| 80 | @invariant |
---|
| 81 | def passwords_match(obj): |
---|
| 82 | if obj.password == obj.password_repeat: |
---|
| 83 | return |
---|
| 84 | raise Invalid('passwords do not match') |
---|
| 85 | |
---|
[6631] | 86 | class IStudentBase(IWAeUPObject): |
---|
| 87 | """Representation of student base data. |
---|
[6621] | 88 | """ |
---|
[6637] | 89 | history = Attribute('Object history, a list of messages.') |
---|
| 90 | state = Attribute('Returns the registration state of a student') |
---|
[6699] | 91 | password = Attribute('Encrypted password of a student') |
---|
[6704] | 92 | adm_code = Attribute('Admission checking access code') |
---|
[6637] | 93 | |
---|
[6756] | 94 | password = schema.Password( |
---|
| 95 | title = u'Password', |
---|
| 96 | required = False, |
---|
| 97 | ) |
---|
| 98 | |
---|
[6637] | 99 | def loggerInfo(ob_class, comment): |
---|
| 100 | """Adds an INFO message to the log file |
---|
| 101 | """ |
---|
| 102 | |
---|
[6665] | 103 | student_id = schema.TextLine( |
---|
| 104 | title = u'Student ID', |
---|
| 105 | required = True, |
---|
| 106 | ) |
---|
| 107 | |
---|
[6621] | 108 | name = schema.TextLine( |
---|
[6631] | 109 | title = u'Full Name', |
---|
[6621] | 110 | default = u'Nobody', |
---|
| 111 | required = True, |
---|
| 112 | ) |
---|
| 113 | |
---|
[6696] | 114 | reg_number = schema.TextLine( |
---|
| 115 | title = u'Registration Number', |
---|
| 116 | default = u'', |
---|
| 117 | required = True, |
---|
| 118 | readonly = False, |
---|
| 119 | ) |
---|
| 120 | |
---|
[6750] | 121 | matric_number = schema.TextLine( |
---|
| 122 | title = u'Matriculation Number', |
---|
| 123 | default = u'', |
---|
| 124 | required = False, |
---|
| 125 | readonly = False, |
---|
| 126 | ) |
---|
| 127 | |
---|
[6631] | 128 | class IStudentClearance(IWAeUPObject): |
---|
| 129 | """Representation of student clearance data. |
---|
| 130 | """ |
---|
[6622] | 131 | |
---|
[6631] | 132 | date_of_birth = schema.Date( |
---|
| 133 | title = u'Date of Birth', |
---|
| 134 | required = True, |
---|
| 135 | ) |
---|
| 136 | |
---|
[6695] | 137 | clearance_locked = schema.Bool( |
---|
| 138 | title = u'Clearance form locked', |
---|
| 139 | default = False, |
---|
| 140 | ) |
---|
| 141 | |
---|
[6631] | 142 | class IStudentPersonal(IWAeUPObject): |
---|
| 143 | """Representation of student personal data. |
---|
| 144 | """ |
---|
| 145 | |
---|
[6651] | 146 | perm_address = schema.Text( |
---|
[6631] | 147 | title = u'Permanent Address', |
---|
| 148 | required = False, |
---|
| 149 | ) |
---|
| 150 | |
---|
| 151 | class IStudent(IStudentBase,IStudentClearance,IStudentPersonal): |
---|
| 152 | """Representation of a student. |
---|
| 153 | """ |
---|
| 154 | |
---|
[6633] | 155 | class IStudentStudyCourse(IWAeUPObject): |
---|
| 156 | """A container for student study levels. |
---|
| 157 | |
---|
| 158 | """ |
---|
| 159 | |
---|
[6648] | 160 | certificate = schema.Choice( |
---|
| 161 | title = u'Certificate', |
---|
| 162 | source = CertificateSource(), |
---|
| 163 | default = None, |
---|
[6633] | 164 | required = True, |
---|
| 165 | ) |
---|
[6635] | 166 | |
---|
[6724] | 167 | current_session = schema.Choice( |
---|
| 168 | title = u'Current Session', |
---|
[6744] | 169 | source = academic_sessions_vocab, |
---|
[6724] | 170 | default = None, |
---|
| 171 | required = True, |
---|
| 172 | ) |
---|
| 173 | |
---|
| 174 | current_level = schema.Choice( |
---|
| 175 | title = u'Current Level', |
---|
[6725] | 176 | source = StudyLevelSource(), |
---|
[6724] | 177 | default = None, |
---|
[6725] | 178 | required = False, |
---|
[6724] | 179 | ) |
---|
| 180 | |
---|
| 181 | current_verdict = schema.Choice( |
---|
| 182 | title = u'Current Verdict', |
---|
| 183 | source = verdicts, |
---|
| 184 | default = None, |
---|
[6725] | 185 | required = False, |
---|
[6724] | 186 | ) |
---|
| 187 | |
---|
| 188 | previous_verdict = schema.Choice( |
---|
| 189 | title = u'Previous Verdict', |
---|
| 190 | source = verdicts, |
---|
| 191 | default = None, |
---|
[6725] | 192 | required = False, |
---|
[6724] | 193 | ) |
---|
| 194 | |
---|
[6635] | 195 | class IStudentAccommodation(IWAeUPObject): |
---|
| 196 | """A container for student accommodation objects. |
---|
| 197 | |
---|
| 198 | """ |
---|
| 199 | |
---|
| 200 | class IStudentPayments(IWAeUPObject): |
---|
| 201 | """A container for student payment objects. |
---|
| 202 | |
---|
| 203 | """ |
---|
| 204 | |
---|
[6694] | 205 | # Interfaces for students only |
---|
| 206 | |
---|
| 207 | class IStudentBaseEdit(IStudentBase): |
---|
| 208 | """Interface needed for editing of student base data by students. |
---|
| 209 | """ |
---|
| 210 | |
---|
| 211 | name = schema.TextLine( |
---|
| 212 | title = u'Full Name', |
---|
| 213 | default = u'Nobody', |
---|
| 214 | required = True, |
---|
| 215 | readonly = True, |
---|
| 216 | ) |
---|
| 217 | |
---|
| 218 | IStudentBaseEdit['name'].order = IStudentBase['name'].order |
---|
| 219 | |
---|
| 220 | class IStudentClearanceEdit(IStudentClearance): |
---|
| 221 | """Interface needed for restricted editing of student clearance data. |
---|
| 222 | """ |
---|
| 223 | |
---|
| 224 | class IStudentPersonalEdit(IStudentPersonal): |
---|
| 225 | """Interface needed for restricted editing of student personal data. |
---|
| 226 | """ |
---|