Skip to content

Commit

Permalink
add behavior iocomune
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico committed Jul 25, 2024
1 parent 05288dc commit 2fa8a6f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<element value="Image" />
<element value="File" />
<element value="Folder" />
<element value="Document" />
</property>
<property name="allow_discussion">False</property>
<property name="default_view">view</property>
Expand All @@ -39,11 +40,14 @@
<element value="plone.namefromtitle" />
<element value="plone.allowdiscussion" />
<element value="plone.excludefromnavigation" />
<element value="plone.leadimage" />
<element value="kitconcept.seo" />
<element value="plone.shortname" />
<element value="plone.richtext" />
<element value="plone.versioning" />
<element value="plone.locking" />
<element value="plone.textindexer" />
<element value="volto.preview_image" />

<!-- TODO: su profilo rer aggiungere
<element value="rer.solrpush.behaviors.solr_fields.ISolrFields" />
Expand Down
27 changes: 26 additions & 1 deletion src/rer/ufficiostampa/setuphandlers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
from Products.CMFPlone.interfaces import INonInstallable
from zope.interface import implementer
from plone import api
from Products.CMFPlone.utils import get_installer
Crom plone.dexterity.interfaces import IDexterityFTI
from zope.component import getUtility


def set_behavior(fti_id, name, value):
"""Set a behavior on a FTI
if value is True, add the behavior, otherwise remove it
"""
# add or remove the behavior based on the value from the form
fti = getUtility(IDexterityFTI, name=fti_id)
behaviors = list(fti.behaviors)
if value and name not in behaviors:
behaviors.append(name)
elif not value and name in behaviors:
behaviors.remove(name)
fti.behaviors = tuple(behaviors)


@implementer(INonInstallable)
Expand All @@ -13,7 +31,14 @@ def getNonInstallableProfiles(self):

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

# Do something during the installation of this package
installer = get_installer(context)
if installer.is_product_installed("design.plone.contenttypes"):
set_behavior("ComunicatoStampa", "design.plone.contenttypes.behavior.argomenti_news", True)
set_behavior("ComunicatoStampa", "design.plone.contenttypes.behavior.news_base", True)
set_behavior("ComunicatoStampa", "plone.basic", True)
set_behavior("ComunicatoStampa", "rer.ufficiostampa.basic", False)
set_behavior("ComunicatoStampa", "rer.ufficiostampa.legislature", False)

def uninstall(context):
"""Uninstall script"""

0 comments on commit 2fa8a6f

Please sign in to comment.