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