[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',"\ |
---|
| 31 | + "'StudentFolder', 'Student', 'Jamb')" |
---|
| 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: |
---|
| 44 | ptypes = "('StudentFolder', 'Student', 'Jamb')" |
---|
| 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 | } |
---|
| 54 | self.deleteActions({'portal_discussion': ['activate_comments',]}) |
---|
| 55 | self.verifyAction('portal_subscriptions', **action) |
---|
| 56 | |
---|
| 57 | ########################################## |
---|
[20] | 58 | # actions |
---|
[19] | 59 | ########################################## |
---|
[20] | 60 | actions = ( { 'tool' : 'portal_actions', |
---|
| 61 | 'id' : 'checkadmission', |
---|
| 62 | 'name' : 'Check Admission', |
---|
[28] | 63 | 'action' : 'string:${object/absolute_url}/check_admission_form', |
---|
[20] | 64 | 'permission': (View, ), |
---|
[23] | 65 | 'condition' : 'not:member', |
---|
| 66 | 'category' : 'student', |
---|
[20] | 67 | 'visible' : 1, |
---|
| 68 | }, |
---|
| 69 | { 'tool' : 'portal_actions', |
---|
| 70 | 'id' : 'new_student', |
---|
| 71 | 'name' : 'Add Student', |
---|
[28] | 72 | 'action' : 'string:${object/absolute_url}/create_student', |
---|
[26] | 73 | 'permission': (View), |
---|
[28] | 74 | 'condition' : 'python: member and here.portal_type == "StudentFolder"', |
---|
[20] | 75 | 'category' : 'student', |
---|
| 76 | 'visible' : 1, |
---|
| 77 | }, |
---|
| 78 | { 'tool' : 'portal_actions', |
---|
| 79 | 'id' : 'edit_student', |
---|
| 80 | 'name' : 'Edit Student', |
---|
| 81 | 'action' : 'cpsdocument_edit_form', |
---|
[26] | 82 | 'permission': ( ), |
---|
[20] | 83 | 'condition' : 'python: here.portal_type == "Student"', |
---|
| 84 | 'category' : 'student', |
---|
| 85 | 'visible' : 1, |
---|
| 86 | }, |
---|
| 87 | { 'tool' : 'portal_actions', |
---|
[28] | 88 | 'id' : 'add_jamb', |
---|
[20] | 89 | 'name' : 'Add Jamb Data', |
---|
[28] | 90 | 'action' : 'string:${object/absolute_url}/create_jamb', |
---|
| 91 | 'permission': (), |
---|
| 92 | 'condition' : 'python:here.portal_type != "Jamb" and len(object.contentItems()) == 0', |
---|
| 93 | 'category' : 'student', |
---|
| 94 | 'visible' : 1, |
---|
| 95 | }, |
---|
| 96 | { 'tool' : 'portal_actions', |
---|
| 97 | 'id' : 'edit_jamb', |
---|
| 98 | 'name' : 'Edit Jamb Data', |
---|
| 99 | 'action' : 'cpsdocument_edit_form', |
---|
[26] | 100 | 'permission': ( ), |
---|
[28] | 101 | 'condition' : 'python: here.portal_type == "Jamb"', |
---|
[20] | 102 | 'category' : 'student', |
---|
| 103 | 'visible' : 1, |
---|
| 104 | }, |
---|
| 105 | ) |
---|
| 106 | self.verifyActions(actions) |
---|
| 107 | ########################################## |
---|
| 108 | # skins |
---|
| 109 | ########################################## |
---|
[19] | 110 | self.log("Verifying %(product_name)s skinss" % vars()) |
---|
| 111 | wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default', |
---|
| 112 | 'waeup_student' : 'Products/WAeUP/skins/waeup_student', |
---|
| 113 | } |
---|
| 114 | self.verifySkins(wskins) |
---|
| 115 | self.resetSkinCache() |
---|
| 116 | ########################################## |
---|
[20] | 117 | # portal types |
---|
[19] | 118 | ########################################## |
---|
| 119 | dtypes = portal.getWAeUPTypes() |
---|
| 120 | self.verifyFlexibleTypes(dtypes) |
---|
| 121 | self.allowContentTypes('StudentFolder', ('Workspace','Section',)) |
---|
| 122 | #self.allowContentTypes('Student', ('Workspace', 'Section')) |
---|
| 123 | ptypes = { |
---|
| 124 | 'StudentFolder' : { |
---|
| 125 | 'allowed_content_types': ('Student',), |
---|
| 126 | 'typeinfo_name': 'WAeUP: StudentFolder', |
---|
| 127 | 'add_meta_type': 'Factory-based Type Information', |
---|
| 128 | }, |
---|
| 129 | 'Student' : { |
---|
| 130 | 'allowed_content_types': ('Jamb',), |
---|
| 131 | 'typeinfo_name': 'WAeUP: Student', |
---|
| 132 | 'add_meta_type': 'Factory-based Type Information', |
---|
| 133 | }, |
---|
| 134 | } |
---|
| 135 | self.verifyContentTypes(ptypes) |
---|
| 136 | ########################################## |
---|
[20] | 137 | # Schemas |
---|
[19] | 138 | ########################################## |
---|
| 139 | self.log("Verifying %(product_name)s schemas" % vars()) |
---|
| 140 | self.verifySchemas(portal.getWAeUPSchemas()) |
---|
| 141 | ########################################## |
---|
[20] | 142 | # widgets |
---|
[19] | 143 | ########################################## |
---|
[20] | 144 | self.log("Verifying %(product_name)s widgets" % vars()) |
---|
| 145 | self.verifyWidgets(portal.getWAeUPWidgets()) |
---|
| 146 | ########################################## |
---|
| 147 | # layouts |
---|
| 148 | ########################################## |
---|
[19] | 149 | self.log("Verifying %(product_name)s layouts" % vars()) |
---|
| 150 | self.verifyLayouts(portal.getWAeUPLayouts()) |
---|
| 151 | ########################################## |
---|
[20] | 152 | # Vocabularies |
---|
[19] | 153 | ########################################## |
---|
| 154 | self.log("Verifying %(product_name)s vocabularies" % vars()) |
---|
| 155 | self.verifyVocabularies(portal.getWAeUPVocabularies()) |
---|
| 156 | |
---|
| 157 | self.installCustomWorkflows() |
---|
| 158 | self.verifyWorkflowAssociation() |
---|
| 159 | |
---|
| 160 | self.log("End of specific %(product_name)s install" % vars()) |
---|
| 161 | self.finalize() |
---|
| 162 | |
---|
| 163 | |
---|
| 164 | def installCustomWorkflows(self): |
---|
| 165 | """Installs custom workflows |
---|
| 166 | """ |
---|
| 167 | from Products.WAeUP.Workflows.WAeUPWorkflow import \ |
---|
| 168 | waeupWorkflowsInstall |
---|
| 169 | |
---|
| 170 | waeupWorkflowsInstall(self.context) |
---|
| 171 | |
---|
| 172 | |
---|
| 173 | def verifyWorkflowAssociation(self): |
---|
| 174 | """Verify workflow association |
---|
| 175 | """ |
---|
| 176 | ws_chains = { |
---|
| 177 | 'Student': 'waeup_workspace_wf', |
---|
| 178 | 'Jamb': 'waeup_workspace_wf', |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | se_chains = { 'StudentFolder': 'waeup_section_wf', |
---|
| 182 | 'Student': 'waeup_section_wf', |
---|
| 183 | 'Jamb': 'waeup_section_wf', |
---|
[25] | 184 | 'ScratchCard': 'waeup_section_wf', |
---|
[19] | 185 | } |
---|
| 186 | |
---|
| 187 | self.verifyLocalWorkflowChains(self.portal['workspaces'], |
---|
| 188 | ws_chains, |
---|
| 189 | destructive=1) |
---|
| 190 | self.verifyLocalWorkflowChains(self.portal['sections'], |
---|
| 191 | se_chains, |
---|
| 192 | destructive=1) |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | def install(self): |
---|
| 196 | installer = WAeUPInstaller(self) |
---|
| 197 | installer.install(self) |
---|
| 198 | return installer.logResult() |
---|