[57] | 1 | #-*- mode: python; mode: fold -*- |
---|
[45] | 2 | from Globals import InitializeClass |
---|
| 3 | from AccessControl import ClassSecurityInfo |
---|
| 4 | |
---|
[47] | 5 | from Products.CMFCore.utils import UniqueObject, getToolByName |
---|
[45] | 6 | from Products.CMFCore.permissions import View |
---|
| 7 | from Products.CMFCore.permissions import ModifyPortalContent |
---|
| 8 | from Products.CPSCore.CPSBase import CPSBase_adder, CPSBaseFolder |
---|
[47] | 9 | #from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument |
---|
| 10 | from Products.CPSDocument.CPSDocument import CPSDocument |
---|
[45] | 11 | from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder |
---|
[57] | 12 | class StudentsFolder(BaseBTreeFolder): ###( |
---|
[45] | 13 | """ |
---|
| 14 | WAeUP container for the various WAeUP containers data |
---|
| 15 | """ |
---|
| 16 | meta_type = 'Students Folder' |
---|
| 17 | portal_type = meta_type |
---|
| 18 | security = ClassSecurityInfo() |
---|
| 19 | |
---|
[47] | 20 | |
---|
[45] | 21 | InitializeClass(StudentsFolder) |
---|
| 22 | |
---|
| 23 | def addStudentsFolder(container, id, REQUEST=None, **kw): |
---|
| 24 | """Add a Student.""" |
---|
| 25 | ob = StudentsFolder(id, **kw) |
---|
| 26 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
[57] | 27 | ###) |
---|
| 28 | |
---|
| 29 | student_fti = { ###( |
---|
| 30 | 'title': 'WAeUP Student', |
---|
| 31 | 'description': '', |
---|
| 32 | 'content_icon': 'student.gif', |
---|
| 33 | 'content_meta_type': 'Student', |
---|
| 34 | 'factory': 'addStudent', |
---|
| 35 | 'immediate_view': 'cpsdocument_view', |
---|
| 36 | 'global_allow': True, |
---|
| 37 | 'filter_content_types': True, |
---|
| 38 | 'allowed_content_types': ('Jamb','StudentPersonal'), |
---|
| 39 | 'allow_discussion': False, |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | ###) |
---|
| 43 | |
---|
| 44 | class Student(CPSDocument): ###( |
---|
| 45 | """ |
---|
| 46 | WAeUP Student container for the various student data |
---|
| 47 | """ |
---|
| 48 | meta_type = 'Student' |
---|
| 49 | portal_type = meta_type |
---|
| 50 | security = ClassSecurityInfo() |
---|
| 51 | |
---|
[152] | 52 | security.declareProtected(View,"Title") |
---|
| 53 | def Title(self): |
---|
| 54 | """compose title""" |
---|
[153] | 55 | reg_nr = self.getId()[1:] |
---|
[152] | 56 | data = getattr(self,'PERSONAL',None) |
---|
| 57 | if data is None: |
---|
| 58 | data = getattr(self,'JAMB',None) |
---|
| 59 | if data: |
---|
| 60 | content = data.getContent() |
---|
| 61 | return "%s %s" % (content.firstname,content.lastname) |
---|
| 62 | return self.title |
---|
| 63 | |
---|
[57] | 64 | InitializeClass(Student) |
---|
| 65 | |
---|
| 66 | def addStudent(container, id, REQUEST=None, **kw): |
---|
| 67 | """Add a Student.""" |
---|
| 68 | ob = Student(id, **kw) |
---|
| 69 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 70 | |
---|
| 71 | ###) |
---|
[91] | 72 | |
---|
[89] | 73 | studentpersonal_fti = { ###( |
---|
| 74 | 'title': 'WAeUP StudentPersonal', |
---|
| 75 | 'description': '', |
---|
| 76 | 'content_icon': 'student.gif', |
---|
| 77 | 'content_meta_type': 'StudentPersonal', |
---|
| 78 | 'factory': 'addStudent', |
---|
| 79 | 'immediate_view': 'student_personal_index_html', |
---|
| 80 | 'global_allow': True, |
---|
| 81 | 'filter_content_types': True, |
---|
| 82 | 'allowed_content_types': (), |
---|
| 83 | 'allow_discussion': False, |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | ###) |
---|
| 87 | |
---|
| 88 | class StudentPersonal(CPSDocument): ###( |
---|
| 89 | """ |
---|
| 90 | WAeUP Student container for the various student data |
---|
| 91 | """ |
---|
| 92 | meta_type = 'StudentPersonal' |
---|
| 93 | portal_type = meta_type |
---|
| 94 | security = ClassSecurityInfo() |
---|
[152] | 95 | |
---|
| 96 | security.declareProtected(View,"Title") |
---|
| 97 | def Title(self): |
---|
| 98 | """compose title""" |
---|
| 99 | content = self.getContent() |
---|
| 100 | return "Personal Data for %s %s" % (content.firstname,content.lastname) |
---|
| 101 | |
---|
[89] | 102 | |
---|
| 103 | InitializeClass(StudentPersonal) |
---|
| 104 | |
---|
| 105 | def addStudentPersonal(container, id, REQUEST=None, **kw): |
---|
| 106 | """Add a Students personal data.""" |
---|
| 107 | ob = StudentPersonal(id, **kw) |
---|
| 108 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 109 | |
---|
| 110 | ###) |
---|
| 111 | |
---|
| 112 | jamb_fti = { ###( |
---|
| 113 | 'title': 'WAeUP Jamb', |
---|
| 114 | 'description': '', |
---|
| 115 | 'content_icon': '', |
---|
| 116 | 'content_meta_type': 'Jamb', |
---|
| 117 | 'factory': 'addJamb', |
---|
| 118 | 'immediate_view': 'cpsdocument_view', |
---|
| 119 | 'global_allow': True, |
---|
| 120 | 'filter_content_types': True, |
---|
| 121 | 'allowed_content_types': ('Course',), |
---|
| 122 | 'allow_discussion': False, |
---|
| 123 | } |
---|
| 124 | ###) |
---|
| 125 | |
---|
| 126 | class Jamb(CPSDocument): ###( |
---|
| 127 | """ |
---|
| 128 | WAeUP Jamb containing the courses and students |
---|
| 129 | """ |
---|
| 130 | meta_type = 'Jamb' |
---|
| 131 | portal_type = meta_type |
---|
| 132 | security = ClassSecurityInfo() |
---|
| 133 | |
---|
[152] | 134 | security.declareProtected(View,"Title") |
---|
| 135 | def Title(self): |
---|
| 136 | """compose title""" |
---|
| 137 | content = self.getContent() |
---|
| 138 | return "JAMB Data for %s %s" % (content.firstname,content.lastname) |
---|
| 139 | |
---|
| 140 | security.declareProtected(View,"setOwnership") |
---|
| 141 | def setOwnership(self,member_id): |
---|
| 142 | """set ownership""" |
---|
| 143 | pm = getattr(self,'portal_membership') |
---|
| 144 | member = pm.getMemberById(member_id) |
---|
| 145 | self.changeOwnership(member) |
---|
| 146 | |
---|
[89] | 147 | InitializeClass(Jamb) |
---|
| 148 | |
---|
| 149 | def addJamb(container, id, REQUEST=None, **kw): |
---|
| 150 | """Add a Jamb.""" |
---|
| 151 | ob = Jamb(id, **kw) |
---|
| 152 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 153 | ###) |
---|
| 154 | |
---|
[139] | 155 | study_level_fti = { ###( |
---|
| 156 | 'title': 'WAeUP StudyLevel', |
---|
| 157 | 'description': '', |
---|
| 158 | 'content_icon': '', |
---|
| 159 | 'content_meta_type': 'StudyLevel', |
---|
| 160 | 'factory': 'addStudyLevel', |
---|
| 161 | 'immediate_view': 'cpsdocument_view', |
---|
| 162 | 'global_allow': True, |
---|
| 163 | 'filter_content_types': True, |
---|
| 164 | 'allowed_content_types': ('Course',), |
---|
| 165 | 'allow_discussion': False, |
---|
| 166 | } |
---|
| 167 | ###) |
---|
| 168 | |
---|
| 169 | class StudyLevel(CPSDocument): ###( |
---|
| 170 | """ |
---|
| 171 | WAeUP StudyLevel containing the courses and students |
---|
| 172 | """ |
---|
| 173 | meta_type = 'StudyLevel' |
---|
| 174 | portal_type = meta_type |
---|
| 175 | security = ClassSecurityInfo() |
---|
| 176 | |
---|
| 177 | InitializeClass(StudyLevel) |
---|
| 178 | |
---|
| 179 | def addStudyLevel(container, id, REQUEST=None, **kw): |
---|
| 180 | """Add a StudyLevel.""" |
---|
| 181 | ob = StudyLevel(id, **kw) |
---|
| 182 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 183 | ###) |
---|
| 184 | |
---|
| 185 | semester_fti = { ###( |
---|
| 186 | 'title': 'WAeUP Semester', |
---|
| 187 | 'description': '', |
---|
| 188 | 'content_icon': '', |
---|
| 189 | 'content_meta_type': 'Semester', |
---|
| 190 | 'factory': 'addSemester', |
---|
| 191 | 'immediate_view': 'cpsdocument_view', |
---|
| 192 | 'global_allow': True, |
---|
| 193 | 'filter_content_types': True, |
---|
| 194 | 'allowed_content_types': ('Course',), |
---|
| 195 | 'allow_discussion': False, |
---|
| 196 | } |
---|
| 197 | ###) |
---|
| 198 | |
---|
| 199 | class Semester(CPSDocument): ###( |
---|
| 200 | """ |
---|
| 201 | WAeUP Semester containing the courses and students |
---|
| 202 | """ |
---|
| 203 | meta_type = 'Semester' |
---|
| 204 | portal_type = meta_type |
---|
| 205 | security = ClassSecurityInfo() |
---|
| 206 | |
---|
| 207 | InitializeClass(Semester) |
---|
| 208 | |
---|
| 209 | def addSemester(container, id, REQUEST=None, **kw): |
---|
| 210 | """Add a Semester.""" |
---|
| 211 | ob = Semester(id, **kw) |
---|
| 212 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 213 | ###) |
---|
| 214 | |
---|