Metadata-Version: 2.4
Name: collective.preventactions
Version: 0.4.0
Summary: This package allows administrators to mark objects which can't be deleted
Author-email: Benoît Suttor <benoit.suttor@imio.be>
License-Expression: GPL-2.0-only
Project-URL: Source, https://github.com/collective/collective.preventactions
Project-URL: Issues, https://github.com/collective/collective.preventactions/issues
Project-URL: Changelog, https://github.com/collective/collective.preventactions/blob/master/CHANGES.rst
Keywords: Plone,Python,Zope
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Plone
Classifier: Framework :: Plone :: 6.1
Classifier: Framework :: Plone :: 6.2
Classifier: Framework :: Plone :: Addon
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
Requires-Dist: plone.api
Requires-Dist: plone.base
Requires-Dist: plone.behavior
Requires-Dist: plone.dexterity
Requires-Dist: plone.z3cform
Requires-Dist: Products.CMFCore
Requires-Dist: Products.GenericSetup
Requires-Dist: z3c.form
Requires-Dist: Zope
Requires-Dist: zope.component
Requires-Dist: zope.i18nmessageid
Requires-Dist: zope.interface
Requires-Dist: zope.schema
Provides-Extra: test
Requires-Dist: plone.app.testing; extra == "test"
Requires-Dist: plone.browserlayer; extra == "test"
Requires-Dist: plone.classicui; extra == "test"

.. image:: https://github.com/collective/collective.preventactions/actions/workflows/test-matrix.yml/badge.svg
   :target: https://github.com/collective/collective.preventactions/actions/workflows/test-matrix.yml

=========================
collective.preventactions
=========================

This package allows administrators to mark objects which can't be deleted or renamed/moved.

.. image:: https://raw.githubusercontent.com/imio/collective.preventactions/master/docs/screenshot.png
    :alt: The map on a collection.
    :width: 602
    :height: 460
    :align: center

* `Source code @ GitHub <https://github.com/collective/collective.preventactions>`_
* `Releases @ PyPI <http://pypi.python.org/pypi/collective.preventactions>`_


Versions
--------

- Version 0.4 is for Plone 6.1 / 6.2 and Python 3.10+
- Version 0.3 is for Plone 5.2 and Python 3
- Versions < 0.3 are compatible with Archetypes (branch 0.2.x)


How it works
------------

This package use marker interfaces and subscribe to `IObjectWillBeRemovedEvent` and `IObjectWillBeMovedEvent` events.
If a marker interface is find on modified object, a exception will be raised.

You can also set some contents not deletable (for example) like this in your setuphandler : ::

   from collective.preventactions.interfaces import IPreventDelete
   from plone import api
   from zope.interface import alsoProvides


   def post_install(context):
       obj = api.content.get('/Plone/content-not-deleteable')
       alsoProvides(obj, IPreventDelete)
       obj.reindexObject(idxs=["object_provides"])

Reindexing ``object_provides`` lets the uninstall profile find and unmark the object.

Installation
------------

To install `collective.preventactions` you simply add ``collective.preventactions``
to the list of eggs in your buildout, run buildout and restart Plone.

Then, install `collective.preventactions` using the Add-ons control panel.


Development
-----------

You only need `uv <https://docs.astral.sh/uv/>`_. The Makefile follows the one generated by
`cookieplone <https://github.com/plone/cookieplone-templates>`_ for a backend add-on ::

    make install         # .venv (Python 3.12, Plone 6.2.3) and instance configuration
    make create-site     # create a "Plone" site with collective.preventactions installed
    make start           # http://localhost:8080/Plone (admin / admin)
    make console         # debug console on the instance
    make remove-data     # remove all content (and the .venv)

``make clean && PLONE_VERSION=6.1-latest make install`` builds against another Plone release, and
``DELETE_EXISTING=1 make create-site`` recreates the site.

Tests and code quality are managed by `plone.meta <https://github.com/plone/meta>`_ and
`tox <https://tox.wiki>`_ ::

    make test            # tests on Python 3.12 with Plone 6.2.3
    make lint            # pre-commit hooks (black, isort, flake8, zpretty, codespell...)
    make format          # reformat code
    make test-all        # lint, every supported Python / Plone version, dependency checks

Any tox environment can be run directly, e.g. ``uvx --with tox-uv tox -e py313-plone61``.
Do not edit the files generated by plone.meta: change ``.meta.toml`` and run
``uvx --from plone.meta config-package --branch current .`` instead.


License
-------

The project is licensed under the GPLv2.

Changelog
=========

0.4.0 (2026-11-12)
------------------

- Fix: the "Prevent actions" form now reindexes ``object_provides``, so the
  uninstall profile also unmarks objects protected through the form.
  [remdub]

- Fix: the uninstall profile now removes the "Prevent actions" object action.
  [remdub]

- Modernize package (Plone 6.2.3, PEP420, plone.meta, tests, french locales)
  [remdub]

- Add behavior to choose which content types to prevent.
  [remdub]


0.3.0 (2019-11-26)
------------------

- Remove Archetypes dependency.
  [bsuttor]


0.2.1 (2018-07-10)
------------------

- Typo.
  [bsuttor]


0.2 (2018-07-09)
----------------

- Fix check render of PreventActionForm.
  [bsuttor]


0.1 (2016-09-20)
----------------

- Package created using mr.bob
  [bsuttor]
