diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e5916b183..1e3986ddd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,6 @@ exclude: | ^cms_form/| ^cms_form_example/| ^cms_info/| - ^cms_status_message/| # END NOT INSTALLABLE ADDONS # Files and folders generated by bots, to avoid loops ^setup/|/static/description/index\.html$| diff --git a/cms_status_message/README.rst b/cms_status_message/README.rst index f9d87887d..451d1ab36 100644 --- a/cms_status_message/README.rst +++ b/cms_status_message/README.rst @@ -21,13 +21,13 @@ CMS status message :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 + :target: https://github.com/OCA/website-cms/tree/19.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 + :target: https://translation.odoo-community.org/projects/website-cms-19-0/website-cms-19-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 + :target: https://runboat.odoo-community.org/builds?repo=OCA/website-cms&target_branch=19.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -55,59 +55,60 @@ Usage ===== Python code -~~~~~~~~~~~ +----------- Set a message: .. code:: python - msg = _('My important message.') - env["ir.http"].add_status_message(msg) + 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' +- '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') + 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 +|image| Autodismiss -~~~~~~~~~~~ +----------- -By default messages will be auto-dismissed after 8 seconds. -You can turn this off by setting an ir.config_param like:: +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 = 0 - cms_status_message.autodismiss_timeout = 3000 # milliseconds +You can customize the timeout by setting the key: +:: -You can also customize this on demand when you create the message: + 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) - + msg = _('I will disappear more slowly') + options = {'autodismissTimeout': 10000} + env["ir.http"].add_status_message(msg, dismiss_options=options) Javascript code -~~~~~~~~~~~~~~~ +--------------- Dependencies: @@ -115,131 +116,129 @@ FIXME v16 .. code:: javascript - - var msg_tool = require('cms_status_message.tool'); - var core = require('web.core'); - var _t = core._t; + 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'); - }); - + 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); + 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 ``
`` 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. -Go to `/cms/status-message/display-test` to see how messages will look like -when your theme is applied. +.. |image| image:: https://raw.githubusercontent.com/OCA/website-cms/19.0/cms_status_message/images/preview.png Changelog ========= 16.0.1.0.0 (2023-05-13) -~~~~~~~~~~~~~~~~~~~~~~~ +----------------------- **Features** -- Migration to v16 (`#127 `_) -- Get rid of `website` dependency - +- Migration to v16 + (`#127 `__) +- Get rid of website dependency 13.0.1.0.1 (2021-08-23) -~~~~~~~~~~~~~~~~~~~~~~~ +----------------------- **Features** -- Migration to v13 (`#111 `_) - +- Migration to v13 + (`#111 `__) 11.0.1.3.0 (2018-08-07) -~~~~~~~~~~~~~~~~~~~~~~~ +----------------------- **Improvements** -* Get rid of example package +- 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 + 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. - + 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 +- 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:: + 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 = 0 - cms_status_message.autodismiss_timeout = 3000 # milliseconds + You can customize the timeout by setting the key: - Check README for further info. + :: + cms_status_message.autodismiss_timeout = 3000 # milliseconds + + Check README for further info. 11.0.1.1.0 (2018-04-22) -~~~~~~~~~~~~~~~~~~~~~~~ +----------------------- **Improvements** -* Improve JS API +- 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. + 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 :) + 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 @@ -249,7 +248,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -257,17 +256,17 @@ Credits ======= Authors -~~~~~~~ +------- * Camptocamp Contributors -~~~~~~~~~~~~ +------------ -* Simone Orsi +- Simone Orsi Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -287,6 +286,6 @@ Current `maintainer `__: |maintainer-simahawk| -This module is part of the `OCA/website-cms `_ project on GitHub. +This module is part of the `OCA/website-cms `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/cms_status_message/__manifest__.py b/cms_status_message/__manifest__.py index 060be2248..a3ae83b98 100644 --- a/cms_status_message/__manifest__.py +++ b/cms_status_message/__manifest__.py @@ -4,7 +4,7 @@ { "name": "CMS status message", "summary": """Basic status messages for your CMS system""", - "version": "16.0.1.1.0", + "version": "19.0.1.0.0", "maintainers": ["simahawk"], "license": "LGPL-3", "author": "Camptocamp, Odoo Community Association (OCA)", @@ -18,7 +18,8 @@ "web.assets_frontend": [ "cms_status_message/static/src/js/tool.esm.js", "cms_status_message/static/src/js/autodismiss.esm.js", + "cms_status_message/static/src/xml/status_message.xml", ], }, - "installable": False, + "installable": True, } diff --git a/cms_status_message/models/ir_http.py b/cms_status_message/models/ir_http.py index 5db5cfde0..7905febf9 100644 --- a/cms_status_message/models/ir_http.py +++ b/cms_status_message/models/ir_http.py @@ -1,7 +1,7 @@ # Copyright 2017 Camptocamp - Simone Orsi # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -from odoo import _, api, http, models +from odoo import api, http, models class IrHttp(models.AbstractModel): @@ -11,10 +11,10 @@ class IrHttp(models.AbstractModel): def default_status_msg_title(self): """Some default msg titles.""" return { - "info": _("Info"), - "success": _("Success"), - "danger": _("Error"), - "warning": _("Warning"), + "info": self.env._("Info"), + "success": self.env._("Success"), + "danger": self.env._("Error"), + "warning": self.env._("Warning"), } @api.model diff --git a/cms_status_message/readme/CONTRIBUTORS.md b/cms_status_message/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..2b66303ae --- /dev/null +++ b/cms_status_message/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Simone Orsi \<\> diff --git a/cms_status_message/readme/CONTRIBUTORS.rst b/cms_status_message/readme/CONTRIBUTORS.rst deleted file mode 100644 index f1c71bce1..000000000 --- a/cms_status_message/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1 +0,0 @@ -* Simone Orsi diff --git a/cms_status_message/readme/DESCRIPTION.rst b/cms_status_message/readme/DESCRIPTION.md similarity index 100% rename from cms_status_message/readme/DESCRIPTION.rst rename to cms_status_message/readme/DESCRIPTION.md diff --git a/cms_status_message/readme/HISTORY.md b/cms_status_message/readme/HISTORY.md new file mode 100644 index 000000000..13b1ec4cd --- /dev/null +++ b/cms_status_message/readme/HISTORY.md @@ -0,0 +1,68 @@ +## 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 diff --git a/cms_status_message/readme/HISTORY.rst b/cms_status_message/readme/HISTORY.rst deleted file mode 100644 index 004cfd5e8..000000000 --- a/cms_status_message/readme/HISTORY.rst +++ /dev/null @@ -1,79 +0,0 @@ -16.0.1.0.0 (2023-05-13) -~~~~~~~~~~~~~~~~~~~~~~~ - -**Features** - -- Migration to v16 (`#127 `_) -- Get rid of `website` dependency - - -13.0.1.0.1 (2021-08-23) -~~~~~~~~~~~~~~~~~~~~~~~ - -**Features** - -- Migration to v13 (`#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 diff --git a/cms_status_message/readme/USAGE.md b/cms_status_message/readme/USAGE.md new file mode 100644 index 000000000..bd61621ab --- /dev/null +++ b/cms_status_message/readme/USAGE.md @@ -0,0 +1,94 @@ +## Python code + +Set a message: + +``` 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: + +``` python +msg = _('Watch out!') +env["ir.http"].add_status_message(msg, kind='warning', title='Oh no') +``` + +Messages will be displayed like this: + +![image](./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: + +``` 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 + +``` 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: + +``` 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: + +``` 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 `
` 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. diff --git a/cms_status_message/readme/USAGE.rst b/cms_status_message/readme/USAGE.rst deleted file mode 100644 index 3f83ace45..000000000 --- a/cms_status_message/readme/USAGE.rst +++ /dev/null @@ -1,105 +0,0 @@ -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:: ./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 ``
`` 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. diff --git a/cms_status_message/static/description/index.html b/cms_status_message/static/description/index.html index 76aae38d6..4cd0dd9c3 100644 --- a/cms_status_message/static/description/index.html +++ b/cms_status_message/static/description/index.html @@ -3,7 +3,7 @@ -README.rst +CMS status message