Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][mig] cms_status_message #143

Merged
merged 58 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2f59f6b
[add] cms_status_message
simahawk Jan 10, 2017
ea922fb
[imp] allow passing html into msg
simahawk Feb 9, 2017
9be8f9a
OCA Transbot updated translations from Transifex
oca-transbot Mar 18, 2017
bd8a49a
[add] status msg rendering via JS (#10)
simahawk Mar 21, 2017
8cb20be
cms_status_message: fix README markup
simahawk Mar 23, 2017
3ac2093
Re-license cms_status_message + cms_delete_content to LGPL
simahawk May 26, 2017
37d2240
OCA Transbot updated translations from Transifex
oca-transbot Jun 3, 2017
7634f89
OCA Transbot updated translations from Transifex
oca-transbot Aug 5, 2017
957bb18
[MIG][10.0] cms status message
TDu Oct 2, 2017
c54abb4
[FIX] cms_status_message readme [ci skip]
TDu Oct 2, 2017
50c9a51
[MIG][11] cms_status_message
simahawk Jan 18, 2018
bab4da7
cms_status_message: improve session handling
simahawk Feb 4, 2018
4ea6520
Fix global JS lint
simahawk Feb 9, 2018
0c8dad0
cms_status_message: improve JS API
simahawk Apr 22, 2018
4506e9a
Bump cms_status_message 11.0.1.1.0
simahawk Apr 22, 2018
9235b36
[UPD] Update cms_status_message.pot
oca-travis Jun 28, 2018
eff7fe4
cms_status_message: add autodismiss option
simahawk Aug 6, 2018
b00c7cd
Bump cms_status_message 11.0.1.2.0
simahawk Aug 7, 2018
e4ab493
cms_status_message: get rid of example package
simahawk Aug 7, 2018
fdb7166
Bump cms_status_message 11.0.1.3.0
simahawk Aug 7, 2018
4784f81
[UPD] Update cms_status_message.pot
oca-travis Aug 7, 2018
b89b047
Update translation files
oca-transbot Dec 9, 2018
6f32f25
[REF] cms_status_message: Black python code
simahawk Apr 18, 2020
a5f36f8
[MIG] cms_status_message: Migration to 13.0
simahawk Apr 18, 2020
f84064d
cms_status_message: apply pre-commit
simahawk Apr 19, 2020
e01834b
cms_status_message: readme fragment + towncrier changelog
simahawk Apr 26, 2020
9668d6b
[UPD] Update cms_status_message.pot
oca-travis Oct 30, 2020
1b39001
Update translation files
oca-transbot Nov 1, 2020
927d706
[FIX] crm_status_message: Fix RST syntax
pedrobaeza Nov 4, 2020
3379257
Added translation using Weblate (Spanish)
claudiagn Feb 17, 2021
595a5db
Added translation using Weblate (Catalan)
claudiagn Feb 17, 2021
649a10e
Translated using Weblate (Spanish)
claudiagn Feb 17, 2021
9418244
Translated using Weblate (Catalan)
claudiagn Feb 17, 2021
bc7fc72
Add missing website key to manifest
simahawk May 16, 2021
881e1fa
cms_status_message: fix autodismiss
simahawk May 17, 2021
25e662d
Set maintainer on cms*
simahawk Aug 23, 2021
cf8548b
[UPD] changelog
OCA-git-bot Aug 23, 2021
6f09712
[UPD] README.rst
OCA-git-bot Aug 23, 2021
2ac2241
cms_status_message 13.0.1.0.1
OCA-git-bot Aug 23, 2021
70e7dec
Translated using Weblate (Italian)
mymage Dec 28, 2022
802a9a6
Translated using Weblate (Italian)
mymage Apr 3, 2023
ebc978c
cms_status_message: migrate to v16
simahawk May 13, 2023
6d942c2
cms_status_message: accept custom request
simahawk Jul 11, 2023
a27a931
cms_*: fix manifest maintainers key
simahawk Jul 12, 2023
f3a5947
cms_status_message: fix session storage
simahawk Jul 24, 2023
c3d6cfc
cms_status_message: fix portal tmpl integration
simahawk Jul 24, 2023
7e11707
[UPD] Update cms_status_message.pot
Sep 20, 2023
2f7ad8a
oca-github-bot post-merge updates
OCA-git-bot Sep 20, 2023
fab01a1
Update translation files
weblate Sep 21, 2023
c943f98
Translated using Weblate (Spanish)
Ivorra78 Sep 27, 2023
c5d4f25
cms_status_message: fix msg spacing
simahawk Oct 31, 2023
89d2144
[BOT] post-merge updates
OCA-git-bot Oct 31, 2023
f13c8bf
Translated using Weblate (Italian)
mymage Nov 13, 2023
793e8fd
Translated using Weblate (Italian)
mymage Jul 8, 2024
d16b927
[IMP] cms_status_message: pre-commit auto fixes
simahawk Feb 6, 2025
b9a5d46
cms_status_message: migrate to v14 (from v16)
simahawk Feb 6, 2025
9febd8a
cms_status_message: qweb t-out does not exists in v14
simahawk Feb 7, 2025
585f0dc
cms_status_message: adapt tests to v14
simahawk Feb 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
288 changes: 288 additions & 0 deletions cms_status_message/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
==================
CMS status message
==================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f5aff4e9e67728208db41b324377db9e2dd1c0fbc6528518eb9e544dde8520c8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fwebsite--cms-lightgray.png?logo=github
:target: https://github.com/OCA/website-cms/tree/16.0/cms_status_message
:alt: OCA/website-cms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/website-cms-16-0/website-cms-16-0-cms_status_message
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/website-cms&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

A "status message" is an important message that you want to show to
users.

For instance: a user submit a form or does a specific action and you
want to report the status of this action like "your profile has been
updated" or "Your upgrade has been successful.".

This module allows to easily display this kind of messages to your
users.

Messages are displayed using Twitter bootstrap alerts.

You can add several messages: they will be displayed one after another.

**Table of contents**

.. contents::
:local:

Usage
=====

Python code
~~~~~~~~~~~

Set a message:

.. code:: python

msg = _('My important message.')
env["ir.http"].add_status_message(msg)

By default the message type is ``info``. The title (the label at the
beginning of the message) matches the message type:

- 'info': 'Info'
- 'success': 'Success'
- 'danger': 'Error'
- 'warning': 'Warning'

You can change message parameters:

.. code:: python

msg = _('Watch out!')
env["ir.http"].add_status_message(msg, kind='warning', title='Oh no')

Messages will be displayed like this:

.. image:: https://raw.githubusercontent.com/OCA/website-cms/16.0/cms_status_message/images/preview.png

Autodismiss
~~~~~~~~~~~

By default messages will be auto-dismissed after 8 seconds.
You can turn this off by setting an ir.config_param like::

cms_status_message.autodismiss = 0

You can customize the timeout by setting the key::

cms_status_message.autodismiss_timeout = 3000 # milliseconds


You can also customize this on demand when you create the message:


.. code:: python

msg = _('I will disappear more slowly')
options = {'autodismissTimeout': 10000}
env["ir.http"].add_status_message(msg, dismiss_options=options)


Javascript code
~~~~~~~~~~~~~~~

Dependencies:

FIXME v16

.. code:: javascript


var msg_tool = require('cms_status_message.tool');
var core = require('web.core');
var _t = core._t;

Inject a custom message on the fly:

.. code:: javascript

msg = {
'msg': _t('Item unpublished.'),
'title': _t('Warning'),
'type': 'warning'
}
msg_tool.render_messages(msg).then(function(html) {
// wipe existing
$('.status_message').remove();
// inject new
$(html).hide().prependTo('#wrap').fadeIn('slow');
});


Add a status message to the session, useful if you want to show the
message only after a redirect:

.. code:: javascript

var msg = _t('Contratulations! You made it!.');
var options = {'title': _('My title'), 'dismissible': false};
msg_tool.add_message(msg, options);

Customize appereance
~~~~~~~~~~~~~~~~~~~~

By default the alert box is added on top of ``<main />`` content. If you
want to customize this behavior just override or disable
``cms_status_message.add_status_message`` template.


Test your theme look and feel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Go to `/cms/status-message/display-test` to see how messages will look like
when your theme is applied.

Changelog
=========

16.0.1.0.0 (2023-05-13)
~~~~~~~~~~~~~~~~~~~~~~~

**Features**

- Migration to v16 (`#127 <https://github.com/OCA/website-cms/issues/127>`_)
- Get rid of `website` dependency


13.0.1.0.1 (2021-08-23)
~~~~~~~~~~~~~~~~~~~~~~~

**Features**

- Migration to v13 (`#111 <https://github.com/OCA/website-cms/issues/111>`_)


11.0.1.3.0 (2018-08-07)
~~~~~~~~~~~~~~~~~~~~~~~

**Improvements**

* Get rid of example package

The example package was there only to show how a message would look like.
But in real life you want always to verify how they look like
with your theme styles applied.

Now we have a new route `/cms/status-message/display-test` to check them.
`cms_status_message_example` module has been removed.


11.0.1.2.0 (2018-08-07)
~~~~~~~~~~~~~~~~~~~~~~~

**Improvements**

* Add auto-dimiss option

By default messages will be auto-dismissed after 8 seconds.
You can turn this off by setting an ir.config_param like::

cms_status_message.autodismiss = 0

You can customize the timeout by setting the key::

cms_status_message.autodismiss_timeout = 3000 # milliseconds

Check README for further info.


11.0.1.1.0 (2018-04-22)
~~~~~~~~~~~~~~~~~~~~~~~

**Improvements**

* Improve JS API

1. load qweb template on demand
2. load qweb template only if not loaded yet
3. use promises for rendering

We load qweb templates via JS.
Prior to this change we got 1 request every time,
on every page load per each template,
even if we were not using any status message feature.

Now we load templates only when needed
and we load them only if not loaded yet,
lowering page load time a bit :)

Plus, rendering now returns a promise object so you can chain calls
and do things when rendering is really finished.


11.0.1.0.0 (2018-01-18)
~~~~~~~~~~~~~~~~~~~~~~~

Upgrade to v11

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/website-cms/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/website-cms/issues/new?body=module:%20cms_status_message%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* Simone Orsi <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-simahawk| image:: https://github.com/simahawk.png?size=40px
:target: https://github.com/simahawk
:alt: simahawk

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-simahawk|

This module is part of the `OCA/website-cms <https://github.com/OCA/website-cms/tree/16.0/cms_status_message>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions cms_status_message/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
24 changes: 24 additions & 0 deletions cms_status_message/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2017 Camptocamp - Simone Orsi
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
"name": "CMS status message",
"summary": """Basic status messages for your CMS system""",
"version": "14.0.1.0.0",
"maintainers": ["simahawk"],
"license": "LGPL-3",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/website-cms",
"depends": ["web", "portal"],
"data": [
"templates/status_message.xml",
"templates/display_test.xml",
],
"assets": {
"web.assets_frontend": [
"cms_status_message/static/src/js/tool.esm.js",
"cms_status_message/static/src/js/autodismiss.esm.js",
],
},
"installable": True,
}
1 change: 1 addition & 0 deletions cms_status_message/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
26 changes: 26 additions & 0 deletions cms_status_message/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2017-2018 Camptocamp - Thierry Ducrest
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import http


class CMSStatusMsgTest(http.Controller):
"""CMS status messge testing routes."""

display_test_template = "cms_status_message.display_test"

@http.route(
"/cms/status-message/display-test",
type="http",
auth="public",
sitemap=False,
)
def display_test(self, **kw): # pragma: no cover
"""Test the cms status messages."""
msg = http.request.httprequest.args.get("message[msg]", "yes it works")
msg_title = "Title"
for kind in ("success", "warning", "danger", "info"):
http.request.env["ir.http"].add_status_message(
msg, kind=kind, title=msg_title
)
return http.request.render(self.display_test_template)
Loading