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