Author: |
Camptocamp, Odoo Community Association (OCA) |
License: |
LGPL-3 |
Branch: |
13.0 |
Repository: |
Change2improve/website-cms |
Dependencies: |
website |
Languages: |
Cucumber (1, 0.1%),
HTML (505, 51.9%),
JavaScript (88, 9.0%),
PO File (78, 8.0%),
Python (205, 21.1%),
and
XML (96, 9.9%) |
Other branches: |
10.0,
11.0,
and
9.0 |
Other repositories: |
BTETON/website-cms,
CompassionCH/website-cms,
ERPLibre/website-cms,
ForgeFlow/website-cms,
Gabinete-Digital/website-cms,
Guobower/website-cms,
Ingeos/website-cms,
JazziMc/website-cms,
MjAbuz/website-cms,
NL66278/website-cms,
NeatNerdPrime/website-cms,
Nooka10/website-cms,
OCA/website-cms,
PCatinean/website-cms,
SeuMarco/website-cms,
TDu/website-cms,
TelmoSenseFly/website-cms,
VisiionSolucionesTecnologicas/website-cms,
akretion/website-cms,
anhvu-sg/website-cms,
apetbiz/website-cms,
aryajimbaran/website-cms,
bishalgit/website-cms,
bvkl/website-cms,
caiuka/website-cms,
camptocamp/website-cms,
coobyHQ/odoo-saas-tools,
don-systems/website-cms,
elvirekemajou/website-cms,
frankchongli/website-cms,
gfcapalbo/website-cms,
grindtildeath/website-cms,
haroldtamo/website-cms,
hbrunn/website-cms,
hinfo506/website-cms,
isoscl/website-cms,
josueBulle/website-cms,
kevin070982/website-cms,
leemannd/website-cms,
lideritjnma/website-cms,
lukehuang/website-cms,
one2pret/website-cms,
osfp-Pakistan/website-cms,
ossamagharib/website-cms,
pscloud/website-cms,
py-web/website-cms,
ravishekharco/website-cms,
redcor/website-cms,
rsullivan2704/website-cms,
sanube/website-cms,
simahawk/website-cms,
steingabelgaard/website-cms,
wahello/website-cms,
and
x0rzkov/odoo-website-cms |
<h1 class="title">CMS status message</h1>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/website-cms/tree/13.0/cms_status_message"><img alt="OCA/website-cms" src="https://img.shields.io/badge/github-OCA%2Fwebsite--cms-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/website-cms-13-0/website-cms-13-0-cms_status_message"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/225/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>A "status message" is an important message that you want to show to
users.</p>
<p>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.".</p>
<p>This module allows to easily display this kind of messages to your
users.</p>
<p>Messages are displayed using Twitter bootstrap alerts.</p>
<p>You can add several messages: they will be displayed one after another.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="id5">Usage</a><ul>
<li><a class="reference internal" href="#python-code" id="id6">Python code</a></li>
<li><a class="reference internal" href="#autodismiss" id="id7">Autodismiss</a></li>
<li><a class="reference internal" href="#javascript-code" id="id8">Javascript code</a></li>
<li><a class="reference internal" href="#customize-appereance" id="id9">Customize appereance</a></li>
<li><a class="reference internal" href="#test-your-theme-look-and-feel" id="id10">Test your theme look and feel</a></li>
</ul>
</li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id11">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#changelog" id="id12">Changelog</a><ul>
<li><a class="reference internal" href="#id1" id="id13">11.0.1.3.0 (2018-08-07)</a></li>
<li><a class="reference internal" href="#id2" id="id14">11.0.1.2.0 (2018-08-07)</a></li>
<li><a class="reference internal" href="#id3" id="id15">11.0.1.1.0 (2018-04-22)</a></li>
<li><a class="reference internal" href="#id4" id="id16">11.0.1.0.0 (2018-01-18)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="id17">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id18">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id19">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id20">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id21">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<a name="usage"></a>
<h2><a class="toc-backref" href="#id5">Usage</a></h2>
<a name="python-code"></a>
<h3><a class="toc-backref" href="#id6">Python code</a></h3>
<p>Set a message:</p>
<pre>
<code lang="python">msg = _('My important message.')
if request.website:
request.website.add_status_message(msg)</code>
</pre>
<p>By default the message type is <code>info</code>. The title (the label at the
beginning of the message) matches the message type:</p>
<ul class="simple">
<li>'info': 'Info'</li>
<li>'success': 'Success'</li>
<li>'danger': 'Error'</li>
<li>'warning': 'Warning'</li>
</ul>
<p>You can change message parameters:</p>
<pre>
<code lang="python">msg = _('Watch out!')
if request.website:
request.website.add_status_message(msg, type_='warning', title='Oh no')</code>
</pre>
<p>Messages will be displayed like this:</p>
<img alt="https://raw.githubusercontent.com/OCA/website-cms/13.0/cms_status_message/images/preview.png" src="https://raw.githubusercontent.com/OCA/website-cms/13.0/cms_status_message/images/preview.png" />
<a name="autodismiss"></a>
<h3><a class="toc-backref" href="#id7">Autodismiss</a></h3>
<p>By default messages will be auto-dismissed after 8 seconds.
You can turn this off by setting an ir.config_param like:</p>
<pre>
<code>cms_status_message.autodismiss = 0</code>
</pre>
<p>You can customize the timeout by setting the key:</p>
<pre>
<code>cms_status_message.autodismiss_timeout = 3000 # milliseconds</code>
</pre>
<p>You can also customize this on demand when you create the message:</p>
<pre>
<code lang="python">msg = _('I will disappear more slowly')
options = {'autodismissTimeout': 10000}
if request.website:
request.website.add_status_message(msg, dismiss_options=options)</code>
</pre>
<a name="javascript-code"></a>
<h3><a class="toc-backref" href="#id8">Javascript code</a></h3>
<p>Dependencies:</p>
<pre>
<code lang="javascript">var msg_tool = require('cms_status_message.tool');
var core = require('web.core');
var _t = core._t;</code>
</pre>
<p>Inject a custom message on the fly:</p>
<pre>
<code lang="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');
});</code>
</pre>
<p>Add a status message to the session, useful if you want to show the
message only after a redirect:</p>
<pre>
<code lang="javascript">var msg = _t('Contratulations! You made it!.');
var options = {'title': _('My title'), 'dismissible': false};
msg_tool.add_message(msg, options);</code>
</pre>
<a name="customize-appereance"></a>
<h3><a class="toc-backref" href="#id9">Customize appereance</a></h3>
<p>By default the alert box is added on top of <code><main /></code> content. If you
want to customize this behavior just override or disable
<code>cms_status_message.add_status_message</code> template.</p>
<a name="test-your-theme-look-and-feel"></a>
<h3><a class="toc-backref" href="#id10">Test your theme look and feel</a></h3>
<p>Go to <cite>/cms/status-message/display-test</cite> to see how messages will look like
when your theme is applied.</p>
<a name="known-issues-roadmap"></a>
<h2><a class="toc-backref" href="#id11">Known issues / Roadmap</a></h2>
<p>Get rid of <cite>website</cite> dependency and move features to a standalone model.</p>
<a name="changelog"></a>
<h2><a class="toc-backref" href="#id12">Changelog</a></h2>
<a name="id1"></a>
<h3><a class="toc-backref" href="#id13">11.0.1.3.0 (2018-08-07)</a></h3>
<p><strong>Improvements</strong></p>
<ul>
<li><p class="first">Get rid of example package</p>
<p>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.</p>
<p>Now we have a new route <cite>/cms/status-message/display-test</cite> to check them.
<cite>cms_status_message_example</cite> module has been removed.</p>
</li>
</ul>
<a name="id2"></a>
<h3><a class="toc-backref" href="#id14">11.0.1.2.0 (2018-08-07)</a></h3>
<p><strong>Improvements</strong></p>
<ul>
<li><p class="first">Add auto-dimiss option</p>
<p>By default messages will be auto-dismissed after 8 seconds.
You can turn this off by setting an ir.config_param like:</p>
<pre>
<code>cms_status_message.autodismiss = 0</code>
</pre>
<p>You can customize the timeout by setting the key:</p>
<pre>
<code>cms_status_message.autodismiss_timeout = 3000 # milliseconds</code>
</pre>
<p>Check README for further info.</p>
</li>
</ul>
<a name="id3"></a>
<h3><a class="toc-backref" href="#id15">11.0.1.1.0 (2018-04-22)</a></h3>
<p><strong>Improvements</strong></p>
<ul>
<li><p class="first">Improve JS API</p>
<ol class="arabic simple">
<li>load qweb template on demand</li>
<li>load qweb template only if not loaded yet</li>
<li>use promises for rendering</li>
</ol>
<p>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.</p>
<p>Now we load templates only when needed
and we load them only if not loaded yet,
lowering page load time a bit :)</p>
<p>Plus, rendering now returns a promise object so you can chain calls
and do things when rendering is really finished.</p>
</li>
</ul>
<a name="id4"></a>
<h3><a class="toc-backref" href="#id16">11.0.1.0.0 (2018-01-18)</a></h3>
<p>Upgrade to v11</p>
<a name="bug-tracker"></a>
<h2><a class="toc-backref" href="#id17">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/website-cms/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/website-cms/issues/new?body=module:%20cms_status_message%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
<a name="credits"></a>
<h2><a class="toc-backref" href="#id18">Credits</a></h2>
<a name="authors"></a>
<h3><a class="toc-backref" href="#id19">Authors</a></h3>
<ul class="simple">
<li>Camptocamp</li>
</ul>
<a name="contributors"></a>
<h3><a class="toc-backref" href="#id20">Contributors</a></h3>
<ul class="simple">
<li>Simone Orsi <<a class="reference external" href="mailto:simone.orsi@camptocamp.com">simone.orsi@camptocamp.com</a>></li>
</ul>
<a name="maintainers"></a>
<h3><a class="toc-backref" href="#id21">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/website-cms/tree/13.0/cms_status_message">OCA/website-cms</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>