[68] | 1 | #-*- mode: python; mode: fold -*- |
---|
| 2 | from Globals import InitializeClass |
---|
| 3 | from AccessControl import ClassSecurityInfo |
---|
| 4 | |
---|
| 5 | from Products.CMFCore.utils import UniqueObject, getToolByName |
---|
| 6 | from Products.CMFCore.permissions import View |
---|
| 7 | from Products.CMFCore.permissions import ModifyPortalContent |
---|
| 8 | from Products.CPSCore.CPSBase import CPSBase_adder, CPSBaseFolder |
---|
| 9 | #from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument |
---|
| 10 | from Products.CPSDocument.CPSDocument import CPSDocument |
---|
| 11 | from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder |
---|
| 12 | |
---|
| 13 | ##class FacultyFolder(BaseBTreeFolder): ###( |
---|
| 14 | ## """ |
---|
| 15 | ## WAeUP container for the various WAeUP containers data |
---|
| 16 | ## """ |
---|
| 17 | ## meta_type = 'Faculty Folder' |
---|
| 18 | ## portal_type = meta_type |
---|
| 19 | ## security = ClassSecurityInfo() |
---|
| 20 | ## |
---|
| 21 | ## |
---|
| 22 | ##InitializeClass(FacultyFolder) |
---|
| 23 | ## |
---|
| 24 | ##def addFacultyFolder(container, id, REQUEST=None, **kw): |
---|
| 25 | ## """Add a Student.""" |
---|
| 26 | ## ob = StudentsFolder(id, **kw) |
---|
| 27 | ## return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 28 | ##### |
---|
| 29 | #####) |
---|
| 30 | |
---|
| 31 | faculty_fti = { ###( |
---|
| 32 | 'title': 'WAeUP Faculty', |
---|
| 33 | 'description': '', |
---|
| 34 | 'content_icon': '', |
---|
| 35 | 'content_meta_type': 'Faculty', |
---|
| 36 | 'factory': 'addFaculty', |
---|
| 37 | 'immediate_view': 'cpsdocument_view', |
---|
| 38 | 'global_allow': True, |
---|
| 39 | 'filter_content_types': True, |
---|
| 40 | 'allowed_content_types': ('Department',), |
---|
| 41 | 'allow_discussion': False, |
---|
[89] | 42 | ## 'actions': ( |
---|
| 43 | ## {'id': 'view', |
---|
| 44 | ## 'name': 'action_view', |
---|
| 45 | ## 'action': 'string:${object_url}/faculty_index_html', |
---|
| 46 | ## #'action': 'string:${object_url}/cpsdocument_view', |
---|
| 47 | ## 'condition': '', |
---|
| 48 | ## 'permission': ('View',), |
---|
| 49 | ## 'category': 'object', |
---|
| 50 | ## 'visible': True,}, |
---|
| 51 | ## {'id': 'new_content', |
---|
| 52 | ## 'name': 'Add Data', |
---|
| 53 | ## 'action': 'string:${object_url}/folder_factories', |
---|
| 54 | ## 'condition': "python:1 or len(object.contentItems()) == 0 ", |
---|
| 55 | ## 'permission': ('Modify portal content',), |
---|
| 56 | ## 'category': 'object', |
---|
| 57 | ## 'visible': True,}, |
---|
| 58 | ## {'id': 'contents', |
---|
| 59 | ## 'name': 'action_folder_contents', |
---|
| 60 | ## 'action': 'string:${object_url}/folder_contents', |
---|
| 61 | ## 'condition': "python:1 or object.getTypeInfo().cps_proxy_type != 'document'", |
---|
| 62 | ## 'permission': ('Modify portal content',), |
---|
| 63 | ## 'category': 'object', |
---|
| 64 | ## 'visible': True,}, |
---|
| 65 | ## {'id': 'edit', |
---|
| 66 | ## 'name': 'action_edit', |
---|
| 67 | ## 'action': 'string:${object_url}/cpsdocument_edit_form', |
---|
| 68 | ## 'condition': '', |
---|
| 69 | ## 'permission': ('Modify portal content',), |
---|
| 70 | ## 'category': 'object', |
---|
| 71 | ## 'visible': True,}, |
---|
| 72 | ## ) |
---|
[68] | 73 | } |
---|
| 74 | ###) |
---|
| 75 | |
---|
| 76 | class Faculty(CPSDocument): ###( |
---|
| 77 | """ |
---|
| 78 | WAeUP Faculty containing Departments |
---|
| 79 | """ |
---|
| 80 | meta_type = 'Faculty' |
---|
| 81 | portal_type = meta_type |
---|
| 82 | security = ClassSecurityInfo() |
---|
| 83 | |
---|
| 84 | InitializeClass(Faculty) |
---|
| 85 | |
---|
| 86 | def addFaculty(container, id, REQUEST=None, **kw): |
---|
| 87 | """Add a Faculty.""" |
---|
| 88 | ob = Faculty(id, **kw) |
---|
| 89 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 90 | ###) |
---|
| 91 | |
---|
| 92 | department_fti = { ###( |
---|
| 93 | 'title': 'WAeUP Department', |
---|
| 94 | 'description': '', |
---|
| 95 | 'content_icon': '', |
---|
| 96 | 'content_meta_type': 'Department', |
---|
| 97 | 'factory': 'addDepartment', |
---|
| 98 | 'immediate_view': 'cpsdocument_view', |
---|
| 99 | 'global_allow': True, |
---|
| 100 | 'filter_content_types': True, |
---|
| 101 | 'allowed_content_types': ('Course',), |
---|
| 102 | 'allow_discussion': False, |
---|
| 103 | } |
---|
| 104 | ###) |
---|
| 105 | |
---|
| 106 | class Department(CPSDocument): ###( |
---|
| 107 | """ |
---|
| 108 | WAeUP Department containing the courses and students |
---|
| 109 | """ |
---|
| 110 | meta_type = 'Department' |
---|
| 111 | portal_type = meta_type |
---|
| 112 | security = ClassSecurityInfo() |
---|
| 113 | |
---|
| 114 | InitializeClass(Department) |
---|
| 115 | |
---|
| 116 | def addDepartment(container, id, REQUEST=None, **kw): |
---|
| 117 | """Add a Department.""" |
---|
| 118 | ob = Department(id, **kw) |
---|
| 119 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 120 | ###) |
---|
| 121 | |
---|
| 122 | course_fti = { ###( |
---|
| 123 | 'title': 'WAeUP Course', |
---|
| 124 | 'description': '', |
---|
| 125 | 'content_icon': '', |
---|
| 126 | 'content_meta_type': 'Course', |
---|
| 127 | 'factory': 'addCourse', |
---|
| 128 | 'immediate_view': 'cpsdocument_view', |
---|
| 129 | 'global_allow': True, |
---|
| 130 | 'filter_content_types': True, |
---|
| 131 | 'allowed_content_types': (), |
---|
| 132 | 'allow_discussion': False, |
---|
| 133 | } |
---|
| 134 | ###) |
---|
| 135 | |
---|
| 136 | class Course(CPSDocument): ###( |
---|
| 137 | """ |
---|
| 138 | WAeUP Course |
---|
| 139 | """ |
---|
| 140 | meta_type = 'Course' |
---|
| 141 | portal_type = meta_type |
---|
| 142 | security = ClassSecurityInfo() |
---|
[152] | 143 | |
---|
| 144 | security.declareProtected(View,"Title") |
---|
| 145 | def Title(self): |
---|
| 146 | """compose title""" |
---|
| 147 | content = self.getContent() |
---|
| 148 | heading = getattr(content,'heading',None) |
---|
| 149 | if heading is None: |
---|
| 150 | return self.title |
---|
| 151 | return heading |
---|
[68] | 152 | |
---|
| 153 | InitializeClass(Course) |
---|
| 154 | |
---|
| 155 | def addCourse(container, id, REQUEST=None, **kw): |
---|
| 156 | """Add a Course.""" |
---|
| 157 | ob = Course(id, **kw) |
---|
| 158 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 159 | ###) |
---|
[139] | 160 | |
---|
| 161 | course_ticket_fti = { ###( |
---|
| 162 | 'title': 'WAeUP CourseTicket', |
---|
| 163 | 'description': '', |
---|
| 164 | 'content_icon': '', |
---|
| 165 | 'content_meta_type': 'CourseTicket', |
---|
| 166 | 'factory': 'addCourseTicket', |
---|
| 167 | 'immediate_view': 'cpsdocument_view', |
---|
| 168 | 'global_allow': True, |
---|
| 169 | 'filter_content_types': True, |
---|
| 170 | 'allowed_content_types': (), |
---|
| 171 | 'allow_discussion': False, |
---|
| 172 | } |
---|
| 173 | ###) |
---|
| 174 | |
---|
| 175 | class CourseTicket(CPSDocument): ###( |
---|
| 176 | """ |
---|
| 177 | WAeUP CourseTicket |
---|
| 178 | """ |
---|
| 179 | meta_type = 'CourseTicket' |
---|
| 180 | portal_type = meta_type |
---|
| 181 | security = ClassSecurityInfo() |
---|
| 182 | |
---|
| 183 | InitializeClass(CourseTicket) |
---|
| 184 | |
---|
| 185 | def addCourseTicket(container, id, REQUEST=None, **kw): |
---|
| 186 | """Add a CourseTicket.""" |
---|
| 187 | ob = CourseTicket(id, **kw) |
---|
| 188 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 189 | ###) |
---|