[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""" |
---|
[139] | 55 | |
---|
[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 | |
---|
| 64 | security.declareProtected(View,"setOwnership") |
---|
| 65 | def setOwnership(self,member_id): |
---|
| 66 | """set ownership""" |
---|
| 67 | pm = getattr(self,'portal_membership') |
---|
| 68 | member = pm.getMemberById(member_id) |
---|
| 69 | self.changeOwnership(member) |
---|
| 70 | |
---|
[57] | 71 | InitializeClass(Student) |
---|
| 72 | |
---|
| 73 | def addStudent(container, id, REQUEST=None, **kw): |
---|
| 74 | """Add a Student.""" |
---|
| 75 | ob = Student(id, **kw) |
---|
| 76 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 77 | |
---|
| 78 | ###) |
---|
[91] | 79 | |
---|
[89] | 80 | studentpersonal_fti = { ###( |
---|
| 81 | 'title': 'WAeUP StudentPersonal', |
---|
| 82 | 'description': '', |
---|
| 83 | 'content_icon': 'student.gif', |
---|
| 84 | 'content_meta_type': 'StudentPersonal', |
---|
| 85 | 'factory': 'addStudent', |
---|
| 86 | 'immediate_view': 'student_personal_index_html', |
---|
| 87 | 'global_allow': True, |
---|
| 88 | 'filter_content_types': True, |
---|
| 89 | 'allowed_content_types': (), |
---|
| 90 | 'allow_discussion': False, |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | ###) |
---|
| 94 | |
---|
| 95 | class StudentPersonal(CPSDocument): ###( |
---|
| 96 | """ |
---|
| 97 | WAeUP Student container for the various student data |
---|
| 98 | """ |
---|
| 99 | meta_type = 'StudentPersonal' |
---|
| 100 | portal_type = meta_type |
---|
| 101 | security = ClassSecurityInfo() |
---|
[152] | 102 | |
---|
| 103 | security.declareProtected(View,"Title") |
---|
| 104 | def Title(self): |
---|
| 105 | """compose title""" |
---|
| 106 | content = self.getContent() |
---|
| 107 | return "Personal Data for %s %s" % (content.firstname,content.lastname) |
---|
| 108 | |
---|
[89] | 109 | |
---|
| 110 | InitializeClass(StudentPersonal) |
---|
| 111 | |
---|
| 112 | def addStudentPersonal(container, id, REQUEST=None, **kw): |
---|
| 113 | """Add a Students personal data.""" |
---|
| 114 | ob = StudentPersonal(id, **kw) |
---|
| 115 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 116 | |
---|
| 117 | ###) |
---|
| 118 | |
---|
| 119 | jamb_fti = { ###( |
---|
| 120 | 'title': 'WAeUP Jamb', |
---|
| 121 | 'description': '', |
---|
| 122 | 'content_icon': '', |
---|
| 123 | 'content_meta_type': 'Jamb', |
---|
| 124 | 'factory': 'addJamb', |
---|
| 125 | 'immediate_view': 'cpsdocument_view', |
---|
| 126 | 'global_allow': True, |
---|
| 127 | 'filter_content_types': True, |
---|
| 128 | 'allowed_content_types': ('Course',), |
---|
| 129 | 'allow_discussion': False, |
---|
| 130 | } |
---|
| 131 | ###) |
---|
| 132 | |
---|
| 133 | class Jamb(CPSDocument): ###( |
---|
| 134 | """ |
---|
| 135 | WAeUP Jamb containing the courses and students |
---|
| 136 | """ |
---|
| 137 | meta_type = 'Jamb' |
---|
| 138 | portal_type = meta_type |
---|
| 139 | security = ClassSecurityInfo() |
---|
| 140 | |
---|
[152] | 141 | security.declareProtected(View,"Title") |
---|
| 142 | def Title(self): |
---|
| 143 | """compose title""" |
---|
| 144 | content = self.getContent() |
---|
| 145 | return "JAMB Data for %s %s" % (content.firstname,content.lastname) |
---|
| 146 | |
---|
| 147 | security.declareProtected(View,"setOwnership") |
---|
| 148 | def setOwnership(self,member_id): |
---|
| 149 | """set ownership""" |
---|
| 150 | pm = getattr(self,'portal_membership') |
---|
| 151 | member = pm.getMemberById(member_id) |
---|
| 152 | self.changeOwnership(member) |
---|
| 153 | |
---|
[89] | 154 | InitializeClass(Jamb) |
---|
| 155 | |
---|
| 156 | def addJamb(container, id, REQUEST=None, **kw): |
---|
| 157 | """Add a Jamb.""" |
---|
| 158 | ob = Jamb(id, **kw) |
---|
| 159 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 160 | ###) |
---|
| 161 | |
---|
[139] | 162 | study_level_fti = { ###( |
---|
| 163 | 'title': 'WAeUP StudyLevel', |
---|
| 164 | 'description': '', |
---|
| 165 | 'content_icon': '', |
---|
| 166 | 'content_meta_type': 'StudyLevel', |
---|
| 167 | 'factory': 'addStudyLevel', |
---|
| 168 | 'immediate_view': 'cpsdocument_view', |
---|
| 169 | 'global_allow': True, |
---|
| 170 | 'filter_content_types': True, |
---|
| 171 | 'allowed_content_types': ('Course',), |
---|
| 172 | 'allow_discussion': False, |
---|
| 173 | } |
---|
| 174 | ###) |
---|
| 175 | |
---|
| 176 | class StudyLevel(CPSDocument): ###( |
---|
| 177 | """ |
---|
| 178 | WAeUP StudyLevel containing the courses and students |
---|
| 179 | """ |
---|
| 180 | meta_type = 'StudyLevel' |
---|
| 181 | portal_type = meta_type |
---|
| 182 | security = ClassSecurityInfo() |
---|
| 183 | |
---|
| 184 | InitializeClass(StudyLevel) |
---|
| 185 | |
---|
| 186 | def addStudyLevel(container, id, REQUEST=None, **kw): |
---|
| 187 | """Add a StudyLevel.""" |
---|
| 188 | ob = StudyLevel(id, **kw) |
---|
| 189 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 190 | ###) |
---|
| 191 | |
---|
| 192 | semester_fti = { ###( |
---|
| 193 | 'title': 'WAeUP Semester', |
---|
| 194 | 'description': '', |
---|
| 195 | 'content_icon': '', |
---|
| 196 | 'content_meta_type': 'Semester', |
---|
| 197 | 'factory': 'addSemester', |
---|
| 198 | 'immediate_view': 'cpsdocument_view', |
---|
| 199 | 'global_allow': True, |
---|
| 200 | 'filter_content_types': True, |
---|
| 201 | 'allowed_content_types': ('Course',), |
---|
| 202 | 'allow_discussion': False, |
---|
| 203 | } |
---|
| 204 | ###) |
---|
| 205 | |
---|
| 206 | class Semester(CPSDocument): ###( |
---|
| 207 | """ |
---|
| 208 | WAeUP Semester containing the courses and students |
---|
| 209 | """ |
---|
| 210 | meta_type = 'Semester' |
---|
| 211 | portal_type = meta_type |
---|
| 212 | security = ClassSecurityInfo() |
---|
| 213 | |
---|
| 214 | InitializeClass(Semester) |
---|
| 215 | |
---|
| 216 | def addSemester(container, id, REQUEST=None, **kw): |
---|
| 217 | """Add a Semester.""" |
---|
| 218 | ob = Semester(id, **kw) |
---|
| 219 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 220 | ###) |
---|
| 221 | |
---|