1 | from Products.CMFCore.utils import getToolByName |
---|
2 | |
---|
3 | def install(context): |
---|
4 | |
---|
5 | # Ordinarily, GenericSetup handlers check for the existence of XML files. |
---|
6 | # Here, we are not parsing an XML file, but we use this text file as a |
---|
7 | # flag to check that we actually meant for this import step to be run. |
---|
8 | # The file is found in profiles/default. |
---|
9 | |
---|
10 | if context.readDataFile('quintagroup.plonecomments_install.txt') is None: |
---|
11 | return |
---|
12 | |
---|
13 | # Add additional setup code here |
---|
14 | |
---|
15 | portal = context.getSite() |
---|
16 | logger = context.getLogger('qPloneComments') |
---|
17 | |
---|
18 | # Add 'DiscussionManagers' group |
---|
19 | gtool = getToolByName(portal, 'portal_groups') |
---|
20 | existing = gtool.listGroupIds() |
---|
21 | if not 'DiscussionManager' in existing: |
---|
22 | gtool.addGroup('DiscussionManager', roles=['DiscussionManager']) |
---|
23 | logger.info('Added DiscussionManager group to portal_groups with DiscussionManager role.') |
---|
24 | |
---|
25 | # Remove workflow-chain for Discussion Item |
---|
26 | wf_tool = getToolByName(portal, 'portal_workflow') |
---|
27 | wf_tool.setChainForPortalTypes(('Discussion Item',), []) |
---|
28 | logger.info('Removed workflow chain for Discussion Item type.') |
---|
29 | |
---|
30 | def uninstall(context): |
---|
31 | |
---|
32 | # Ordinarily, GenericSetup handlers check for the existence of XML files. |
---|
33 | # Here, we are not parsing an XML file, but we use this text file as a |
---|
34 | # flag to check that we actually meant for this import step to be run. |
---|
35 | # The file is found in profiles/default. |
---|
36 | |
---|
37 | if context.readDataFile('quintagroup.plonecomments_uninstall.txt') is None: |
---|
38 | return |
---|
39 | |
---|
40 | # Add additional setup code here |
---|
41 | portal_conf=getToolByName(context.getSite(),'portal_controlpanel') |
---|
42 | portal_conf.unregisterConfiglet('prefs_comments_setup_form') |
---|