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