[6621] | 1 | ## |
---|
| 2 | ## interfaces.py |
---|
[6706] | 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 |
---|
[6648] | 7 | from waeup.sirp.students.vocabularies import ( |
---|
| 8 | year_range, lgas_vocab, CertificateSource, GenderSource, |
---|
| 9 | ) |
---|
[6621] | 10 | |
---|
[6692] | 11 | class IStudentsContainer(IWAeUPObject): |
---|
| 12 | """An students container contains university students. |
---|
| 13 | |
---|
| 14 | """ |
---|
| 15 | |
---|
| 16 | def addStudent(student): |
---|
| 17 | """Add an IStudent object and subcontainers. |
---|
| 18 | |
---|
| 19 | """ |
---|
| 20 | |
---|
| 21 | def archive(id=None): |
---|
| 22 | """Create on-dist archive of students. |
---|
| 23 | |
---|
| 24 | If id is `None`, all students are archived. |
---|
| 25 | |
---|
| 26 | If id contains a single id string, only the respective |
---|
| 27 | students are archived. |
---|
| 28 | |
---|
| 29 | If id contains a list of id strings all of the respective |
---|
| 30 | students types are saved to disk. |
---|
| 31 | """ |
---|
| 32 | |
---|
| 33 | def clear(id=None, archive=True): |
---|
| 34 | """Remove students of type given by 'id'. |
---|
| 35 | |
---|
| 36 | Optionally archive the students. |
---|
| 37 | |
---|
| 38 | If id is `None`, all students are archived. |
---|
| 39 | |
---|
| 40 | If id contains a single id string, only the respective |
---|
| 41 | students are archived. |
---|
| 42 | |
---|
| 43 | If id contains a list of id strings all of the respective |
---|
| 44 | student types are saved to disk. |
---|
| 45 | |
---|
| 46 | If `archive` is ``False`` none of the archive-handling is done |
---|
| 47 | and respective students are simply removed from the |
---|
| 48 | database. |
---|
| 49 | """ |
---|
| 50 | |
---|
[6642] | 51 | class IStudentNavigation(IWAeUPObject): |
---|
| 52 | """Interface needed for student navigation. |
---|
| 53 | """ |
---|
| 54 | |
---|
| 55 | def getStudent(): |
---|
| 56 | """Return student object. |
---|
| 57 | """ |
---|
| 58 | |
---|
[6705] | 59 | class IStudentPasswordSetting(IWAeUPObject): |
---|
| 60 | """Data needed for password setting. |
---|
| 61 | """ |
---|
| 62 | name = schema.TextLine( |
---|
| 63 | title = u'Full Name', |
---|
| 64 | default = u'Nobody', |
---|
| 65 | required = True, |
---|
| 66 | ) |
---|
| 67 | |
---|
| 68 | password = schema.Password( |
---|
| 69 | title = u'New password', |
---|
| 70 | required = False, |
---|
| 71 | ) |
---|
| 72 | |
---|
| 73 | password_repeat = schema.Password( |
---|
| 74 | title = u'Retype new password', |
---|
| 75 | required = False, |
---|
| 76 | ) |
---|
| 77 | |
---|
[6706] | 78 | @invariant |
---|
| 79 | def passwords_match(obj): |
---|
| 80 | if obj.password == obj.password_repeat: |
---|
| 81 | return |
---|
| 82 | raise Invalid('passwords do not match') |
---|
| 83 | |
---|
[6631] | 84 | class IStudentBase(IWAeUPObject): |
---|
| 85 | """Representation of student base data. |
---|
[6621] | 86 | """ |
---|
[6637] | 87 | history = Attribute('Object history, a list of messages.') |
---|
| 88 | state = Attribute('Returns the registration state of a student') |
---|
[6699] | 89 | password = Attribute('Encrypted password of a student') |
---|
[6637] | 90 | |
---|
[6705] | 91 | password = schema.Password( |
---|
| 92 | title = u'Password', |
---|
| 93 | required = False, |
---|
| 94 | ) |
---|
| 95 | |
---|
[6637] | 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 | |
---|
[6621] | 105 | name = schema.TextLine( |
---|
[6631] | 106 | title = u'Full Name', |
---|
[6621] | 107 | default = u'Nobody', |
---|
| 108 | required = True, |
---|
| 109 | ) |
---|
| 110 | |
---|
[6696] | 111 | reg_number = schema.TextLine( |
---|
| 112 | title = u'Registration Number', |
---|
| 113 | default = u'', |
---|
| 114 | required = True, |
---|
| 115 | readonly = False, |
---|
| 116 | ) |
---|
| 117 | |
---|
[6631] | 118 | class IStudentClearance(IWAeUPObject): |
---|
| 119 | """Representation of student clearance data. |
---|
| 120 | """ |
---|
[6622] | 121 | |
---|
[6631] | 122 | date_of_birth = schema.Date( |
---|
| 123 | title = u'Date of Birth', |
---|
| 124 | required = True, |
---|
| 125 | ) |
---|
| 126 | |
---|
[6695] | 127 | clearance_locked = schema.Bool( |
---|
| 128 | title = u'Clearance form locked', |
---|
| 129 | default = False, |
---|
| 130 | ) |
---|
| 131 | |
---|
[6631] | 132 | class IStudentPersonal(IWAeUPObject): |
---|
| 133 | """Representation of student personal data. |
---|
| 134 | """ |
---|
| 135 | |
---|
[6651] | 136 | perm_address = schema.Text( |
---|
[6631] | 137 | title = u'Permanent Address', |
---|
| 138 | required = False, |
---|
| 139 | ) |
---|
| 140 | |
---|
| 141 | class IStudent(IStudentBase,IStudentClearance,IStudentPersonal): |
---|
| 142 | """Representation of a student. |
---|
| 143 | """ |
---|
| 144 | |
---|
[6633] | 145 | class IStudentStudyCourse(IWAeUPObject): |
---|
| 146 | """A container for student study levels. |
---|
| 147 | |
---|
| 148 | """ |
---|
| 149 | |
---|
[6648] | 150 | certificate = schema.Choice( |
---|
| 151 | title = u'Certificate', |
---|
| 152 | source = CertificateSource(), |
---|
| 153 | default = None, |
---|
[6633] | 154 | required = True, |
---|
| 155 | ) |
---|
[6635] | 156 | |
---|
| 157 | class IStudentAccommodation(IWAeUPObject): |
---|
| 158 | """A container for student accommodation objects. |
---|
| 159 | |
---|
| 160 | """ |
---|
| 161 | |
---|
| 162 | class IStudentPayments(IWAeUPObject): |
---|
| 163 | """A container for student payment objects. |
---|
| 164 | |
---|
| 165 | """ |
---|
| 166 | |
---|
[6694] | 167 | # Interfaces for students only |
---|
| 168 | |
---|
| 169 | class IStudentBaseEdit(IStudentBase): |
---|
| 170 | """Interface needed for editing of student base data by students. |
---|
| 171 | """ |
---|
| 172 | |
---|
| 173 | name = schema.TextLine( |
---|
| 174 | title = u'Full Name', |
---|
| 175 | default = u'Nobody', |
---|
| 176 | required = True, |
---|
| 177 | readonly = True, |
---|
| 178 | ) |
---|
| 179 | |
---|
| 180 | IStudentBaseEdit['name'].order = IStudentBase['name'].order |
---|
| 181 | |
---|
| 182 | class IStudentClearanceEdit(IStudentClearance): |
---|
| 183 | """Interface needed for restricted editing of student clearance data. |
---|
| 184 | """ |
---|
| 185 | |
---|
| 186 | class IStudentPersonalEdit(IStudentPersonal): |
---|
| 187 | """Interface needed for restricted editing of student personal data. |
---|
| 188 | """ |
---|