[60] | 1 | #-*- mode: python; mode: fold -*- |
---|
[19] | 2 | from Products.CPSInstaller.CPSInstaller import CPSInstaller |
---|
[20] | 3 | from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent |
---|
[19] | 4 | try: |
---|
[23] | 5 | from Products.CPSSubscriptions.permissions import CanNotifyContent |
---|
[19] | 6 | CPSSubscriptions = True |
---|
| 7 | except ImportError: |
---|
| 8 | CPSSubscriptions = False |
---|
| 9 | try: |
---|
[23] | 10 | from Products.CPSForum.CPSForumPermissions import ForumManageComments |
---|
[19] | 11 | CPSForum = True |
---|
| 12 | except ImportError: |
---|
| 13 | CPSForum = False |
---|
| 14 | |
---|
[60] | 15 | from Products.WAeUP.Students import addStudentsFolder |
---|
| 16 | |
---|
[19] | 17 | class WAeUPInstaller(CPSInstaller): |
---|
| 18 | """ |
---|
| 19 | WAeUP Installer |
---|
| 20 | """ |
---|
| 21 | product_name = "WAeUP" |
---|
| 22 | |
---|
| 23 | def install(self,portal): |
---|
| 24 | "install" |
---|
| 25 | |
---|
| 26 | product_name = self.product_name |
---|
| 27 | self.log("Starting %(product_name)s install" % vars() ) |
---|
| 28 | |
---|
| 29 | ########################################## |
---|
[60] | 30 | # Actions ###( |
---|
[19] | 31 | ########################################## |
---|
| 32 | if CPSSubscriptions: |
---|
| 33 | ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\ |
---|
[45] | 34 | + "'University', 'StudentsFolder', 'Student', 'Jamb')" |
---|
[19] | 35 | condition = "object.portal_type not in %s" % ptypes |
---|
| 36 | |
---|
| 37 | action = {'id' : 'notify_content', |
---|
| 38 | 'name' : 'action_notify_content', |
---|
| 39 | 'action' : 'string:${object_url}/content_notify_email_form', |
---|
| 40 | 'condition' : 'python:%s' % condition, |
---|
| 41 | 'permission' : (CanNotifyContent,), |
---|
| 42 | 'category' : 'object', |
---|
| 43 | } |
---|
| 44 | self.deleteActions({'portal_subscriptions': ['notify_content',]}) |
---|
| 45 | self.verifyAction('portal_subscriptions', **action) |
---|
| 46 | if CPSForum: |
---|
[45] | 47 | ptypes = "('University', 'StudentsFolder', 'Student', 'Jamb')" |
---|
[19] | 48 | condition = "object.portal_type not in %s" % ptypes |
---|
| 49 | |
---|
| 50 | action = {'id' : 'activate_comments', |
---|
| 51 | 'name': 'action_activate_comments', |
---|
| 52 | 'action': 'string:${object/absolute_url}/set_comment_mode?mode=1', |
---|
| 53 | 'condition' : 'python:%s' % condition, |
---|
| 54 | 'permission': (ForumManageComments,), |
---|
| 55 | 'category' : 'object', |
---|
| 56 | } |
---|
[57] | 57 | self.deleteActions({'portal_subscriptions': ['activate_comments',]}) |
---|
[19] | 58 | self.verifyAction('portal_subscriptions', **action) |
---|
[57] | 59 | # now portal_discussion |
---|
| 60 | self.deleteActions({'portal_discussion': ['comment', |
---|
| 61 | 'activate_comments', |
---|
| 62 | 'deactivate_comments', |
---|
| 63 | 'manage_comments']}) |
---|
| 64 | action = {'id' : 'comment', |
---|
| 65 | 'name': 'action_comment', |
---|
| 66 | 'action': "string:${object/absolute_url}/post_comment", |
---|
| 67 | 'condition' : "python:getattr(object.getContent(), 'allow_discussion' , None) and object.hasCommentAction()", |
---|
| 68 | 'permission': (View,), |
---|
| 69 | 'category' : 'object', |
---|
| 70 | } |
---|
| 71 | self.verifyAction('portal_discussion', **action) |
---|
| 72 | action = {'id' : 'activate_comments', |
---|
| 73 | 'name': 'action_activate_comments', |
---|
| 74 | 'action': "string:${object/absolute_url}/set_comment_mode?mode=1", |
---|
| 75 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 76 | 'permission': (ForumManageComments,), |
---|
| 77 | 'category' : 'object', |
---|
| 78 | } |
---|
| 79 | self.verifyAction('portal_discussion', **action) |
---|
| 80 | action = {'id' : 'deactivate_comments', |
---|
| 81 | 'name': 'action_deactivate_comments', |
---|
| 82 | 'action': "string:${object/absolute_url}/set_comment_mode?mode=0", |
---|
| 83 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 84 | 'permission': (ForumManageComments,), |
---|
| 85 | 'category' : 'object', |
---|
| 86 | } |
---|
| 87 | self.verifyAction('portal_discussion', **action) |
---|
| 88 | action = {'id' : 'manage_comments', |
---|
| 89 | 'name': 'action_manage_comments', |
---|
| 90 | 'action': "string:${object/absolute_url}/manage_comment", |
---|
| 91 | 'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1", |
---|
| 92 | 'permission': (ForumManageComments,), |
---|
| 93 | 'category' : 'object', |
---|
| 94 | } |
---|
| 95 | self.verifyAction('portal_discussion', **action) |
---|
[19] | 96 | |
---|
| 97 | ########################################## |
---|
[20] | 98 | # actions |
---|
[19] | 99 | ########################################## |
---|
[20] | 100 | actions = ( { 'tool' : 'portal_actions', |
---|
| 101 | 'id' : 'checkadmission', |
---|
| 102 | 'name' : 'Check Admission', |
---|
[47] | 103 | 'action' : 'string:${object/absolute_url}/check_admission', |
---|
[20] | 104 | 'permission': (View, ), |
---|
[49] | 105 | 'condition' : 'python: not member', |
---|
[23] | 106 | 'category' : 'student', |
---|
[20] | 107 | 'visible' : 1, |
---|
| 108 | }, |
---|
[49] | 109 | ## { 'tool' : 'portal_actions', |
---|
| 110 | ## 'id' : 'new_student', |
---|
| 111 | ## 'name' : 'Add Student', |
---|
| 112 | ## 'action' : 'string:${object/absolute_url}/create_student_form', |
---|
| 113 | ## 'permission': (View), |
---|
| 114 | ## 'condition' : 'python: 0 and member and here.portal_type == "StudentsFolder"', |
---|
| 115 | ## 'category' : 'student', |
---|
| 116 | ## 'visible' : 1, |
---|
| 117 | ## }, |
---|
[20] | 118 | { 'tool' : 'portal_actions', |
---|
| 119 | 'id' : 'edit_student', |
---|
| 120 | 'name' : 'Edit Student', |
---|
| 121 | 'action' : 'cpsdocument_edit_form', |
---|
[26] | 122 | 'permission': ( ), |
---|
[49] | 123 | 'condition' : 'python: 0 and member and here.portal_type == "Student"', |
---|
[20] | 124 | 'category' : 'student', |
---|
| 125 | 'visible' : 1, |
---|
| 126 | }, |
---|
| 127 | { 'tool' : 'portal_actions', |
---|
[28] | 128 | 'id' : 'add_jamb', |
---|
[49] | 129 | 'name' : 'Add Student JAMB', |
---|
| 130 | 'action' : 'string:${object/absolute_url}/create_jamb', |
---|
[28] | 131 | 'permission': (), |
---|
[49] | 132 | 'condition' : 'python: member and here.portal_type in ("StudentsFolder",) and "StudentManager" in member.getGroups()', |
---|
[28] | 133 | 'category' : 'student', |
---|
| 134 | 'visible' : 1, |
---|
| 135 | }, |
---|
| 136 | { 'tool' : 'portal_actions', |
---|
[47] | 137 | 'id' : 'add_personal', |
---|
| 138 | 'name' : 'Add personal Data', |
---|
| 139 | 'action' : 'string:${object/absolute_url}/create_personal_form', |
---|
| 140 | 'permission': (), |
---|
[49] | 141 | 'condition' : 'python: 0 and member and not here.portal_type in ("Jamb","StudentsFolder") and not "StudentManager" in member.getGroups()', |
---|
[47] | 142 | 'category' : 'student', |
---|
| 143 | 'visible' : 1, |
---|
| 144 | }, |
---|
| 145 | { 'tool' : 'portal_actions', |
---|
[28] | 146 | 'id' : 'edit_jamb', |
---|
| 147 | 'name' : 'Edit Jamb Data', |
---|
| 148 | 'action' : 'cpsdocument_edit_form', |
---|
[26] | 149 | 'permission': ( ), |
---|
[49] | 150 | 'condition' : 'python: member and here.portal_type in ("Student",) and "StudentManager" in member.getGroups()', |
---|
[20] | 151 | 'category' : 'student', |
---|
| 152 | 'visible' : 1, |
---|
| 153 | }, |
---|
| 154 | ) |
---|
| 155 | self.verifyActions(actions) |
---|
| 156 | ########################################## |
---|
[60] | 157 | ###) |
---|
| 158 | |
---|
| 159 | # skins |
---|
[20] | 160 | ########################################## |
---|
[19] | 161 | self.log("Verifying %(product_name)s skinss" % vars()) |
---|
| 162 | wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', |
---|
| 163 | 'waeup_student' : 'Products/WAeUP/skins/waeup_student', |
---|
| 164 | } |
---|
| 165 | self.verifySkins(wskins) |
---|
| 166 | self.resetSkinCache() |
---|
| 167 | ########################################## |
---|
[20] | 168 | # portal types |
---|
[19] | 169 | ########################################## |
---|
| 170 | dtypes = portal.getWAeUPTypes() |
---|
| 171 | self.verifyFlexibleTypes(dtypes) |
---|
[45] | 172 | self.allowContentTypes('University', ('Workspace','Section',)) |
---|
[19] | 173 | ########################################## |
---|
[20] | 174 | # Schemas |
---|
[19] | 175 | ########################################## |
---|
| 176 | self.log("Verifying %(product_name)s schemas" % vars()) |
---|
| 177 | self.verifySchemas(portal.getWAeUPSchemas()) |
---|
| 178 | ########################################## |
---|
[20] | 179 | # widgets |
---|
[19] | 180 | ########################################## |
---|
[20] | 181 | self.log("Verifying %(product_name)s widgets" % vars()) |
---|
| 182 | self.verifyWidgets(portal.getWAeUPWidgets()) |
---|
| 183 | ########################################## |
---|
| 184 | # layouts |
---|
| 185 | ########################################## |
---|
[19] | 186 | self.log("Verifying %(product_name)s layouts" % vars()) |
---|
| 187 | self.verifyLayouts(portal.getWAeUPLayouts()) |
---|
| 188 | ########################################## |
---|
[20] | 189 | # Vocabularies |
---|
[19] | 190 | ########################################## |
---|
| 191 | self.log("Verifying %(product_name)s vocabularies" % vars()) |
---|
| 192 | self.verifyVocabularies(portal.getWAeUPVocabularies()) |
---|
[60] | 193 | ########################################## |
---|
| 194 | # Groups |
---|
| 195 | ########################################## |
---|
| 196 | |
---|
[19] | 197 | self.installCustomWorkflows() |
---|
| 198 | self.verifyWorkflowAssociation() |
---|
| 199 | |
---|
| 200 | self.log("End of specific %(product_name)s install" % vars()) |
---|
| 201 | self.finalize() |
---|
| 202 | |
---|
| 203 | |
---|
| 204 | def installCustomWorkflows(self): |
---|
| 205 | """Installs custom workflows |
---|
| 206 | """ |
---|
| 207 | from Products.WAeUP.Workflows.WAeUPWorkflow import \ |
---|
| 208 | waeupWorkflowsInstall |
---|
| 209 | |
---|
| 210 | waeupWorkflowsInstall(self.context) |
---|
| 211 | |
---|
| 212 | |
---|
| 213 | def verifyWorkflowAssociation(self): |
---|
| 214 | """Verify workflow association |
---|
| 215 | """ |
---|
| 216 | ws_chains = { |
---|
| 217 | 'Student': 'waeup_workspace_wf', |
---|
| 218 | 'Jamb': 'waeup_workspace_wf', |
---|
| 219 | } |
---|
| 220 | |
---|
[45] | 221 | se_chains = { 'University': 'waeup_section_wf', |
---|
| 222 | 'StudentsFolder': 'waeup_section_wf', |
---|
[19] | 223 | 'Student': 'waeup_section_wf', |
---|
[47] | 224 | 'StudentPersonal': 'waeup_section_wf', |
---|
[19] | 225 | 'Jamb': 'waeup_section_wf', |
---|
[25] | 226 | 'ScratchCard': 'waeup_section_wf', |
---|
[19] | 227 | } |
---|
| 228 | |
---|
| 229 | self.verifyLocalWorkflowChains(self.portal['workspaces'], |
---|
| 230 | ws_chains, |
---|
| 231 | destructive=1) |
---|
| 232 | self.verifyLocalWorkflowChains(self.portal['sections'], |
---|
| 233 | se_chains, |
---|
| 234 | destructive=1) |
---|
| 235 | |
---|
| 236 | |
---|
| 237 | def install(self): |
---|
| 238 | installer = WAeUPInstaller(self) |
---|
| 239 | installer.install(self) |
---|
[60] | 240 | dirtool = getattr(self,'portal_directories') |
---|
| 241 | groups = dirtool.groups |
---|
| 242 | for newEntry in ('Students','StudentManager'): |
---|
| 243 | if newEntry not in groups.listEntryIds(): |
---|
| 244 | groups.createEntry({'group': newEntry, |
---|
| 245 | 'members': []}) |
---|
| 246 | groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',)) |
---|
| 247 | #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
| 248 | sections = getattr(self,'sections') |
---|
| 249 | waeup = getattr(sections,'waeup',None) |
---|
| 250 | if not waeup: |
---|
| 251 | sections.content_create(type_name='University',title='waeup') |
---|
| 252 | sections.waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
| 253 | member_role='SectionReviewer', |
---|
| 254 | ) |
---|
| 255 | sections.waeup.content_create(type_name='StudentsFolder',title='students') |
---|
| 256 | sections.waeup.folder_localrole_add(member_ids=('group:Students',), |
---|
| 257 | member_role='SectionReviewer', |
---|
| 258 | ) |
---|
| 259 | sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',), |
---|
| 260 | member_role='SectionManager', |
---|
| 261 | ) |
---|
| 262 | sections.waeup.students.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',)) |
---|
| 263 | sections.waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) |
---|
[19] | 264 | return installer.logResult() |
---|