Skip to content

Commit 67d61ab

Browse files
committed
cms_delete_content: readme fragment + towncrier changelog
1 parent 52ba398 commit 67d61ab

File tree

6 files changed

+86
-7
lines changed

6 files changed

+86
-7
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Simone Orsi <simone.orsi@camptocamp.com>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Basic features for deleting content via frontend.
2+
3+
Features
4+
--------
5+
6+
- register your own custom delete confirmation view per-model
7+
- use ``cms_status_message`` to show confirmation message for deletion
8+
- generic template for asking delete confirmation
9+
- new fields and parameters on ``website.published.mixin`` to handle
10+
delete links and redirects
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
=========
2-
CHANGELOG
3-
=========
4-
51
11.0.1.0.2 (2018-04-27)
6-
=======================
2+
~~~~~~~~~~~~~~~~~~~~~~~
73

84
**Fixes**
95

@@ -16,14 +12,14 @@ CHANGELOG
1612

1713

1814
11.0.1.0.1 (2018-04-24)
19-
=======================
15+
~~~~~~~~~~~~~~~~~~~~~~~
2016

2117
**Fixes**
2218

2319
* Update JS according to `cms_status_message` updates
2420

2521

2622
11.0.1.0.0 (2018-01-18)
27-
=======================
23+
~~~~~~~~~~~~~~~~~~~~~~~
2824

2925
* Initial release
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
Get rid of `website` dependency to be able to use it w/ `portal` module only.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
Delete button and behavior
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
To add a delete button:
5+
6+
.. code:: html
7+
8+
<a class="btn btn-danger cms_delete_confirm" t-att-href="object.cms_delete_confirm_url">Delete</a>
9+
10+
When you click on a confirmation dialog pops up.
11+
12+
If you hit ``cancel`` the popup is closed. If you hit submit the item is
13+
deleted and you get redirected to your model's ``cms_after_delete_url``.
14+
By default is ``/``.
15+
16+
Customization
17+
-------------
18+
19+
Custom per-model delete messge
20+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21+
22+
.. code:: python
23+
24+
class MyModel(models.Model):
25+
_inherit = "my.model"
26+
27+
@api.multi
28+
def msg_content_delete_confirm(self):
29+
self.ensure_one()
30+
return _('Are you sure you want to delete "%s"?.') % self.name
31+
32+
Custom "after delete URL"
33+
~~~~~~~~~~~~~~~~~~~~~~~~~
34+
35+
When you are viewing a content and you delete it you want to be
36+
redirected to some other place.
37+
38+
By default you get redirected to the root of the website.
39+
40+
To change this behavior just override the attribute in your model
41+
declaration:
42+
43+
.. code:: python
44+
45+
class MyModel(models.Model):
46+
_inherit = "my.model"
47+
48+
cms_after_delete_url = '/foo'
49+
50+
Note: if you want to customize it on demand for particular pages, or you
51+
are deleting an item from another page (like a management page) you can
52+
pass ``?redirect=`` in the url, like:
53+
54+
.. code:: html
55+
56+
<a class="btn btn-danger cms_delete_confirm" t-attf-href="#{object.cms_delete_confirm_url}?redirect=">Delete</a>
57+
58+
Custom global delete confirm message appeareance
59+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60+
61+
.. code:: xml
62+
63+
<template id="delete_confirm" inherit_id="cms_delete_content.delete_confirm">
64+
65+
<xpath expr="//h4[@id='delete_confirm']" position="replace">
66+
<h1 t-esc="main_object.msg_content_delete_confirm()">I want it bigger!</h1>
67+
</xpath>
68+
69+
</template>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Migration to v13

0 commit comments

Comments
 (0)