Metadata-Version: 2.4
Name: collective.messagesviewlet
Version: 2.0.0
Summary: Add-on displaying manager defined messages in a viewlet
Author-email: IMIO Team <support@imio.be>
License-Expression: GPL-2.0-only
Project-URL: PyPI, https://pypi.org/project/collective.messagesviewlet
Project-URL: Source, https://github.com/collective/collective.messagesviewlet
Project-URL: Issues, https://github.com/collective/collective.messagesviewlet/issues
Project-URL: Changelog, https://github.com/collective/collective.messagesviewlet/blob/master/CHANGES.rst
Keywords: Python,Plone
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: Plone
Classifier: Framework :: Plone :: 6.1
Classifier: Framework :: Plone :: 6.2
Classifier: Framework :: Plone :: Addon
Classifier: Operating System :: OS Independent
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
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
Requires-Dist: collective.behavior.talcondition
Requires-Dist: plone.api
Requires-Dist: plone.app.dexterity
Requires-Dist: plone.app.event
Requires-Dist: plone.app.layout
Requires-Dist: plone.app.registry
Requires-Dist: plone.app.textfield
Requires-Dist: plone.app.workflow
Requires-Dist: plone.app.z3cform
Requires-Dist: plone.autoform
Requires-Dist: plone.base
Requires-Dist: plone.dexterity
Requires-Dist: plone.indexer
Requires-Dist: plone.registry
Requires-Dist: plone.supermodel
Requires-Dist: plone.z3cform
Requires-Dist: Products.CMFCore
Requires-Dist: Products.CMFPlone
Requires-Dist: Products.GenericSetup
Requires-Dist: Products.statusmessages
Requires-Dist: pytz
Requires-Dist: z3c.form
Requires-Dist: Zope
Requires-Dist: zope.annotation
Requires-Dist: zope.component
Requires-Dist: zope.globalrequest
Requires-Dist: zope.i18n
Requires-Dist: zope.i18nmessageid
Requires-Dist: zope.interface
Requires-Dist: zope.publisher
Requires-Dist: zope.schema
Provides-Extra: test
Requires-Dist: plone.app.contenttypes[test]; extra == "test"
Requires-Dist: plone.app.testing; extra == "test"
Requires-Dist: plone.browserlayer; extra == "test"
Requires-Dist: plone.classicui; extra == "test"
Requires-Dist: python-dateutil; extra == "test"
Requires-Dist: zope.viewlet; extra == "test"

.. image:: https://github.com/collective/collective.messagesviewlet/actions/workflows/test-matrix.yml/badge.svg?branch=master
    :target: https://github.com/collective/collective.messagesviewlet/actions/workflows/test-matrix.yml

.. image:: https://coveralls.io/repos/collective/collective.messagesviewlet/badge.svg?branch=master
  :target: https://coveralls.io/github/collective/collective.messagesviewlet?branch=master

.. image:: http://img.shields.io/pypi/v/collective.messagesviewlet.svg
   :alt: PyPI badge
   :target: https://pypi.org/project/collective.messagesviewlet


.. This README is meant for consumption by humans and pypi. Pypi can render rst files so please do not use Sphinx features.
   If you want to learn more about writing documentation, please check out: http://docs.plone.org/about/documentation_styleguide_addons.html
   This text does not appear on pypi or github. It is a comment.

==============================================================================
collective.messagesviewlet
==============================================================================

Add-on displaying manager defined messages in a viewlet

.. image:: https://raw.githubusercontent.com/collective/collective.messagesviewlet/master/docs/messageviewletinaction.png
    :alt: The three message types.
    :width: 1300
    :align: center

Features
--------

Messages are defined in control panel.

Multiple messages can be displayed together in the viewlet.

A message contains the following configuration attributes:

* text : displayed text in the viewlet
* message type : info, significant, warning (different layout in the viewlet)
* can hide : if checked, the user can hide the message (mark as read)
* start date : displaying start date (optional)
* end date : displaying end date (optional)
* required roles : user must have one of the required roles (optional)
* use local roles : message displayed for users having Reader local role on message (optional)
* location : full site or homepage only

Local messages can also be authorized (through control panel) to be added in any
folderish content types and you can then choose if / on which levels they display.

The collective.behavior.talcondition is enabled, providing 2 attributes.

* tal condition : optional tal expression evaluated on viewlet context
* bypassing roles : optional roles bypassing the tal condition

.. image:: https://raw.githubusercontent.com/collective/collective.messagesviewlet/master/docs/messageviewletinconfiguration.png
    :alt: The management interface.
    :width: 1252
    :align: center


A workflow is provided with the following states:

* inactive : not displayed
* activated : displayed

The hiding functionality uses a cookie. It is necessary to (re-)activate a message to "reset" the cookie.
After new activation, the message will be displayed again even for users that hide it.

The optional 'messages' profile adds some useful examples that can be activated when needed:

* message for scheduled maintenance (limited to Member)
* message for imminent or current maintenance : (given to anonymous)
* message for staging site

There is also a PseudoMessage class that can be instantiated and used in viewlet templates.


Limitations
-----------

This add-on supports Plone 6.1 on Python 3.10 to 3.13, and Plone 6.2 on Python
3.10 to 3.14, and is tested on each of them. Use version 1.0b5 for Plone 4.3 to
6.0.


Improvements
------------

* Modify hidden_uid when some fields are changed: end when gone, can_hide (to unchecked), start when end is gone
* Message definition from file system
* Message definition from rss feed


Translations
------------

This product has been translated into

- English
- French


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

Add ``collective.messagesviewlet`` to the dependencies of your project (``pip``,
``uv`` or buildout ``eggs``), restart Plone, then install the add-on in the
Add-ons control panel.


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

You only need `uv <https://docs.astral.sh/uv/>`_ ::

    make install         # .venv (Python 3.12, Plone 6.2.3) and instance configuration
    make create-site     # create a "Plone" site with collective.messagesviewlet installed
    make start           # http://localhost:8080/Plone (admin / admin)
    make console         # debug console on the instance
    make i18n            # update the translation files
    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 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.


Contribute
----------

- Issue Tracker: https://github.com/collective/collective.messagesviewlet/issues
- Source Code: https://github.com/collective/collective.messagesviewlet


Support
-------

If you are having issues, please let us know.


License
-------

The project is licensed under the GPLv2.

- IMIO Team, support@imio.be

Changelog
=========


2.0.0 (2026-11-18)
------------------

- Breaking: migrate to PEP 420 native namespaces (setuptools 81 / Plone 6.2).
  Support Plone 6.1 only on Python 3.10 to 3.13, and Plone 6.2 on Python 3.10
  to 3.14: Plone 4.3 to 6.0 are dropped (use 1.0b5).
  [bsuttor]

- Move the package metadata from ``setup.py`` to ``pyproject.toml``, configure
  the package with plone.meta (tox, GitHub Actions, pre-commit) and replace the
  buildout development environment by a uv one on Plone 6.2.3. Remove the
  Travis and buildout files, and the Selenium robot tests, which can't run on
  plone.app.robotframework 3.
  [bsuttor]

- Import ``IPloneSiteRoot`` and ``INonInstallable`` from ``plone.base``, and
  drop ``six``.
  [bsuttor]


1.0b5 (2026-10-22)
------------------

- Fix messages disappearing (or appearing) up to 2 hours too early when the
  server isn't in UTC: the catalog was queried with a naive local "now",
  which the `start`/`end` DateRecurringIndex reads as UTC
  [remdub]
- `add_message`: default `start` is now computed at call time, in the portal
  timezone, instead of once at import time
  [remdub]


1.0b4 (2025-04-24)
------------------

- Add Plone 6.1 compatibility by replacing pkg_resources with importlib
  [remdub]


1.0b3 (2023-08-24)
------------------

- Add upgrade step : Remove deprecated control panel action
  [boulch]

- Improve uninstall product
  [boulch, gbastien]


1.0b2 (2022-12-26)
------------------

- Fix bundle registry upgrade step
  [laulaz]


1.0b1 (2022-12-22)
------------------

- Migrate to Plone 6.0.0: remove dexteritytextindexer, use new simplified
  resources registry, fix styles, fix icons, ...
  [boulch, laulaz]
- Add local messages feature. Local messages can be added in any folderish
  content types and you can choose if / on which levels they display.
  [boulch]
- Protect messages-config folder with one-state private workflow.
  [boulch]
- Add control panel (with messages-config folder link).
  [boulch]
- Use JS to show/hide messages when closed, to avoid caching problems (#12).
  [laulaz]
- Update / improve translations.
  [boulch, laulaz]


0.23 (2020-04-17)
-----------------
- Fix tests & travis build (#8).
  [laulaz]
- Prevent a bug when compare 2 dates with different timezone format.
  [boulch]


0.22 (2020-01-15)
-----------------

- Fix bug when message configuration don't permit to hide this message (close button stayed).
  [boulch]
- Adapted code for Plone5.2/Py3.
  [gbastien]

0.21 (2019-10-14)
-----------------

- Bypass allowed content types constraint when (post)install messagesConfig container
  [boulch]


0.20 (2019-08-23)
-----------------

- Added parameter `caching=True` to `utils.get_messages_to_show`, if `True`,
  the method result is cached in the request for given `context`.
  [gbastien]

0.19 (2019-07-15)
-----------------

- Added PseudoMessage class that be be used in viewlet template.
  [sgeulette]

0.18 (2019-05-27)
-----------------

- Define version to `2000` in `metadata.xml` of plone4 profile or upgrade step
  to 2000 is always displayed.
  [gbastien]

0.17 (2019-04-23)
-----------------

- Evaluate TAL condition using behavior `evaluate` method instead calling
  directly submethod `utils.evaluateExpressionFor` so behavior method
  `complete_extra_expr_ctx` is called.
  [gbastien]
- Call JS on portal_url so it can be cached by the browser.
  [gbastien]
- Tests on Plone5 and Plone4.
  [bsuttor]
- Manage profiles differently
  [sgeulette]
- Moved `MessagesViewlet.getAllMessages` code to `utils.get_messages_to_show`
  so it is easily callable from outside.
  [gbastien]
- Be defensive while managing TZ of message dates : do not set it if already
  set, it fails, moreover, indexing a metadata from a date attribute that had
  no TZ to one having TZ fails so undindex/reindex the entire message.
  [gbastien]

0.16 (2018-10-18)
-----------------

- Corrected import step dependencies to avoid unresolved warning. Save really changes !
  [sgeulette]

0.15 (2018-10-11)
-----------------

- Corrected import step dependencies to avoid unresolved warning.
  [sgeulette]

0.14 (2018-07-23)
-----------------

- Generate new uid when message is activated or re-activated.
  [sgeulette]

0.13 (2018-06-13)
-----------------

- Add <span> around cross <img> to ease override.
  [mgennart]

0.12 (2017-05-30)
-----------------

- Corrected image path.
  [sgeulette]
- Decrease space between messages
  [sgeulette]

0.11 (2017-03-16)
-----------------

- Added default message to warn that application only runs correctly on Firefox
  and Chrome, in addition to the already existing message that warned about the
  application only running correctly on Firefox.
  [gbastien]
- Use CheckBoxWidget for IMessage.required_roles` to ease selection when
  displaying several elements.
  [gbastien]
- Use RadioFieldWidget for Bool fields `IMessage.can_hide` and
  `IMessage.use_local_roles` so it is displayed correctly on the view,
  especially when it is False.
  [gbastien]


0.10 (2017-02-06)
-----------------

- Use INavigationRoot instead of IPloneSiteRoot to check if context is homepage.
  [bsuttor]


0.9 (2016-03-30)
----------------

- Increased coverage by using vocabulary methods instead of redefining it in tests.
  [gbastien]
- Added new example message: bad browser (not Firefox) warning
  [sgeulette]
- Use plone.formwidget.datetime to have hour at 0 by default.
  [sgeulette]
- CSS fix : display 'cursor: pointer;' when hovering the close button.
  [gbastien]
- Added 'MessagesConfig' to site_properties.types_not_searched.
  [gbastien]


0.8 (2016-01-18)
----------------

- Added parameter 'activate' to utils.add_message that makes it possible to create
  an 'activated' message directly.
  [gbastien]
- Adapted tests to use utils.add_message instead of duplicating this code.
  [gbastien]


0.7 (2015-11-17)
----------------

- Do not pass a default 'context' in utils._ to avoid strange ConnectionStateError.
  [gbastien]
- Give context to translate method.
  [sgeulette]
- Corrected and added icon type images.
  [sgeulette]


0.6 (2015-09-18)
----------------

- Simplify workflow. Only one activated state. Unrestricted search results before filtering.
  Added 'use local role' boolean attribute.
  [sgeulette]
- Updated default messages
  [sgeulette]
- Added local roles test
  [sgeulette]
- Renamed bad transition name
  [sgeulette]


0.5 (2015-09-14)
----------------

- Removed useless dependency on z3c.jbot.
  [gbastien]
- Corrected rst in readme.
  [sgeulette]


0.4 (2015-09-10)
----------------

- Use full url for readme images to display correctly on pypi.
  [sgeulette]


0.3 (2015-09-10)
----------------

- Translate title configuration folder.
  [sgeulette]


0.2 (2015-09-09)
----------------

- Added utils method to create message. Added example profile to add some messages.
  [sgeulette]


0.1 (2015-09-08)
----------------

- Initial release.
  [sgeulette, anuyens, DieKatze, boulch]
