Skip to content

Commit

Permalink
add uninstall profile
Browse files Browse the repository at this point in the history
  • Loading branch information
petschki committed Apr 17, 2024
1 parent 7993cac commit 6a99d0b
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/bda/plone/shop/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ class IShopArticleSettings(model.Schema):
),
description=_("help_default_quantity_unit", default="default measurement"),
vocabulary="bda.plone.shop.vocabularies.QuantityUnitVocabulary",
default="quantity",
)

default_item_net = schema.Decimal(
Expand Down
12 changes: 10 additions & 2 deletions src/bda/plone/shop/profiles.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@
description="bda.plone.shop"
provides="Products.GenericSetup.interfaces.EXTENSION" />

<!-- Hide profiles/products from Quick Installer -->
<genericsetup:registerProfile
name="uninstall"
title="bda.plone.shop (uninstall)"
description="Uninstalls the bda.plone.shop add-on."
provides="Products.GenericSetup.interfaces.EXTENSION"
directory="profiles/uninstall"
post_handler=".setuphandlers.uninstall"
/>

<!-- Hide profiles/products from addon manager -->
<utility factory=".setuphandlers.HiddenProfiles" name="bda.plone.shop" />
<utility factory=".setuphandlers.HiddenProducts" name="bda.plone.shop" />

</configure>
34 changes: 34 additions & 0 deletions src/bda/plone/shop/profiles/uninstall/actions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<object name="portal_actions"
meta_type="Plone Actions Tool"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">

<!-- remove entries -->
<object name="object_buttons" meta_type="CMF Action Category">
<object name="enableBuyable" meta_type="CMF Action" remove="true" />
<object name="disableBuyable" meta_type="CMF Action" remove="true" />
<object name="enableVendor" meta_type="CMF Action" remove="true" />
<object name="disableVendor" meta_type="CMF Action" remove="true" />
</object>

<object name="user" meta_type="CMF Action Category">

<!-- reset permissions -->
<object name="dashboard" meta_type="CMF Action" i18n:domain="plone">
<property name="permissions">
<element value="Portlets: Manage own portlets" />
</property>
</object>

<object name="preferences" meta_type="CMF Action" i18n:domain="plone">
<property name="permissions">
<element value="View" />
</property>
</object>

<!-- remove -->
<object name="information" meta_type="CMF Action" remove="true" />

</object>

</object>
7 changes: 7 additions & 0 deletions src/bda/plone/shop/profiles/uninstall/browserlayer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<layers>
<layer
name="bda.plone.shop"
interface="bda.plone.shop.interfaces.IShopExtensionLayer"
remove="true" />
</layers>
10 changes: 10 additions & 0 deletions src/bda/plone/shop/profiles/uninstall/catalog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<object name="portal_catalog" meta_type="Plone Catalog Tool">
<index name="item_buyable" meta_type="BooleanIndex" remove="true">
<indexed_attr value="item_buyable" />
</index>
<column value="item_buyable" remove="true" />
<column value="item_net" remove="true" />
<column value="item_buyable_start" remove="true" />
<column value="item_buyable_end" remove="true" />
</object>
21 changes: 21 additions & 0 deletions src/bda/plone/shop/profiles/uninstall/controlpanel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<object
name="portal_controlpanel"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="bda.plone.shop"
purge="False">

<configlet
title="Shop settings"
action_id="bdashop"
appId="bda.plone.shop"
category="Products"
url_expr="string:${portal_url}/@@shop_controlpanel"
icon_expr="string:shop"
visible="True"
i18n:attributes="title"
remove="true">
<permission>Manage portal</permission>
</configlet>

</object>
28 changes: 28 additions & 0 deletions src/bda/plone/shop/profiles/uninstall/memberdata_properties.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<object name="portal_memberdata" meta_type="Plone Memberdata Tool">

<!-- 5.2 complains that it shouldn't be remove -->
<!-- <property name="fullname" remove="True"></property> -->
<!-- <property name="location" remove="True"></property> -->

<property name="gender" type="string" remove="true"></property>
<property name="firstname" type="string" remove="true"></property>
<property name="lastname" type="string" remove="true"></property>
<property name="phone" type="string" remove="true"></property>
<property name="company" type="string" remove="true"></property>

<property name="street" type="string" remove="true"></property>
<property name="zip" type="string" remove="true"></property>
<property name="city" type="string" remove="true"></property>
<property name="country" type="string" remove="true"></property>

<property name="delivery_alternative_delivery" type="boolean" remove="true"></property>
<property name="delivery_firstname" type="string" remove="true"></property>
<property name="delivery_lastname" type="string" remove="true"></property>
<property name="delivery_company" type="string" remove="true"></property>
<property name="delivery_street" type="string" remove="true"></property>
<property name="delivery_zip" type="string" remove="true"></property>
<property name="delivery_city" type="string" remove="true"></property>
<property name="delivery_country" type="string" remove="true"></property>

</object>
14 changes: 14 additions & 0 deletions src/bda/plone/shop/profiles/uninstall/registry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<registry>

<records prefix="plone.bundles/bda-plone-shop" interface='Products.CMFPlone.interfaces.IBundleRegistry' remove="true" />
<records interface="bda.plone.shop.interfaces.IShopSettings" prefix="plone.shop" remove="true" />
<records interface="bda.plone.shop.interfaces.IShopCartSettings" remove="true" />
<records interface="bda.plone.shop.interfaces.IShopArticleSettings" remove="true" />
<records interface="bda.plone.shop.interfaces.IShopShippingSettings" remove="true" />
<records interface="bda.plone.shop.interfaces.IShopTaxSettings" remove="true" />
<records interface="bda.plone.shop.interfaces.INotificationTextSettings" remove="true" />
<records interface="bda.plone.shop.interfaces.IInvoiceSettings" remove="true" />
<records interface="bda.plone.shop.interfaces.IPaymentTextSettings" remove="true" />

</registry>
38 changes: 27 additions & 11 deletions src/bda/plone/shop/setuphandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from bda.plone.shop.user.properties import PAS_ID
from bda.plone.shop.user.properties import UserPropertiesPASPlugin
from plone import api
from Products.CMFPlone import interfaces as Plone
from Products.CMFQuickInstallerTool import interfaces as QuickInstaller
from plone.base.interfaces import INonInstallable
from Products.PluggableAuthService.interfaces.plugins import IPropertiesPlugin
from zope.interface import implementer
from zope.globalrequest import getRequest

import logging

Expand Down Expand Up @@ -72,21 +72,37 @@ def install(context):

def uninstall(context):
"""
Remove the PAS plugin.
Remove dependencies
"""
installer = api.content.get_view(
name="installer",
context=api.portal.get(),
request=getRequest(),
)

for dep in [
"bda.plone.ajax",
"bda.plone.cart",
"bda.plone.checkout",
"bda.plone.discount",
"bda.plone.orders",
"bda.plone.payment",
"collective.js.datatables",
"souper.plone",
"yafowil.plone",
]:
installer.uninstall_product(dep)

pas = api.portal.get_tool(name="acl_users")
logger.info(remove_plugin(pas))


@implementer(Plone.INonInstallable)
@implementer(INonInstallable)
class HiddenProfiles(object):
def getNonInstallableProfiles(self):
"""Do not show on Plone's list of installable profiles."""
return []

"""Hide uninstall profile from site-creation and quickinstaller."""
return ["bda.plone.shop:uninstall"]

@implementer(QuickInstaller.INonInstallable)
class HiddenProducts(object):
def getNonInstallableProducts(self):
"""Do not show on QuickInstaller's list of installable products."""
return []
"""Hide the upgrades package from site-creation and quickinstaller."""
return ["bda.plone.shop.upgrades"]
11 changes: 7 additions & 4 deletions src/bda/plone/shop/vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def QuantityUnitVocabulary(context):
if not settings:
return
terms = []
for quantity_unit in settings.quantity_units:
for quantity_unit in (settings.quantity_units or []):
terms.append(
SimpleTerm(
value=quantity_unit,
Expand Down Expand Up @@ -157,7 +157,7 @@ def AvailableShippingMethodsVocabulary(context):
def ShippingMethodsVocabulary(context):
try:
items = Shippings(context).vocab
except KeyError:
except (KeyError, TypeError):
# happens GS profile application if registry entries not present yet
return AvailableShippingMethodsVocabulary(context)
return SimpleVocabulary([SimpleTerm(value=k, title=v) for k, v in items])
Expand All @@ -166,15 +166,18 @@ def ShippingMethodsVocabulary(context):
@provider(IVocabularyFactory)
def AvailablePaymentMethodsVocabulary(context):
payments = Payments(context).payments
items = [(payment.pid, payment.label) for payment in payments]
try:
items = [(payment.pid, payment.label) for payment in payments]
except KeyError:
return SimpleVocabulary([])
return SimpleVocabulary([SimpleTerm(value=k, title=v) for k, v in items])


@provider(IVocabularyFactory)
def PaymentMethodsVocabulary(context):
try:
items = Payments(context).vocab
except KeyError:
except (KeyError, TypeError):
# happens GS profile application if registry entries not present yet
return AvailablePaymentMethodsVocabulary(context)
return SimpleVocabulary([SimpleTerm(value=k, title=v) for k, v in items])

0 comments on commit 6a99d0b

Please sign in to comment.