[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, |
---|
[6764] | 68 | readonly = True |
---|
[6756] | 69 | ) |
---|
| 70 | |
---|
| 71 | password = schema.Password( |
---|
| 72 | title = u'New password', |
---|
| 73 | required = False, |
---|
| 74 | ) |
---|
| 75 | |
---|
| 76 | password_repeat = schema.Password( |
---|
| 77 | title = u'Retype new password', |
---|
| 78 | required = False, |
---|
| 79 | ) |
---|
| 80 | |
---|
| 81 | @invariant |
---|
| 82 | def passwords_match(obj): |
---|
| 83 | if obj.password == obj.password_repeat: |
---|
| 84 | return |
---|
| 85 | raise Invalid('passwords do not match') |
---|
| 86 | |
---|
[6631] | 87 | class IStudentBase(IWAeUPObject): |
---|
| 88 | """Representation of student base data. |
---|
[6621] | 89 | """ |
---|
[6637] | 90 | history = Attribute('Object history, a list of messages.') |
---|
| 91 | state = Attribute('Returns the registration state of a student') |
---|
[6699] | 92 | password = Attribute('Encrypted password of a student') |
---|
[6637] | 93 | |
---|
| 94 | def loggerInfo(ob_class, comment): |
---|
| 95 | """Adds an INFO message to the log file |
---|
| 96 | """ |
---|
| 97 | |
---|
[6665] | 98 | student_id = schema.TextLine( |
---|
| 99 | title = u'Student ID', |
---|
| 100 | required = True, |
---|
| 101 | ) |
---|
| 102 | |
---|
[6621] | 103 | name = schema.TextLine( |
---|
[6631] | 104 | title = u'Full Name', |
---|
[6621] | 105 | default = u'Nobody', |
---|
| 106 | required = True, |
---|
| 107 | ) |
---|
| 108 | |
---|
[6696] | 109 | reg_number = schema.TextLine( |
---|
| 110 | title = u'Registration Number', |
---|
| 111 | default = u'', |
---|
| 112 | required = True, |
---|
| 113 | readonly = False, |
---|
| 114 | ) |
---|
| 115 | |
---|
[6750] | 116 | matric_number = schema.TextLine( |
---|
| 117 | title = u'Matriculation Number', |
---|
| 118 | default = u'', |
---|
| 119 | required = False, |
---|
| 120 | readonly = False, |
---|
| 121 | ) |
---|
| 122 | |
---|
[6769] | 123 | adm_code = schema.TextLine( |
---|
[6771] | 124 | title = u'PWD Access Code', |
---|
[6769] | 125 | default = u'', |
---|
| 126 | required = False, |
---|
| 127 | readonly = True, |
---|
| 128 | ) |
---|
| 129 | |
---|
[6631] | 130 | class IStudentClearance(IWAeUPObject): |
---|
| 131 | """Representation of student clearance data. |
---|
| 132 | """ |
---|
[6622] | 133 | |
---|
[6631] | 134 | date_of_birth = schema.Date( |
---|
| 135 | title = u'Date of Birth', |
---|
| 136 | required = True, |
---|
| 137 | ) |
---|
| 138 | |
---|
[6695] | 139 | clearance_locked = schema.Bool( |
---|
| 140 | title = u'Clearance form locked', |
---|
| 141 | default = False, |
---|
| 142 | ) |
---|
| 143 | |
---|
[6769] | 144 | clr_code = schema.TextLine( |
---|
[6771] | 145 | title = u'CLR Access Code', |
---|
[6769] | 146 | default = u'', |
---|
| 147 | required = False, |
---|
| 148 | readonly = True, |
---|
| 149 | ) |
---|
| 150 | |
---|
[6631] | 151 | class IStudentPersonal(IWAeUPObject): |
---|
| 152 | """Representation of student personal data. |
---|
| 153 | """ |
---|
| 154 | |
---|
[6651] | 155 | perm_address = schema.Text( |
---|
[6631] | 156 | title = u'Permanent Address', |
---|
| 157 | required = False, |
---|
| 158 | ) |
---|
| 159 | |
---|
| 160 | class IStudent(IStudentBase,IStudentClearance,IStudentPersonal): |
---|
| 161 | """Representation of a student. |
---|
| 162 | """ |
---|
| 163 | |
---|
[6633] | 164 | class IStudentStudyCourse(IWAeUPObject): |
---|
| 165 | """A container for student study levels. |
---|
| 166 | |
---|
| 167 | """ |
---|
| 168 | |
---|
[6648] | 169 | certificate = schema.Choice( |
---|
| 170 | title = u'Certificate', |
---|
| 171 | source = CertificateSource(), |
---|
| 172 | default = None, |
---|
[6633] | 173 | required = True, |
---|
| 174 | ) |
---|
[6635] | 175 | |
---|
[6724] | 176 | current_session = schema.Choice( |
---|
| 177 | title = u'Current Session', |
---|
[6744] | 178 | source = academic_sessions_vocab, |
---|
[6724] | 179 | default = None, |
---|
| 180 | required = True, |
---|
| 181 | ) |
---|
| 182 | |
---|
| 183 | current_level = schema.Choice( |
---|
| 184 | title = u'Current Level', |
---|
[6725] | 185 | source = StudyLevelSource(), |
---|
[6724] | 186 | default = None, |
---|
[6725] | 187 | required = False, |
---|
[6724] | 188 | ) |
---|
| 189 | |
---|
| 190 | current_verdict = schema.Choice( |
---|
| 191 | title = u'Current Verdict', |
---|
| 192 | source = verdicts, |
---|
| 193 | default = None, |
---|
[6725] | 194 | required = False, |
---|
[6724] | 195 | ) |
---|
| 196 | |
---|
| 197 | previous_verdict = schema.Choice( |
---|
| 198 | title = u'Previous Verdict', |
---|
| 199 | source = verdicts, |
---|
| 200 | default = None, |
---|
[6725] | 201 | required = False, |
---|
[6724] | 202 | ) |
---|
| 203 | |
---|
[6635] | 204 | class IStudentAccommodation(IWAeUPObject): |
---|
| 205 | """A container for student accommodation objects. |
---|
| 206 | |
---|
| 207 | """ |
---|
| 208 | |
---|
| 209 | class IStudentPayments(IWAeUPObject): |
---|
| 210 | """A container for student payment objects. |
---|
| 211 | |
---|
| 212 | """ |
---|
| 213 | |
---|
[6694] | 214 | # Interfaces for students only |
---|
| 215 | |
---|
| 216 | class IStudentClearanceEdit(IStudentClearance): |
---|
| 217 | """Interface needed for restricted editing of student clearance data. |
---|
| 218 | """ |
---|
| 219 | |
---|
| 220 | class IStudentPersonalEdit(IStudentPersonal): |
---|
| 221 | """Interface needed for restricted editing of student personal data. |
---|
| 222 | """ |
---|