1 | ## |
---|
2 | ## interfaces.py |
---|
3 | from zope.interface import Interface, Attribute |
---|
4 | from zope import schema |
---|
5 | from waeup.sirp.interfaces import IWAeUPObject |
---|
6 | from waeup.sirp.students.vocabularies import ( |
---|
7 | year_range, lgas_vocab, CertificateSource, GenderSource, |
---|
8 | ) |
---|
9 | |
---|
10 | class IStudentsContainer(IWAeUPObject): |
---|
11 | """An students container contains university students. |
---|
12 | |
---|
13 | """ |
---|
14 | |
---|
15 | def addStudent(student): |
---|
16 | """Add an IStudent object and subcontainers. |
---|
17 | |
---|
18 | """ |
---|
19 | |
---|
20 | def archive(id=None): |
---|
21 | """Create on-dist archive of students. |
---|
22 | |
---|
23 | If id is `None`, all students are archived. |
---|
24 | |
---|
25 | If id contains a single id string, only the respective |
---|
26 | students are archived. |
---|
27 | |
---|
28 | If id contains a list of id strings all of the respective |
---|
29 | students types are saved to disk. |
---|
30 | """ |
---|
31 | |
---|
32 | def clear(id=None, archive=True): |
---|
33 | """Remove students of type given by 'id'. |
---|
34 | |
---|
35 | Optionally archive the students. |
---|
36 | |
---|
37 | If id is `None`, all students are archived. |
---|
38 | |
---|
39 | If id contains a single id string, only the respective |
---|
40 | students are archived. |
---|
41 | |
---|
42 | If id contains a list of id strings all of the respective |
---|
43 | student types are saved to disk. |
---|
44 | |
---|
45 | If `archive` is ``False`` none of the archive-handling is done |
---|
46 | and respective students are simply removed from the |
---|
47 | database. |
---|
48 | """ |
---|
49 | |
---|
50 | class IStudentNavigation(IWAeUPObject): |
---|
51 | """Interface needed for student navigation. |
---|
52 | """ |
---|
53 | |
---|
54 | def getStudent(): |
---|
55 | """Return student object. |
---|
56 | """ |
---|
57 | |
---|
58 | class IStudentBase(IWAeUPObject): |
---|
59 | """Representation of student base data. |
---|
60 | """ |
---|
61 | history = Attribute('Object history, a list of messages.') |
---|
62 | state = Attribute('Returns the registration state of a student') |
---|
63 | #student_id = Attribute('Randomly generated id') |
---|
64 | password = Attribute('Encrypted password of a student') |
---|
65 | |
---|
66 | def loggerInfo(ob_class, comment): |
---|
67 | """Adds an INFO message to the log file |
---|
68 | """ |
---|
69 | |
---|
70 | student_id = schema.TextLine( |
---|
71 | title = u'Student ID', |
---|
72 | required = True, |
---|
73 | ) |
---|
74 | |
---|
75 | name = schema.TextLine( |
---|
76 | title = u'Full Name', |
---|
77 | default = u'Nobody', |
---|
78 | required = True, |
---|
79 | ) |
---|
80 | |
---|
81 | reg_number = schema.TextLine( |
---|
82 | title = u'Registration Number', |
---|
83 | default = u'', |
---|
84 | required = True, |
---|
85 | readonly = False, |
---|
86 | ) |
---|
87 | |
---|
88 | class IStudentClearance(IWAeUPObject): |
---|
89 | """Representation of student clearance data. |
---|
90 | """ |
---|
91 | |
---|
92 | date_of_birth = schema.Date( |
---|
93 | title = u'Date of Birth', |
---|
94 | required = True, |
---|
95 | ) |
---|
96 | |
---|
97 | clearance_locked = schema.Bool( |
---|
98 | title = u'Clearance form locked', |
---|
99 | default = False, |
---|
100 | ) |
---|
101 | |
---|
102 | class IStudentPersonal(IWAeUPObject): |
---|
103 | """Representation of student personal data. |
---|
104 | """ |
---|
105 | |
---|
106 | perm_address = schema.Text( |
---|
107 | title = u'Permanent Address', |
---|
108 | required = False, |
---|
109 | ) |
---|
110 | |
---|
111 | class IStudent(IStudentBase,IStudentClearance,IStudentPersonal): |
---|
112 | """Representation of a student. |
---|
113 | """ |
---|
114 | |
---|
115 | class IStudentStudyCourse(IWAeUPObject): |
---|
116 | """A container for student study levels. |
---|
117 | |
---|
118 | """ |
---|
119 | |
---|
120 | certificate = schema.Choice( |
---|
121 | title = u'Certificate', |
---|
122 | source = CertificateSource(), |
---|
123 | default = None, |
---|
124 | required = True, |
---|
125 | ) |
---|
126 | |
---|
127 | class IStudentAccommodation(IWAeUPObject): |
---|
128 | """A container for student accommodation objects. |
---|
129 | |
---|
130 | """ |
---|
131 | |
---|
132 | class IStudentPayments(IWAeUPObject): |
---|
133 | """A container for student payment objects. |
---|
134 | |
---|
135 | """ |
---|
136 | |
---|
137 | # Interfaces for students only |
---|
138 | |
---|
139 | class IStudentBaseEdit(IStudentBase): |
---|
140 | """Interface needed for editing of student base data by students. |
---|
141 | """ |
---|
142 | |
---|
143 | name = schema.TextLine( |
---|
144 | title = u'Full Name', |
---|
145 | default = u'Nobody', |
---|
146 | required = True, |
---|
147 | readonly = True, |
---|
148 | ) |
---|
149 | |
---|
150 | IStudentBaseEdit['name'].order = IStudentBase['name'].order |
---|
151 | |
---|
152 | class IStudentClearanceEdit(IStudentClearance): |
---|
153 | """Interface needed for restricted editing of student clearance data. |
---|
154 | """ |
---|
155 | |
---|
156 | class IStudentPersonalEdit(IStudentPersonal): |
---|
157 | """Interface needed for restricted editing of student personal data. |
---|
158 | """ |
---|