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