Skip to content

Commit

Permalink
add uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed May 22, 2024
1 parent 6120678 commit 379195d
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 36 deletions.
77 changes: 43 additions & 34 deletions plone/app/discussion/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,59 @@
i18n_domain="plone"
>

<five:registerPackage package="." />
<five:registerPackage package="." />

<include package="plone.indexer" />
<include package="plone.app.registry" />
<include package="plone.resource" />
<include package="plone.uuid" />
<include package="plone.app.uuid" />
<include package="plone.indexer" />
<include package="plone.app.registry" />
<include package="plone.resource" />
<include package="plone.uuid" />
<include package="plone.app.uuid" />

<include file="behavior.zcml" />
<include file="contentrules.zcml" />
<include file="permissions.zcml" />
<include file="notifications.zcml" />
<include file="subscribers.zcml" />
<include file="upgrades.zcml" />
<include file="behavior.zcml" />
<include file="contentrules.zcml" />
<include file="permissions.zcml" />
<include file="notifications.zcml" />
<include file="subscribers.zcml" />
<include file="upgrades.zcml" />

<!-- load captcha before browser -->
<configure zcml:condition="installed plone.formwidget.captcha">
<include package="plone.formwidget.captcha" />
<include package="plone.formwidget.captcha" />
</configure>
<configure zcml:condition="installed plone.formwidget.recaptcha">
<include package="plone.formwidget.recaptcha" />
<include package="plone.formwidget.recaptcha" />
</configure>
<configure zcml:condition="installed plone.formwidget.hcaptcha">
<include package="plone.formwidget.hcaptcha" />
<include package="plone.formwidget.hcaptcha" />
</configure>
<configure zcml:condition="installed collective.z3cform.norobots">
<include package="collective.z3cform.norobots" />
<include package="collective.z3cform.norobots" />
</configure>

<include package=".browser" />
<include package=".browser" />

<!-- Register the installation GenericSetup extension profile -->
<genericsetup:registerProfile
name="default"
title="Discussion Support"
description="Commenting infrastructure for Plone"
provides="Products.GenericSetup.interfaces.EXTENSION"
for="plone.base.interfaces.IPloneSiteRoot"
directory="profiles/default"
post_handler=".setuphandlers.post_install"
/>
<!-- For upgrade steps see upgrades.zcml. -->

<!-- Comments -->
<genericsetup:registerProfile
name="default"
title="Discussion Support"
description="Commenting infrastructure for Plone"
provides="Products.GenericSetup.interfaces.EXTENSION"
for="plone.base.interfaces.IPloneSiteRoot"
directory="profiles/default"
post_handler=".setuphandlers.post_install"
/>
<genericsetup:registerProfile
name="uninstall"
title="Uninstall Discussion Support"
description="Uninstall Commenting infrastructure for Plone"
provides="Products.GenericSetup.interfaces.EXTENSION"
for="plone.base.interfaces.IPloneSiteRoot"
directory="profiles/uninstall"
post_handler=".setuphandlers.post_uninstall"
/>
<!-- For upgrade steps see upgrades.zcml. -->

<!-- Comments -->

<class class=".comment.Comment">
<require
Expand All @@ -72,7 +81,7 @@
component=".comment.CommentFactory"
/>

<!-- Conversations -->
<!-- Conversations -->

<class class=".conversation.Conversation">
<require
Expand All @@ -86,21 +95,21 @@
<adapter factory=".conversation.ConversationReplies" />
<adapter factory=".conversation.CommentReplies" />

<!-- Captcha Vocabulary -->
<!-- Captcha Vocabulary -->
<utility
provides="zope.schema.interfaces.IVocabularyFactory"
name="plone.app.discussion.vocabularies.CaptchaVocabulary"
component=".vocabularies.captcha_vocabulary"
/>

<!-- Text Transform Vocabulary -->
<!-- Text Transform Vocabulary -->
<utility
provides="zope.schema.interfaces.IVocabularyFactory"
name="plone.app.discussion.vocabularies.TextTransformVocabulary"
component=".vocabularies.text_transform_vocabulary"
/>

<!-- Conversation indexes -->
<!-- Conversation indexes -->
<adapter
factory=".catalog.total_comments"
name="total_comments"
Expand All @@ -118,7 +127,7 @@
name="in_response_to"
/>

<!-- Comment indexes -->
<!-- Comment indexes -->
<adapter
factory=".catalog.UID"
name="UID"
Expand Down
13 changes: 13 additions & 0 deletions plone/app/discussion/profiles/uninstall/actions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
name="portal_actions"
>
<object meta_type="CMF Action Category"
name="user"
>
<object meta_type="CMF Action"
name="review-comments"
remove="true"
/>
</object>
</object>
6 changes: 6 additions & 0 deletions plone/app/discussion/profiles/uninstall/browserlayer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<layers>
<layer name="plone.app.discussion"
remove="true"
/>
</layers>
18 changes: 18 additions & 0 deletions plone/app/discussion/profiles/uninstall/catalog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<object name="portal_catalog">

<index meta_type="FieldIndex"
name="total_comments"
remove="true"
/>
<index meta_type="KeywordIndex"
name="commentators"
remove="true"
/>
<column value="total_comments" remove="true" />
<column value="last_comment_date" remove="true" />
<column value="commentators" remove="true" />
<column value="in_response_to" remove="true" />
<column value="author_name" remove="true" />

</object>
14 changes: 14 additions & 0 deletions plone/app/discussion/profiles/uninstall/controlpanel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
name="portal_controlpanel"
purge="False"
i18n:domain="plone"
>

<configlet action_id="discussion"
appId="plone.app.discussion"
category="plone-general"
remove="true"
/>

</object>
6 changes: 6 additions & 0 deletions plone/app/discussion/profiles/uninstall/registry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<registry>
<records interface="plone.app.discussion.interfaces.IDiscussionSettings"
remove="true"
/>
</registry>
24 changes: 22 additions & 2 deletions plone/app/discussion/setuphandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,35 @@
"Link",
]

BEHAVIOR = "plone.allowdiscussion"


def add_discussion_behavior_to_default_types(context):
"""Add the discussion behavior to all default types, if they exist."""
types_tool = getToolByName(context, "portal_types")
for type_name in DEFAULT_TYPES:
if type_name in types_tool.objectIds():
types_tool[type_name].behaviors += ("plone.allowdiscussion",)
if type_name in types_tool.objectIds() and BEHAVIOR not in types_tool[type_name].behaviors:
types_tool[type_name].behaviors += (BEHAVIOR,)


def remove_discussion_behavior_to_default_types(context):
"""Remove the discussion behavior from all default types, if they exist."""
types_tool = getToolByName(context, "portal_types")
for type_name in types_tool.objectIds():
fti = types_tool[type_name]
if getattr(fti, "behaviors", None) is None:
continue
if BEHAVIOR in fti.behaviors:
behaviors = list(fti.behaviors)
behaviors.remove(BEHAVIOR)
fti.behaviors = tuple(behaviors)


def post_install(context):
"""Post install script"""
add_discussion_behavior_to_default_types(context)


def post_uninstall(context):
"""Post uninstall script"""
remove_discussion_behavior_to_default_types(context)

0 comments on commit 379195d

Please sign in to comment.