From 5649fbbd851d3b2f3b1b1b560506a74acd012573 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Sun, 4 Mar 2018 12:07:58 +0100 Subject: [PATCH 01/31] Add `cms_info` --- cms_info/README.rst | 79 ++++++++++++++++++++++++++++++++ cms_info/__init__.py | 1 + cms_info/__manifest__.py | 18 ++++++++ cms_info/models/__init__.py | 1 + cms_info/models/website_mixin.py | 71 ++++++++++++++++++++++++++++ 5 files changed, 170 insertions(+) create mode 100644 cms_info/README.rst create mode 100644 cms_info/__init__.py create mode 100644 cms_info/__manifest__.py create mode 100644 cms_info/models/__init__.py create mode 100644 cms_info/models/website_mixin.py diff --git a/cms_info/README.rst b/cms_info/README.rst new file mode 100644 index 00000000..60974919 --- /dev/null +++ b/cms_info/README.rst @@ -0,0 +1,79 @@ +.. 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 + +======== +CMS Info +======== + +Provide basic information for website records / models via `website.published.mixin`. +This module is meant to be used as a base to build your own CMS. + +New attributes +-------------- + +* ``cms_create_url``: lead to create view. By default ``/cms/create/my.model`` +* ``cms_search_url``: lead to search view. By default ``/cms/search/my.model`` +* ``cms_edit_url`` (computed field): lead to edit view. By default ``/cms/edit/my.model/model_id`` + +.. note:: No routing provided. + This attributes provide only basic information on contents' URLs. + If you use `cms_form` default routes are handled automatically. + If not, is up to you to provide your own routes to handle them. + + +Permission and extra information +-------------------------------- + +* ``record.cms_is_owner()``: current user is the owner of the record? +* ``record.cms_can_edit()``: current user can edit this record? +* ``record.cms_can_publish()``: current user can publish this record? +* ``record.cms_can_delete()``: current user can delete this record? +* ``model.cms_can_create()``: current user can create a new record? + + +Info all in one +--------------- + +When you build CMS UIs you need all those info at once. +This module provides also an helper method `cms_info()` +that gives you back a dictionary containing: + +* `is_owner`: True/False, +* `can_edit`: True/False, +* `can_create`: True/False, +* `can_publish`: True/False, +* `can_delete`: True/False, +* `create_url` +* `edit_url` +* `delete_url` + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. + + +Credits +======= + +Contributors +------------ + +* Simone Orsi + + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/cms_info/__init__.py b/cms_info/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/cms_info/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/cms_info/__manifest__.py b/cms_info/__manifest__.py new file mode 100644 index 00000000..6dcc5fcb --- /dev/null +++ b/cms_info/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2018 Simone Orsi - Camptocamp +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +{ + "name": "CMS info", + "summary": + """A set of basic information needed on all published records.""", + "version": "11.0.1.0.0", + "category": "Website", + "website": "https://github.com/OCA/website-cms", + "author": "Camptocamp, Odoo Community Association (OCA)", + "license": "LGPL-3", + "installable": True, + "depends": [ + 'website', + 'cms_delete_content', + ], +} diff --git a/cms_info/models/__init__.py b/cms_info/models/__init__.py new file mode 100644 index 00000000..bdd8436d --- /dev/null +++ b/cms_info/models/__init__.py @@ -0,0 +1 @@ +from . import website_mixin diff --git a/cms_info/models/website_mixin.py b/cms_info/models/website_mixin.py new file mode 100644 index 00000000..eec62568 --- /dev/null +++ b/cms_info/models/website_mixin.py @@ -0,0 +1,71 @@ +# Copyright 2018 Simone Orsi (Camptocamp) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). +from odoo import models, api, exceptions, fields + + +class WebsiteMixin(models.AbstractModel): + _inherit = 'website.published.mixin' + + @property + def cms_create_url(self): + return '/cms/create/{}'.format(self._name) + + @property + def cms_search_url(self): + return '/cms/search/{}'.format(self._name) + + cms_edit_url = fields.Char( + string='CMS edit URL', + compute='_compute_cms_edit_url', + readonly=True, + ) + + @api.multi + def _compute_cms_edit_url(self): + for item in self: + item.cms_edit_url = '/cms/edit/{}/{}'.format(item._name, item.id) + + @api.multi + def cms_is_owner(self, uid=None): + self.ensure_one() + uid = uid or self.env.user.id + return self.create_uid.id == uid + + @api.model + def cms_can_create(self): + return self.check_access_rights('create', raise_exception=False) + + @api.multi + def _cms_check_perm(self, mode): + self.ensure_one() + try: + self.check_access_rights(mode) + self.check_access_rule(mode) + can = True + except exceptions.AccessError: + can = False + return can + + def cms_can_edit(self): + return self._cms_check_perm('write') + + def cms_can_delete(self): + return self._cms_check_perm('unlink') + + def cms_can_publish(self): + # TODO: improve this + return self.cms_can_edit() + + def cms_info(self): + info = { + 'is_owner': self.cms_is_owner(), + 'can_edit': self.cms_can_edit(), + 'can_create': self.cms_can_create(), + 'can_publish': self.cms_can_publish(), + 'can_delete': self.cms_can_delete(), + 'create_url': self.cms_create_url, + 'edit_url': self.cms_edit_url, + # delete/delete confirm URLs come from `cms_delete_content` + 'delete_url': self.cms_delete_confirm_url, + } + return info From 584020fc6c765b8bf368f13a91100eba74a34bbc Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Fri, 27 Apr 2018 16:30:46 +0200 Subject: [PATCH 02/31] Bump cms_info 11.0.1.0.0 --- cms_info/CHANGES.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 cms_info/CHANGES.rst diff --git a/cms_info/CHANGES.rst b/cms_info/CHANGES.rst new file mode 100644 index 00000000..e537fbc4 --- /dev/null +++ b/cms_info/CHANGES.rst @@ -0,0 +1,12 @@ +========= +CHANGELOG +========= + + +11.0.1.0.0 (2018-04-27) +======================= + +Improvements +------------ + +* Initial release \ No newline at end of file From 562593ce7c6be1bcdd14bb724a26ba955be94f37 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Sun, 5 Aug 2018 13:04:55 +0200 Subject: [PATCH 03/31] cms_info: test coverage 100% --- cms_info/tests/__init__.py | 1 + cms_info/tests/fake_models.py | 65 +++++++++++++++++++++ cms_info/tests/test_info_mixin.py | 97 +++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 cms_info/tests/__init__.py create mode 100644 cms_info/tests/fake_models.py create mode 100644 cms_info/tests/test_info_mixin.py diff --git a/cms_info/tests/__init__.py b/cms_info/tests/__init__.py new file mode 100644 index 00000000..b9617100 --- /dev/null +++ b/cms_info/tests/__init__.py @@ -0,0 +1 @@ +from . import test_info_mixin \ No newline at end of file diff --git a/cms_info/tests/fake_models.py b/cms_info/tests/fake_models.py new file mode 100644 index 00000000..083e77b4 --- /dev/null +++ b/cms_info/tests/fake_models.py @@ -0,0 +1,65 @@ +# Copyright 2018 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import fields, models + + +class TestMixin(object): + + # generate xmlids + # this is needed if you want to load data tied to a test model via xid + _test_setup_gen_xid = False + _test_teardown_no_delete = False + + @classmethod + def _test_setup_model(cls, env): + """Initialize it.""" + cls._build_model(env.registry, env.cr) + env.registry.setup_models(env.cr) + ctx = dict(env.context, update_custom_fields=True) + if cls._test_setup_gen_xid: + ctx['module'] = cls._module + env.registry.init_models(env.cr, [cls._name], ctx) + + @classmethod + def _test_teardown_model(cls, env): + """Deinitialize it.""" + if not getattr(cls, '_test_teardown_no_delete', False): + del env.registry.models[cls._name] + env.registry.setup_models(env.cr) + + def _test_get_model_id(self): + self.env.cr.execute( + "SELECT id FROM ir_model WHERE model = %s", (self._name, )) + res = self.env.cr.fetchone() + return res[0] if res else None + + def _test_create_ACL(self, **kw): + model_id = self._test_get_model_id() + if not model_id: + self._reflect() + model_id = self._test_get_model_id() + if model_id: + vals = self._test_ACL_values(model_id) + vals.update(kw) + self.env['ir.model.access'].create(vals) + + def _test_ACL_values(self, model_id): + values = { + 'name': 'Fake ACL for %s' % self._name, + 'model_id': model_id, + 'perm_read': 1, + 'perm_create': 1, + 'perm_write': 1, + 'perm_unlink': 1, + 'active': True, + } + return values + + +class FakeModel(models.Model, TestMixin): + _name = 'fake.model' + _inherit = 'website.published.mixin' + _test_setup_ACL = True + + name = fields.Char() diff --git a/cms_info/tests/test_info_mixin.py b/cms_info/tests/test_info_mixin.py new file mode 100644 index 00000000..6f1ff1eb --- /dev/null +++ b/cms_info/tests/test_info_mixin.py @@ -0,0 +1,97 @@ +# Copyright 2018 Simone Orsi +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +import odoo.tests.common as test_common +from .fake_models import FakeModel + + +class TestInfoMixin(test_common.SavepointCase): + + post_install = True + at_install = False + + TEST_MODELS_KLASSES = [FakeModel, ] + + @classmethod + def setUpClass(cls): + super().setUpClass() + for kls in cls.TEST_MODELS_KLASSES: + kls._test_setup_model(cls.env) + cls.record = cls.env[FakeModel._name].create({'name': 'Foo'}) + user_model = cls.env['res.users'].with_context( + tracking_disable=True, no_reset_password=True) + cls.user1 = user_model.create({ + 'name': 'User 1', + 'login': 'user1', + 'email': 'user1@email.com', + 'groups_id': [(6, 0, [cls.env.ref('base.group_portal').id])] + }) + + @classmethod + def tearDownClass(cls): + for kls in cls.TEST_MODELS_KLASSES: + kls._test_teardown_model(cls.env) + super().tearDownClass() + + def test_create_url(self): + self.assertEqual(self.record.cms_create_url, '/cms/create/fake.model') + + def test_search_url(self): + self.assertEqual(self.record.cms_search_url, '/cms/search/fake.model') + + def test_edit_url(self): + self.assertEqual( + self.record.cms_edit_url, + '/cms/edit/fake.model/%s' % self.record.id) + + def test_is_owner(self): + self.record._test_create_ACL( + groups_id=[(4, self.env.ref('base.group_system').id)] + ) + self.assertTrue(self.record.cms_is_owner()) + self.assertFalse(self.record.sudo(self.user1).cms_is_owner()) + + def test_can_create(self): + self.assertTrue(self.env[FakeModel._name].cms_can_create()) + self.assertFalse( + self.env[FakeModel._name].sudo(self.user1).cms_can_create() + ) + + def test_can_edit(self): + self.record._test_create_ACL( + groups_id=[(4, self.env.ref('base.group_portal').id)], + perm_write=False, + ) + self.assertTrue(self.record.cms_can_edit()) + self.assertFalse(self.record.sudo(self.user1).cms_can_edit()) + + def test_can_publish(self): + # this permission by default is just a proxy to "can edit" + self.record._test_create_ACL( + groups_id=[(4, self.env.ref('base.group_portal').id)], + perm_write=False, + ) + self.assertTrue(self.record.cms_can_publish()) + self.assertFalse(self.record.sudo(self.user1).cms_can_publish()) + + def test_can_delete(self): + self.record._test_create_ACL( + groups_id=[(4, self.env.ref('base.group_portal').id)], + perm_write=False, + perm_unlink=False, + ) + self.assertTrue(self.record.cms_can_delete()) + self.assertFalse(self.record.sudo(self.user1).cms_can_delete()) + + def test_info(self): + info = self.record.cms_info() + keys = ( + 'is_owner', + 'can_edit', + 'can_create', + 'can_publish', + 'can_delete', + 'create_url', + 'edit_url', + 'delete_url', + ) + self.assertEqual(sorted(keys), sorted(info.keys())) From 0a466bb78d91b5eeff96e0c0f438fa4205c14e93 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 9 Aug 2018 15:22:54 +0200 Subject: [PATCH 04/31] cms_info: info dict default to None values --- cms_info/models/website_mixin.py | 32 +++++++++++++++++++++---------- cms_info/tests/test_info_mixin.py | 16 +++++++++++++++- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/cms_info/models/website_mixin.py b/cms_info/models/website_mixin.py index eec62568..04a5c5b4 100644 --- a/cms_info/models/website_mixin.py +++ b/cms_info/models/website_mixin.py @@ -56,16 +56,28 @@ def cms_can_publish(self): # TODO: improve this return self.cms_can_edit() + @api.multi def cms_info(self): - info = { - 'is_owner': self.cms_is_owner(), - 'can_edit': self.cms_can_edit(), - 'can_create': self.cms_can_create(), - 'can_publish': self.cms_can_publish(), - 'can_delete': self.cms_can_delete(), + # do not use `ensure_one` so we can use this on an empty recordset + info = {}.fromkeys(( + 'is_owner', 'can_edit', 'can_create', 'can_publish', + 'can_delete', 'create_url', 'edit_url', 'delete_url', + ), None) + if self: + # we have a record indeed + info.update({ + # make sure it works even on empty recordsets + 'is_owner': self.cms_is_owner() if self else None, + 'can_edit': self.cms_can_edit(), + 'can_publish': self.cms_can_publish(), + 'can_delete': self.cms_can_delete(), + 'edit_url': self.cms_edit_url, + # delete/delete confirm URLs come from `cms_delete_content` + 'delete_url': self.cms_delete_confirm_url, + }) + info.update({ + # class-level info 'create_url': self.cms_create_url, - 'edit_url': self.cms_edit_url, - # delete/delete confirm URLs come from `cms_delete_content` - 'delete_url': self.cms_delete_confirm_url, - } + 'can_create': self.cms_can_create(), + }) return info diff --git a/cms_info/tests/test_info_mixin.py b/cms_info/tests/test_info_mixin.py index 6f1ff1eb..404f817d 100644 --- a/cms_info/tests/test_info_mixin.py +++ b/cms_info/tests/test_info_mixin.py @@ -82,7 +82,7 @@ def test_can_delete(self): self.assertTrue(self.record.cms_can_delete()) self.assertFalse(self.record.sudo(self.user1).cms_can_delete()) - def test_info(self): + def test_info_on_record(self): info = self.record.cms_info() keys = ( 'is_owner', @@ -95,3 +95,17 @@ def test_info(self): 'delete_url', ) self.assertEqual(sorted(keys), sorted(info.keys())) + + def test_info_on_model(self): + info = self.record.browse().cms_info() + keys = ( + 'is_owner', + 'can_edit', + 'can_create', + 'can_publish', + 'can_delete', + 'create_url', + 'edit_url', + 'delete_url', + ) + self.assertEqual(sorted(keys), sorted(info.keys())) From 7d4a8988b523144e696299778a7725aac5fad89d Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Fri, 18 Jan 2019 08:52:03 +0100 Subject: [PATCH 05/31] Bump cms_info 11.0.1.0.1 --- cms_info/CHANGES.rst | 11 +++++++++-- cms_info/__manifest__.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cms_info/CHANGES.rst b/cms_info/CHANGES.rst index e537fbc4..21d9555a 100644 --- a/cms_info/CHANGES.rst +++ b/cms_info/CHANGES.rst @@ -2,11 +2,18 @@ CHANGELOG ========= +11.0.1.0.1 (2019-01-18) +======================= + +**Fixes** + +* Info dict default to None values +* Test coverage 100% + 11.0.1.0.0 (2018-04-27) ======================= -Improvements ------------- +**Improvements** * Initial release \ No newline at end of file diff --git a/cms_info/__manifest__.py b/cms_info/__manifest__.py index 6dcc5fcb..a1c4b905 100644 --- a/cms_info/__manifest__.py +++ b/cms_info/__manifest__.py @@ -5,7 +5,7 @@ "name": "CMS info", "summary": """A set of basic information needed on all published records.""", - "version": "11.0.1.0.0", + "version": "11.0.1.0.1", "category": "Website", "website": "https://github.com/OCA/website-cms", "author": "Camptocamp, Odoo Community Association (OCA)", From 9333e2e86f222931c8e9c12b32620813cdb9dc26 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Wed, 3 Apr 2019 03:31:21 +0000 Subject: [PATCH 06/31] [ADD] icon.png --- cms_info/static/description/icon.png | Bin 0 -> 9455 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 cms_info/static/description/icon.png diff --git a/cms_info/static/description/icon.png b/cms_info/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f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_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 From 589c79d4b859dedc87cefbdb55a6d747e7b5d38c Mon Sep 17 00:00:00 2001 From: Ronald Portier Date: Thu, 8 Aug 2019 08:43:18 +0200 Subject: [PATCH 07/31] [FIX] cms_info test. In ir.model.access it is group_id (singular). --- cms_info/tests/test_info_mixin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cms_info/tests/test_info_mixin.py b/cms_info/tests/test_info_mixin.py index 404f817d..c7885d4f 100644 --- a/cms_info/tests/test_info_mixin.py +++ b/cms_info/tests/test_info_mixin.py @@ -45,7 +45,7 @@ def test_edit_url(self): def test_is_owner(self): self.record._test_create_ACL( - groups_id=[(4, self.env.ref('base.group_system').id)] + group_id=self.env.ref('base.group_portal').id ) self.assertTrue(self.record.cms_is_owner()) self.assertFalse(self.record.sudo(self.user1).cms_is_owner()) @@ -58,7 +58,7 @@ def test_can_create(self): def test_can_edit(self): self.record._test_create_ACL( - groups_id=[(4, self.env.ref('base.group_portal').id)], + group_id=self.env.ref('base.group_portal').id, perm_write=False, ) self.assertTrue(self.record.cms_can_edit()) @@ -67,7 +67,7 @@ def test_can_edit(self): def test_can_publish(self): # this permission by default is just a proxy to "can edit" self.record._test_create_ACL( - groups_id=[(4, self.env.ref('base.group_portal').id)], + group_id=self.env.ref('base.group_portal').id, perm_write=False, ) self.assertTrue(self.record.cms_can_publish()) @@ -75,7 +75,7 @@ def test_can_publish(self): def test_can_delete(self): self.record._test_create_ACL( - groups_id=[(4, self.env.ref('base.group_portal').id)], + group_id=self.env.ref('base.group_portal').id, perm_write=False, perm_unlink=False, ) From 62d9e70e0e07e9b254c10295233c6f2cddd15a30 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Wed, 21 Aug 2019 14:37:21 +0000 Subject: [PATCH 08/31] cms_info 11.0.1.0.2 --- cms_info/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cms_info/__manifest__.py b/cms_info/__manifest__.py index a1c4b905..4d301380 100644 --- a/cms_info/__manifest__.py +++ b/cms_info/__manifest__.py @@ -5,7 +5,7 @@ "name": "CMS info", "summary": """A set of basic information needed on all published records.""", - "version": "11.0.1.0.1", + "version": "11.0.1.0.2", "category": "Website", "website": "https://github.com/OCA/website-cms", "author": "Camptocamp, Odoo Community Association (OCA)", From d587205b695d0f47c59c805b95e47a0b664d3a17 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Sat, 18 Apr 2020 16:16:14 +0200 Subject: [PATCH 09/31] [REF] cms_info: Black python code --- cms_info/__manifest__.py | 8 +--- cms_info/models/website_mixin.py | 69 ++++++++++++++++------------ cms_info/tests/__init__.py | 2 +- cms_info/tests/fake_models.py | 27 +++++------ cms_info/tests/test_info_mixin.py | 74 ++++++++++++++++--------------- 5 files changed, 96 insertions(+), 84 deletions(-) diff --git a/cms_info/__manifest__.py b/cms_info/__manifest__.py index 4d301380..5069e115 100644 --- a/cms_info/__manifest__.py +++ b/cms_info/__manifest__.py @@ -3,16 +3,12 @@ { "name": "CMS info", - "summary": - """A set of basic information needed on all published records.""", + "summary": """A set of basic information needed on all published records.""", "version": "11.0.1.0.2", "category": "Website", "website": "https://github.com/OCA/website-cms", "author": "Camptocamp, Odoo Community Association (OCA)", "license": "LGPL-3", "installable": True, - "depends": [ - 'website', - 'cms_delete_content', - ], + "depends": ["website", "cms_delete_content",], } diff --git a/cms_info/models/website_mixin.py b/cms_info/models/website_mixin.py index 04a5c5b4..44836b63 100644 --- a/cms_info/models/website_mixin.py +++ b/cms_info/models/website_mixin.py @@ -4,26 +4,24 @@ class WebsiteMixin(models.AbstractModel): - _inherit = 'website.published.mixin' + _inherit = "website.published.mixin" @property def cms_create_url(self): - return '/cms/create/{}'.format(self._name) + return "/cms/create/{}".format(self._name) @property def cms_search_url(self): - return '/cms/search/{}'.format(self._name) + return "/cms/search/{}".format(self._name) cms_edit_url = fields.Char( - string='CMS edit URL', - compute='_compute_cms_edit_url', - readonly=True, + string="CMS edit URL", compute="_compute_cms_edit_url", readonly=True, ) @api.multi def _compute_cms_edit_url(self): for item in self: - item.cms_edit_url = '/cms/edit/{}/{}'.format(item._name, item.id) + item.cms_edit_url = "/cms/edit/{}/{}".format(item._name, item.id) @api.multi def cms_is_owner(self, uid=None): @@ -33,7 +31,7 @@ def cms_is_owner(self, uid=None): @api.model def cms_can_create(self): - return self.check_access_rights('create', raise_exception=False) + return self.check_access_rights("create", raise_exception=False) @api.multi def _cms_check_perm(self, mode): @@ -47,10 +45,10 @@ def _cms_check_perm(self, mode): return can def cms_can_edit(self): - return self._cms_check_perm('write') + return self._cms_check_perm("write") def cms_can_delete(self): - return self._cms_check_perm('unlink') + return self._cms_check_perm("unlink") def cms_can_publish(self): # TODO: improve this @@ -59,25 +57,38 @@ def cms_can_publish(self): @api.multi def cms_info(self): # do not use `ensure_one` so we can use this on an empty recordset - info = {}.fromkeys(( - 'is_owner', 'can_edit', 'can_create', 'can_publish', - 'can_delete', 'create_url', 'edit_url', 'delete_url', - ), None) + info = {}.fromkeys( + ( + "is_owner", + "can_edit", + "can_create", + "can_publish", + "can_delete", + "create_url", + "edit_url", + "delete_url", + ), + None, + ) if self: # we have a record indeed - info.update({ - # make sure it works even on empty recordsets - 'is_owner': self.cms_is_owner() if self else None, - 'can_edit': self.cms_can_edit(), - 'can_publish': self.cms_can_publish(), - 'can_delete': self.cms_can_delete(), - 'edit_url': self.cms_edit_url, - # delete/delete confirm URLs come from `cms_delete_content` - 'delete_url': self.cms_delete_confirm_url, - }) - info.update({ - # class-level info - 'create_url': self.cms_create_url, - 'can_create': self.cms_can_create(), - }) + info.update( + { + # make sure it works even on empty recordsets + "is_owner": self.cms_is_owner() if self else None, + "can_edit": self.cms_can_edit(), + "can_publish": self.cms_can_publish(), + "can_delete": self.cms_can_delete(), + "edit_url": self.cms_edit_url, + # delete/delete confirm URLs come from `cms_delete_content` + "delete_url": self.cms_delete_confirm_url, + } + ) + info.update( + { + # class-level info + "create_url": self.cms_create_url, + "can_create": self.cms_can_create(), + } + ) return info diff --git a/cms_info/tests/__init__.py b/cms_info/tests/__init__.py index b9617100..9dc826c7 100644 --- a/cms_info/tests/__init__.py +++ b/cms_info/tests/__init__.py @@ -1 +1 @@ -from . import test_info_mixin \ No newline at end of file +from . import test_info_mixin diff --git a/cms_info/tests/fake_models.py b/cms_info/tests/fake_models.py index 083e77b4..dbbac1a6 100644 --- a/cms_info/tests/fake_models.py +++ b/cms_info/tests/fake_models.py @@ -18,19 +18,20 @@ def _test_setup_model(cls, env): env.registry.setup_models(env.cr) ctx = dict(env.context, update_custom_fields=True) if cls._test_setup_gen_xid: - ctx['module'] = cls._module + ctx["module"] = cls._module env.registry.init_models(env.cr, [cls._name], ctx) @classmethod def _test_teardown_model(cls, env): """Deinitialize it.""" - if not getattr(cls, '_test_teardown_no_delete', False): + if not getattr(cls, "_test_teardown_no_delete", False): del env.registry.models[cls._name] env.registry.setup_models(env.cr) def _test_get_model_id(self): self.env.cr.execute( - "SELECT id FROM ir_model WHERE model = %s", (self._name, )) + "SELECT id FROM ir_model WHERE model = %s", (self._name,) + ) res = self.env.cr.fetchone() return res[0] if res else None @@ -42,24 +43,24 @@ def _test_create_ACL(self, **kw): if model_id: vals = self._test_ACL_values(model_id) vals.update(kw) - self.env['ir.model.access'].create(vals) + self.env["ir.model.access"].create(vals) def _test_ACL_values(self, model_id): values = { - 'name': 'Fake ACL for %s' % self._name, - 'model_id': model_id, - 'perm_read': 1, - 'perm_create': 1, - 'perm_write': 1, - 'perm_unlink': 1, - 'active': True, + "name": "Fake ACL for %s" % self._name, + "model_id": model_id, + "perm_read": 1, + "perm_create": 1, + "perm_write": 1, + "perm_unlink": 1, + "active": True, } return values class FakeModel(models.Model, TestMixin): - _name = 'fake.model' - _inherit = 'website.published.mixin' + _name = "fake.model" + _inherit = "website.published.mixin" _test_setup_ACL = True name = fields.Char() diff --git a/cms_info/tests/test_info_mixin.py b/cms_info/tests/test_info_mixin.py index c7885d4f..195da549 100644 --- a/cms_info/tests/test_info_mixin.py +++ b/cms_info/tests/test_info_mixin.py @@ -9,22 +9,27 @@ class TestInfoMixin(test_common.SavepointCase): post_install = True at_install = False - TEST_MODELS_KLASSES = [FakeModel, ] + TEST_MODELS_KLASSES = [ + FakeModel, + ] @classmethod def setUpClass(cls): super().setUpClass() for kls in cls.TEST_MODELS_KLASSES: kls._test_setup_model(cls.env) - cls.record = cls.env[FakeModel._name].create({'name': 'Foo'}) - user_model = cls.env['res.users'].with_context( - tracking_disable=True, no_reset_password=True) - cls.user1 = user_model.create({ - 'name': 'User 1', - 'login': 'user1', - 'email': 'user1@email.com', - 'groups_id': [(6, 0, [cls.env.ref('base.group_portal').id])] - }) + cls.record = cls.env[FakeModel._name].create({"name": "Foo"}) + user_model = cls.env["res.users"].with_context( + tracking_disable=True, no_reset_password=True + ) + cls.user1 = user_model.create( + { + "name": "User 1", + "login": "user1", + "email": "user1@email.com", + "groups_id": [(6, 0, [cls.env.ref("base.group_portal").id])], + } + ) @classmethod def tearDownClass(cls): @@ -33,19 +38,20 @@ def tearDownClass(cls): super().tearDownClass() def test_create_url(self): - self.assertEqual(self.record.cms_create_url, '/cms/create/fake.model') + self.assertEqual(self.record.cms_create_url, "/cms/create/fake.model") def test_search_url(self): - self.assertEqual(self.record.cms_search_url, '/cms/search/fake.model') + self.assertEqual(self.record.cms_search_url, "/cms/search/fake.model") def test_edit_url(self): self.assertEqual( self.record.cms_edit_url, - '/cms/edit/fake.model/%s' % self.record.id) + "/cms/edit/fake.model/%s" % self.record.id, + ) def test_is_owner(self): self.record._test_create_ACL( - group_id=self.env.ref('base.group_portal').id + group_id=self.env.ref("base.group_portal").id ) self.assertTrue(self.record.cms_is_owner()) self.assertFalse(self.record.sudo(self.user1).cms_is_owner()) @@ -58,8 +64,7 @@ def test_can_create(self): def test_can_edit(self): self.record._test_create_ACL( - group_id=self.env.ref('base.group_portal').id, - perm_write=False, + group_id=self.env.ref("base.group_portal").id, perm_write=False, ) self.assertTrue(self.record.cms_can_edit()) self.assertFalse(self.record.sudo(self.user1).cms_can_edit()) @@ -67,15 +72,14 @@ def test_can_edit(self): def test_can_publish(self): # this permission by default is just a proxy to "can edit" self.record._test_create_ACL( - group_id=self.env.ref('base.group_portal').id, - perm_write=False, + group_id=self.env.ref("base.group_portal").id, perm_write=False, ) self.assertTrue(self.record.cms_can_publish()) self.assertFalse(self.record.sudo(self.user1).cms_can_publish()) def test_can_delete(self): self.record._test_create_ACL( - group_id=self.env.ref('base.group_portal').id, + group_id=self.env.ref("base.group_portal").id, perm_write=False, perm_unlink=False, ) @@ -85,27 +89,27 @@ def test_can_delete(self): def test_info_on_record(self): info = self.record.cms_info() keys = ( - 'is_owner', - 'can_edit', - 'can_create', - 'can_publish', - 'can_delete', - 'create_url', - 'edit_url', - 'delete_url', + "is_owner", + "can_edit", + "can_create", + "can_publish", + "can_delete", + "create_url", + "edit_url", + "delete_url", ) self.assertEqual(sorted(keys), sorted(info.keys())) def test_info_on_model(self): info = self.record.browse().cms_info() keys = ( - 'is_owner', - 'can_edit', - 'can_create', - 'can_publish', - 'can_delete', - 'create_url', - 'edit_url', - 'delete_url', + "is_owner", + "can_edit", + "can_create", + "can_publish", + "can_delete", + "create_url", + "edit_url", + "delete_url", ) self.assertEqual(sorted(keys), sorted(info.keys())) From a87838c925e4cf77e8024275904ce840c8021b75 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Sat, 18 Apr 2020 16:16:14 +0200 Subject: [PATCH 10/31] [MIG] cms_info: Migration to 13.0 --- cms_info/__manifest__.py | 2 +- cms_info/models/website_mixin.py | 4 ---- cms_info/tests/test_info_mixin.py | 10 +++++----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/cms_info/__manifest__.py b/cms_info/__manifest__.py index 5069e115..b7567439 100644 --- a/cms_info/__manifest__.py +++ b/cms_info/__manifest__.py @@ -4,7 +4,7 @@ { "name": "CMS info", "summary": """A set of basic information needed on all published records.""", - "version": "11.0.1.0.2", + "version": "13.0.1.0.0", "category": "Website", "website": "https://github.com/OCA/website-cms", "author": "Camptocamp, Odoo Community Association (OCA)", diff --git a/cms_info/models/website_mixin.py b/cms_info/models/website_mixin.py index 44836b63..1dce12dd 100644 --- a/cms_info/models/website_mixin.py +++ b/cms_info/models/website_mixin.py @@ -18,12 +18,10 @@ def cms_search_url(self): string="CMS edit URL", compute="_compute_cms_edit_url", readonly=True, ) - @api.multi def _compute_cms_edit_url(self): for item in self: item.cms_edit_url = "/cms/edit/{}/{}".format(item._name, item.id) - @api.multi def cms_is_owner(self, uid=None): self.ensure_one() uid = uid or self.env.user.id @@ -33,7 +31,6 @@ def cms_is_owner(self, uid=None): def cms_can_create(self): return self.check_access_rights("create", raise_exception=False) - @api.multi def _cms_check_perm(self, mode): self.ensure_one() try: @@ -54,7 +51,6 @@ def cms_can_publish(self): # TODO: improve this return self.cms_can_edit() - @api.multi def cms_info(self): # do not use `ensure_one` so we can use this on an empty recordset info = {}.fromkeys( diff --git a/cms_info/tests/test_info_mixin.py b/cms_info/tests/test_info_mixin.py index 195da549..d25da112 100644 --- a/cms_info/tests/test_info_mixin.py +++ b/cms_info/tests/test_info_mixin.py @@ -54,12 +54,12 @@ def test_is_owner(self): group_id=self.env.ref("base.group_portal").id ) self.assertTrue(self.record.cms_is_owner()) - self.assertFalse(self.record.sudo(self.user1).cms_is_owner()) + self.assertFalse(self.record.with_user(self.user1).cms_is_owner()) def test_can_create(self): self.assertTrue(self.env[FakeModel._name].cms_can_create()) self.assertFalse( - self.env[FakeModel._name].sudo(self.user1).cms_can_create() + self.env[FakeModel._name].with_user(self.user1).cms_can_create() ) def test_can_edit(self): @@ -67,7 +67,7 @@ def test_can_edit(self): group_id=self.env.ref("base.group_portal").id, perm_write=False, ) self.assertTrue(self.record.cms_can_edit()) - self.assertFalse(self.record.sudo(self.user1).cms_can_edit()) + self.assertFalse(self.record.with_user(self.user1).cms_can_edit()) def test_can_publish(self): # this permission by default is just a proxy to "can edit" @@ -75,7 +75,7 @@ def test_can_publish(self): group_id=self.env.ref("base.group_portal").id, perm_write=False, ) self.assertTrue(self.record.cms_can_publish()) - self.assertFalse(self.record.sudo(self.user1).cms_can_publish()) + self.assertFalse(self.record.with_user(self.user1).cms_can_publish()) def test_can_delete(self): self.record._test_create_ACL( @@ -84,7 +84,7 @@ def test_can_delete(self): perm_unlink=False, ) self.assertTrue(self.record.cms_can_delete()) - self.assertFalse(self.record.sudo(self.user1).cms_can_delete()) + self.assertFalse(self.record.with_user(self.user1).cms_can_delete()) def test_info_on_record(self): info = self.record.cms_info() From ce702c79e00e4889b23c320a8660406c4834a4de Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Sat, 18 Apr 2020 18:40:32 +0200 Subject: [PATCH 11/31] [REF] cms_delete_content: Black python code --- cms_info/models/cms_mixin.py | 123 +++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 cms_info/models/cms_mixin.py diff --git a/cms_info/models/cms_mixin.py b/cms_info/models/cms_mixin.py new file mode 100644 index 00000000..8238c1c9 --- /dev/null +++ b/cms_info/models/cms_mixin.py @@ -0,0 +1,123 @@ +# Copyright 2018 Simone Orsi (Camptocamp) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). +from odoo import models, api, exceptions, fields + + +class CMSInfoMixin(models.AbstractModel): + _inherit = "cms.info.mixin" + + @property + def cms_create_url(self): + return "/cms/create/{}".format(self._name) + + @property + def cms_search_url(self): + return "/cms/search/{}".format(self._name) + + @property + def cms_edit_url_base(self): + return "/cms/delete/{}".format(self._name) + + @property + def cms_delete_url_base(self): + return "/cms/delete/{}".format(self._name) + + @property + def cms_after_delete_url(self): + return '/' + + cms_edit_url = fields.Char( + string="CMS edit URL", compute="_compute_cms_edit_url", readonly=True, + ) + + cms_delete_url = fields.Char( + string='CMS delete URL', + compute='_compute_cms_delete_url', + readonly=True, + ) + + cms_delete_confirm_url = fields.Char( + string='CMS delete confirm URL', + compute='_compute_cms_delete_url', + readonly=True, + ) + + def _compute_cms_edit_url(self): + base_url = self.cms_edit_url_base + for item in self: + item.cms_edit_url = "{}/{}".format(base_url, item.id) + + @api.multi + def _compute_cms_delete_url(self): + base_url = self.cms_delete_url_base + for item in self: + item.update({ + "cms_delete_url": '{}/{}'.format(base_url, item.id), + "cms_delete_confirm_url": '{}/{}/confirm'.format(base_url, item.id), + }) + + def cms_is_owner(self, uid=None): + self.ensure_one() + uid = uid or self.env.user.id + return self.create_uid.id == uid + + @api.model + def cms_can_create(self): + return self.check_access_rights("create", raise_exception=False) + + def _cms_check_perm(self, mode): + self.ensure_one() + try: + self.check_access_rights(mode) + self.check_access_rule(mode) + can = True + except exceptions.AccessError: + can = False + return can + + def cms_can_edit(self): + return self._cms_check_perm("write") + + def cms_can_delete(self): + return self._cms_check_perm("unlink") + + def cms_can_publish(self): + # TODO: improve this + return self.cms_can_edit() + + def cms_info(self): + # do not use `ensure_one` so we can use this on an empty recordset + info = {}.fromkeys( + ( + "is_owner", + "can_edit", + "can_create", + "can_publish", + "can_delete", + "create_url", + "edit_url", + "delete_url", + ), + None, + ) + if self: + # we have a record indeed + info.update( + { + # make sure it works even on empty recordsets + "is_owner": self.cms_is_owner() if self else None, + "can_edit": self.cms_can_edit(), + "can_publish": self.cms_can_publish(), + "can_delete": self.cms_can_delete(), + "edit_url": self.cms_edit_url, + "delete_url": self.cms_delete_confirm_url, + } + ) + info.update( + { + # class-level info + "create_url": self.cms_create_url, + "can_create": self.cms_can_create(), + } + ) + return info From 320e5b97049c21dd48f029a8074812a5ccaafb86 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Sat, 18 Apr 2020 19:01:33 +0200 Subject: [PATCH 12/31] cms_delete_content depends on cms_info cms_info is the base module, cms_delete_content must depend on it, not the other way around --- cms_info/__manifest__.py | 5 +- cms_info/models/__init__.py | 1 + cms_info/models/cms_mixin.py | 5 +- cms_info/models/website_mixin.py | 92 +++---------------------------- cms_info/tests/test_info_mixin.py | 14 +++++ 5 files changed, 28 insertions(+), 89 deletions(-) diff --git a/cms_info/__manifest__.py b/cms_info/__manifest__.py index b7567439..354a2144 100644 --- a/cms_info/__manifest__.py +++ b/cms_info/__manifest__.py @@ -10,5 +10,8 @@ "author": "Camptocamp, Odoo Community Association (OCA)", "license": "LGPL-3", "installable": True, - "depends": ["website", "cms_delete_content",], + # TODO: think about make cms stuff independent from `website`. + # If you want to use these features in portal only it shouldn't be required + # to install `website`. + "depends": ["website", ], } diff --git a/cms_info/models/__init__.py b/cms_info/models/__init__.py index bdd8436d..5b8657bf 100644 --- a/cms_info/models/__init__.py +++ b/cms_info/models/__init__.py @@ -1 +1,2 @@ +from . import cms_mixin from . import website_mixin diff --git a/cms_info/models/cms_mixin.py b/cms_info/models/cms_mixin.py index 8238c1c9..d36f62f9 100644 --- a/cms_info/models/cms_mixin.py +++ b/cms_info/models/cms_mixin.py @@ -4,7 +4,7 @@ class CMSInfoMixin(models.AbstractModel): - _inherit = "cms.info.mixin" + _name = "cms.info.mixin" @property def cms_create_url(self): @@ -16,7 +16,7 @@ def cms_search_url(self): @property def cms_edit_url_base(self): - return "/cms/delete/{}".format(self._name) + return "/cms/edit/{}".format(self._name) @property def cms_delete_url_base(self): @@ -47,7 +47,6 @@ def _compute_cms_edit_url(self): for item in self: item.cms_edit_url = "{}/{}".format(base_url, item.id) - @api.multi def _compute_cms_delete_url(self): base_url = self.cms_delete_url_base for item in self: diff --git a/cms_info/models/website_mixin.py b/cms_info/models/website_mixin.py index 1dce12dd..b81f4c9b 100644 --- a/cms_info/models/website_mixin.py +++ b/cms_info/models/website_mixin.py @@ -1,90 +1,12 @@ # Copyright 2018 Simone Orsi (Camptocamp) # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). -from odoo import models, api, exceptions, fields +from odoo import models class WebsiteMixin(models.AbstractModel): - _inherit = "website.published.mixin" - - @property - def cms_create_url(self): - return "/cms/create/{}".format(self._name) - - @property - def cms_search_url(self): - return "/cms/search/{}".format(self._name) - - cms_edit_url = fields.Char( - string="CMS edit URL", compute="_compute_cms_edit_url", readonly=True, - ) - - def _compute_cms_edit_url(self): - for item in self: - item.cms_edit_url = "/cms/edit/{}/{}".format(item._name, item.id) - - def cms_is_owner(self, uid=None): - self.ensure_one() - uid = uid or self.env.user.id - return self.create_uid.id == uid - - @api.model - def cms_can_create(self): - return self.check_access_rights("create", raise_exception=False) - - def _cms_check_perm(self, mode): - self.ensure_one() - try: - self.check_access_rights(mode) - self.check_access_rule(mode) - can = True - except exceptions.AccessError: - can = False - return can - - def cms_can_edit(self): - return self._cms_check_perm("write") - - def cms_can_delete(self): - return self._cms_check_perm("unlink") - - def cms_can_publish(self): - # TODO: improve this - return self.cms_can_edit() - - def cms_info(self): - # do not use `ensure_one` so we can use this on an empty recordset - info = {}.fromkeys( - ( - "is_owner", - "can_edit", - "can_create", - "can_publish", - "can_delete", - "create_url", - "edit_url", - "delete_url", - ), - None, - ) - if self: - # we have a record indeed - info.update( - { - # make sure it works even on empty recordsets - "is_owner": self.cms_is_owner() if self else None, - "can_edit": self.cms_can_edit(), - "can_publish": self.cms_can_publish(), - "can_delete": self.cms_can_delete(), - "edit_url": self.cms_edit_url, - # delete/delete confirm URLs come from `cms_delete_content` - "delete_url": self.cms_delete_confirm_url, - } - ) - info.update( - { - # class-level info - "create_url": self.cms_create_url, - "can_create": self.cms_can_create(), - } - ) - return info + _name = "website.published.mixin" + # Apply cms mixin to website published one + _inherit = [ + "website.published.mixin", + "cms.info.mixin" + ] diff --git a/cms_info/tests/test_info_mixin.py b/cms_info/tests/test_info_mixin.py index d25da112..cdea330f 100644 --- a/cms_info/tests/test_info_mixin.py +++ b/cms_info/tests/test_info_mixin.py @@ -49,6 +49,20 @@ def test_edit_url(self): "/cms/edit/fake.model/%s" % self.record.id, ) + def test_delete_url(self): + self.assertEqual( + self.record.cms_delete_url, + "/cms/delete/fake.model/%s" % self.record.id, + ) + self.assertEqual( + self.record.cms_delete_confirm_url, + "/cms/delete/fake.model/%s/confirm" % self.record.id, + ) + self.assertEqual( + self.record.cms_after_delete_url, + "/", + ) + def test_is_owner(self): self.record._test_create_ACL( group_id=self.env.ref("base.group_portal").id From b425b919fd351b98e9384de406f396cf6df0302c Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Sun, 19 Apr 2020 16:31:15 +0200 Subject: [PATCH 13/31] cms_info: refactor tests w/ fake model loader --- cms_info/tests/fake_models.py | 56 +-------------- cms_info/tests/test_info_mixin.py | 111 ++++++++++++++++++------------ 2 files changed, 69 insertions(+), 98 deletions(-) diff --git a/cms_info/tests/fake_models.py b/cms_info/tests/fake_models.py index dbbac1a6..48c3e770 100644 --- a/cms_info/tests/fake_models.py +++ b/cms_info/tests/fake_models.py @@ -4,61 +4,7 @@ from odoo import fields, models -class TestMixin(object): - - # generate xmlids - # this is needed if you want to load data tied to a test model via xid - _test_setup_gen_xid = False - _test_teardown_no_delete = False - - @classmethod - def _test_setup_model(cls, env): - """Initialize it.""" - cls._build_model(env.registry, env.cr) - env.registry.setup_models(env.cr) - ctx = dict(env.context, update_custom_fields=True) - if cls._test_setup_gen_xid: - ctx["module"] = cls._module - env.registry.init_models(env.cr, [cls._name], ctx) - - @classmethod - def _test_teardown_model(cls, env): - """Deinitialize it.""" - if not getattr(cls, "_test_teardown_no_delete", False): - del env.registry.models[cls._name] - env.registry.setup_models(env.cr) - - def _test_get_model_id(self): - self.env.cr.execute( - "SELECT id FROM ir_model WHERE model = %s", (self._name,) - ) - res = self.env.cr.fetchone() - return res[0] if res else None - - def _test_create_ACL(self, **kw): - model_id = self._test_get_model_id() - if not model_id: - self._reflect() - model_id = self._test_get_model_id() - if model_id: - vals = self._test_ACL_values(model_id) - vals.update(kw) - self.env["ir.model.access"].create(vals) - - def _test_ACL_values(self, model_id): - values = { - "name": "Fake ACL for %s" % self._name, - "model_id": model_id, - "perm_read": 1, - "perm_create": 1, - "perm_write": 1, - "perm_unlink": 1, - "active": True, - } - return values - - -class FakeModel(models.Model, TestMixin): +class FakeModel(models.TransientModel): _name = "fake.model" _inherit = "website.published.mixin" _test_setup_ACL = True diff --git a/cms_info/tests/test_info_mixin.py b/cms_info/tests/test_info_mixin.py index cdea330f..d528cf98 100644 --- a/cms_info/tests/test_info_mixin.py +++ b/cms_info/tests/test_info_mixin.py @@ -1,7 +1,10 @@ # Copyright 2018 Simone Orsi # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +import mock +from odoo_test_helper import FakeModelLoader + import odoo.tests.common as test_common -from .fake_models import FakeModel +from odoo import exceptions class TestInfoMixin(test_common.SavepointCase): @@ -9,16 +12,16 @@ class TestInfoMixin(test_common.SavepointCase): post_install = True at_install = False - TEST_MODELS_KLASSES = [ - FakeModel, - ] - @classmethod def setUpClass(cls): super().setUpClass() - for kls in cls.TEST_MODELS_KLASSES: - kls._test_setup_model(cls.env) - cls.record = cls.env[FakeModel._name].create({"name": "Foo"}) + from .fake_models import FakeModel + + cls.loader = FakeModelLoader(cls.env, cls.__module__) + cls.loader.backup_registry() + cls.loader.update_registry((FakeModel,)) + cls.model = cls.env[FakeModel._name] + cls.record = cls.model.create({"name": "Foo"}) user_model = cls.env["res.users"].with_context( tracking_disable=True, no_reset_password=True ) @@ -33,8 +36,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - for kls in cls.TEST_MODELS_KLASSES: - kls._test_teardown_model(cls.env) + cls.loader.restore_registry() super().tearDownClass() def test_create_url(self): @@ -45,60 +47,83 @@ def test_search_url(self): def test_edit_url(self): self.assertEqual( - self.record.cms_edit_url, - "/cms/edit/fake.model/%s" % self.record.id, + self.record.cms_edit_url, "/cms/edit/fake.model/%s" % self.record.id, ) def test_delete_url(self): self.assertEqual( - self.record.cms_delete_url, - "/cms/delete/fake.model/%s" % self.record.id, + self.record.cms_delete_url, "/cms/delete/fake.model/%s" % self.record.id, ) self.assertEqual( self.record.cms_delete_confirm_url, "/cms/delete/fake.model/%s/confirm" % self.record.id, ) self.assertEqual( - self.record.cms_after_delete_url, - "/", + self.record.cms_after_delete_url, "/", ) def test_is_owner(self): - self.record._test_create_ACL( - group_id=self.env.ref("base.group_portal").id - ) self.assertTrue(self.record.cms_is_owner()) self.assertFalse(self.record.with_user(self.user1).cms_is_owner()) + # No special ACL nor record rule. + # Rely on the fact that access rights checks are called in the right way + # and depending on their result we get proper cms info. def test_can_create(self): - self.assertTrue(self.env[FakeModel._name].cms_can_create()) - self.assertFalse( - self.env[FakeModel._name].with_user(self.user1).cms_can_create() - ) + path_rights = "odoo.models.Model.check_access_rights" + with mock.patch(path_rights) as mocked: + mocked.return_value = False + self.assertFalse(self.model.with_user(self.user1).cms_can_create()) + mocked.assert_called_with("create", raise_exception=False) + mocked.return_value = True + self.assertTrue(self.model.with_user(self.user1).cms_can_create()) + mocked.assert_called_with("create", raise_exception=False) + + def _test_can(self, record, mode, handler): + path_rights = "odoo.models.Model.check_access_rights" + path_rule = "odoo.models.Model.check_access_rule" + with mock.patch(path_rights) as mocked_rights, mock.patch( + path_rule + ) as mocked_rule: + # test false + mocked_rights.side_effect = exceptions.AccessError("BAM!") + mocked_rule.side_effect = exceptions.AccessError("BAM!") + self.assertFalse(handler()) + mocked_rights.assert_called_with(mode) + # failed on ACL check, no call here + mocked_rule.assert_not_called() + + with mock.patch(path_rights) as mocked_rights, mock.patch( + path_rule + ) as mocked_rule: + # test true only rights + mocked_rights.return_value = True + mocked_rule.side_effect = exceptions.AccessError("BAM!") + self.assertFalse(handler()) + mocked_rights.assert_called_with(mode) + mocked_rule.assert_called_with(mode) + + with mock.patch(path_rights) as mocked_rights, mock.patch( + path_rule + ) as mocked_rule: + # test true + mocked_rights.return_value = True + mocked_rule.return_value = True + self.assertTrue(handler()) + mocked_rights.assert_called_with(mode) + mocked_rule.assert_called_with(mode) def test_can_edit(self): - self.record._test_create_ACL( - group_id=self.env.ref("base.group_portal").id, perm_write=False, - ) - self.assertTrue(self.record.cms_can_edit()) - self.assertFalse(self.record.with_user(self.user1).cms_can_edit()) - - def test_can_publish(self): - # this permission by default is just a proxy to "can edit" - self.record._test_create_ACL( - group_id=self.env.ref("base.group_portal").id, perm_write=False, - ) - self.assertTrue(self.record.cms_can_publish()) - self.assertFalse(self.record.with_user(self.user1).cms_can_publish()) + record = self.record.with_user(self.user1) + self._test_can(record, "write", record.cms_can_edit) def test_can_delete(self): - self.record._test_create_ACL( - group_id=self.env.ref("base.group_portal").id, - perm_write=False, - perm_unlink=False, - ) - self.assertTrue(self.record.cms_can_delete()) - self.assertFalse(self.record.with_user(self.user1).cms_can_delete()) + record = self.record.with_user(self.user1) + self._test_can(record, "unlink", record.cms_can_delete) + + def test_can_publish(self): + record = self.record.with_user(self.user1) + self._test_can(record, "write", record.cms_can_publish) def test_info_on_record(self): info = self.record.cms_info() From 603da53f04d3ab273abeae1beb7aaf32aef83d9f Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Sun, 19 Apr 2020 16:32:27 +0200 Subject: [PATCH 14/31] cms_info: apply pre-commit --- cms_info/CHANGES.rst | 2 +- cms_info/__manifest__.py | 2 +- cms_info/models/cms_mixin.py | 26 +++++++++++++------------- cms_info/models/website_mixin.py | 5 +---- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/cms_info/CHANGES.rst b/cms_info/CHANGES.rst index 21d9555a..3a078cb0 100644 --- a/cms_info/CHANGES.rst +++ b/cms_info/CHANGES.rst @@ -16,4 +16,4 @@ CHANGELOG **Improvements** -* Initial release \ No newline at end of file +* Initial release diff --git a/cms_info/__manifest__.py b/cms_info/__manifest__.py index 354a2144..da926905 100644 --- a/cms_info/__manifest__.py +++ b/cms_info/__manifest__.py @@ -13,5 +13,5 @@ # TODO: think about make cms stuff independent from `website`. # If you want to use these features in portal only it shouldn't be required # to install `website`. - "depends": ["website", ], + "depends": ["website"], } diff --git a/cms_info/models/cms_mixin.py b/cms_info/models/cms_mixin.py index d36f62f9..dc6f29aa 100644 --- a/cms_info/models/cms_mixin.py +++ b/cms_info/models/cms_mixin.py @@ -1,6 +1,6 @@ # Copyright 2018 Simone Orsi (Camptocamp) # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). -from odoo import models, api, exceptions, fields +from odoo import api, exceptions, fields, models class CMSInfoMixin(models.AbstractModel): @@ -21,24 +21,22 @@ def cms_edit_url_base(self): @property def cms_delete_url_base(self): return "/cms/delete/{}".format(self._name) - + @property def cms_after_delete_url(self): - return '/' + return "/" cms_edit_url = fields.Char( string="CMS edit URL", compute="_compute_cms_edit_url", readonly=True, ) - + cms_delete_url = fields.Char( - string='CMS delete URL', - compute='_compute_cms_delete_url', - readonly=True, + string="CMS delete URL", compute="_compute_cms_delete_url", readonly=True, ) cms_delete_confirm_url = fields.Char( - string='CMS delete confirm URL', - compute='_compute_cms_delete_url', + string="CMS delete confirm URL", + compute="_compute_cms_delete_url", readonly=True, ) @@ -50,10 +48,12 @@ def _compute_cms_edit_url(self): def _compute_cms_delete_url(self): base_url = self.cms_delete_url_base for item in self: - item.update({ - "cms_delete_url": '{}/{}'.format(base_url, item.id), - "cms_delete_confirm_url": '{}/{}/confirm'.format(base_url, item.id), - }) + item.update( + { + "cms_delete_url": "{}/{}".format(base_url, item.id), + "cms_delete_confirm_url": "{}/{}/confirm".format(base_url, item.id), + } + ) def cms_is_owner(self, uid=None): self.ensure_one() diff --git a/cms_info/models/website_mixin.py b/cms_info/models/website_mixin.py index b81f4c9b..73dbb74b 100644 --- a/cms_info/models/website_mixin.py +++ b/cms_info/models/website_mixin.py @@ -6,7 +6,4 @@ class WebsiteMixin(models.AbstractModel): _name = "website.published.mixin" # Apply cms mixin to website published one - _inherit = [ - "website.published.mixin", - "cms.info.mixin" - ] + _inherit = ["website.published.mixin", "cms.info.mixin"] From a3e2c2ce8bf09e30ea01389806086c741f32e911 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Sat, 25 Apr 2020 15:28:23 +0200 Subject: [PATCH 15/31] cms_info: clean up warnings, unify url makers --- cms_info/models/cms_mixin.py | 15 +++++++++++---- cms_info/tests/fake_models.py | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cms_info/models/cms_mixin.py b/cms_info/models/cms_mixin.py index dc6f29aa..57d8bd83 100644 --- a/cms_info/models/cms_mixin.py +++ b/cms_info/models/cms_mixin.py @@ -4,23 +4,30 @@ class CMSInfoMixin(models.AbstractModel): + """Provide core information for CMS records. + """ + _name = "cms.info.mixin" + _description = "CMS Info mixin" + + def _cms_make_url(self, action): + return "/cms/{}/{}".format(action, self._name) @property def cms_create_url(self): - return "/cms/create/{}".format(self._name) + return self._cms_make_url("create") @property def cms_search_url(self): - return "/cms/search/{}".format(self._name) + return self._cms_make_url("search") @property def cms_edit_url_base(self): - return "/cms/edit/{}".format(self._name) + return self._cms_make_url("edit") @property def cms_delete_url_base(self): - return "/cms/delete/{}".format(self._name) + return self._cms_make_url("delete") @property def cms_after_delete_url(self): diff --git a/cms_info/tests/fake_models.py b/cms_info/tests/fake_models.py index 48c3e770..0a85ea28 100644 --- a/cms_info/tests/fake_models.py +++ b/cms_info/tests/fake_models.py @@ -6,7 +6,7 @@ class FakeModel(models.TransientModel): _name = "fake.model" - _inherit = "website.published.mixin" - _test_setup_ACL = True + _description = "Testing fake model" + _inherit = "cms.info.mixin" name = fields.Char() From 5c40c6e585f8af4679afd2c0f13bc9fa7007bd99 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Sun, 26 Apr 2020 12:01:29 +0200 Subject: [PATCH 16/31] cms_info: readme fragment + towncrier changelog --- cms_info/CHANGES.rst | 19 ------------ cms_info/readme/CONTRIBUTORS.rst | 1 + cms_info/readme/DESCRIPTION.rst | 2 ++ cms_info/readme/HISTORY.rst | 15 +++++++++ cms_info/readme/ROADMAP.rst | 3 ++ cms_info/readme/USAGE.rst | 38 +++++++++++++++++++++++ cms_info/readme/newsfragments/111.feature | 1 + 7 files changed, 60 insertions(+), 19 deletions(-) delete mode 100644 cms_info/CHANGES.rst create mode 100644 cms_info/readme/CONTRIBUTORS.rst create mode 100644 cms_info/readme/DESCRIPTION.rst create mode 100644 cms_info/readme/HISTORY.rst create mode 100644 cms_info/readme/ROADMAP.rst create mode 100644 cms_info/readme/USAGE.rst create mode 100644 cms_info/readme/newsfragments/111.feature diff --git a/cms_info/CHANGES.rst b/cms_info/CHANGES.rst deleted file mode 100644 index 3a078cb0..00000000 --- a/cms_info/CHANGES.rst +++ /dev/null @@ -1,19 +0,0 @@ -========= -CHANGELOG -========= - -11.0.1.0.1 (2019-01-18) -======================= - -**Fixes** - -* Info dict default to None values -* Test coverage 100% - - -11.0.1.0.0 (2018-04-27) -======================= - -**Improvements** - -* Initial release diff --git a/cms_info/readme/CONTRIBUTORS.rst b/cms_info/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..f1c71bce --- /dev/null +++ b/cms_info/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Simone Orsi diff --git a/cms_info/readme/DESCRIPTION.rst b/cms_info/readme/DESCRIPTION.rst new file mode 100644 index 00000000..a7ef6eea --- /dev/null +++ b/cms_info/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Provide basic information for website records / models via `website.published.mixin`. +This module is meant to be used as a base to build your own CMS. diff --git a/cms_info/readme/HISTORY.rst b/cms_info/readme/HISTORY.rst new file mode 100644 index 00000000..f362ecde --- /dev/null +++ b/cms_info/readme/HISTORY.rst @@ -0,0 +1,15 @@ +11.0.1.0.1 (2019-01-18) +~~~~~~~~~~~~~~~~~~~~~~~ + +**Fixes** + +- Info dict default to None values +- Test coverage 100% + + +11.0.1.0.0 (2018-04-27) +~~~~~~~~~~~~~~~~~~~~~~~ + +**Improvements** + +- Initial release diff --git a/cms_info/readme/ROADMAP.rst b/cms_info/readme/ROADMAP.rst new file mode 100644 index 00000000..a122bbd7 --- /dev/null +++ b/cms_info/readme/ROADMAP.rst @@ -0,0 +1,3 @@ + +Get rid of `website` dependency and move `website.published.mixin` integration +to a glue module. diff --git a/cms_info/readme/USAGE.rst b/cms_info/readme/USAGE.rst new file mode 100644 index 00000000..d9315c89 --- /dev/null +++ b/cms_info/readme/USAGE.rst @@ -0,0 +1,38 @@ +New attributes +-------------- + +* ``cms_create_url``: lead to create view. By default ``/cms/create/my.model`` +* ``cms_search_url``: lead to search view. By default ``/cms/search/my.model`` +* ``cms_edit_url`` (computed field): lead to edit view. By default ``/cms/edit/my.model/model_id`` + +.. note:: No routing provided. + This attributes provide only basic information on contents' URLs. + If you use `cms_form` default routes are handled automatically. + If not, is up to you to provide your own routes to handle them. + + +Permission and extra information +-------------------------------- + +* ``record.cms_is_owner()``: current user is the owner of the record? +* ``record.cms_can_edit()``: current user can edit this record? +* ``record.cms_can_publish()``: current user can publish this record? +* ``record.cms_can_delete()``: current user can delete this record? +* ``model.cms_can_create()``: current user can create a new record? + + +Info all in one +--------------- + +When you build CMS UIs you need all those info at once. +This module provides also an helper method `cms_info()` +that gives you back a dictionary containing: + +* `is_owner`: True/False, +* `can_edit`: True/False, +* `can_create`: True/False, +* `can_publish`: True/False, +* `can_delete`: True/False, +* `create_url` +* `edit_url` +* `delete_url` diff --git a/cms_info/readme/newsfragments/111.feature b/cms_info/readme/newsfragments/111.feature new file mode 100644 index 00000000..92cdae7c --- /dev/null +++ b/cms_info/readme/newsfragments/111.feature @@ -0,0 +1 @@ +Migration to v13 From 2a1f814661a2a8b35e485c03ca0bc8848a786efe Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 9 Nov 2020 08:40:22 +0100 Subject: [PATCH 17/31] [FIX] cms_info: Proper RST syntax --- cms_info/README.rst | 91 ++++- cms_info/readme/USAGE.rst | 6 +- cms_info/static/description/index.html | 499 +++++++++++++++++++++++++ 3 files changed, 579 insertions(+), 17 deletions(-) create mode 100644 cms_info/static/description/index.html diff --git a/cms_info/README.rst b/cms_info/README.rst index 60974919..af4f46c7 100644 --- a/cms_info/README.rst +++ b/cms_info/README.rst @@ -1,16 +1,43 @@ -.. 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 - ======== -CMS Info +CMS info ======== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/13.0/cms_info + :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-13-0/website-cms-13-0-cms_info + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/225/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + Provide basic information for website records / models via `website.published.mixin`. This module is meant to be used as a base to build your own CMS. +**Table of contents** + +.. contents:: + :local: + +Usage +===== + New attributes --------------- +~~~~~~~~~~~~~~ * ``cms_create_url``: lead to create view. By default ``/cms/create/my.model`` * ``cms_search_url``: lead to search view. By default ``/cms/search/my.model`` @@ -23,7 +50,7 @@ New attributes Permission and extra information --------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ``record.cms_is_owner()``: current user is the owner of the record? * ``record.cms_can_edit()``: current user can edit this record? @@ -33,7 +60,7 @@ Permission and extra information Info all in one ---------------- +~~~~~~~~~~~~~~~ When you build CMS UIs you need all those info at once. This module provides also an helper method `cms_info()` @@ -48,32 +75,68 @@ that gives you back a dictionary containing: * `edit_url` * `delete_url` +Known issues / Roadmap +====================== + + +Get rid of `website` dependency and move `website.published.mixin` integration +to a glue module. + +Changelog +========= + +11.0.1.0.1 (2019-01-18) +~~~~~~~~~~~~~~~~~~~~~~~ + +**Fixes** + +- Info dict default to None values +- Test coverage 100% + + +11.0.1.0.0 (2018-04-27) +~~~~~~~~~~~~~~~~~~~~~~~ + +**Improvements** + +- Initial release 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 smashing it by providing a detailed and welcomed +`feedback `_. +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Camptocamp + Contributors ------------- +~~~~~~~~~~~~ * Simone Orsi +Maintainers +~~~~~~~~~~~ -Maintainer ----------- +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. +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. -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. +This module is part of the `OCA/website-cms `_ project on GitHub. -To contribute to this module, please visit https://odoo-community.org. +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/cms_info/readme/USAGE.rst b/cms_info/readme/USAGE.rst index d9315c89..60886a0d 100644 --- a/cms_info/readme/USAGE.rst +++ b/cms_info/readme/USAGE.rst @@ -1,5 +1,5 @@ New attributes --------------- +~~~~~~~~~~~~~~ * ``cms_create_url``: lead to create view. By default ``/cms/create/my.model`` * ``cms_search_url``: lead to search view. By default ``/cms/search/my.model`` @@ -12,7 +12,7 @@ New attributes Permission and extra information --------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ``record.cms_is_owner()``: current user is the owner of the record? * ``record.cms_can_edit()``: current user can edit this record? @@ -22,7 +22,7 @@ Permission and extra information Info all in one ---------------- +~~~~~~~~~~~~~~~ When you build CMS UIs you need all those info at once. This module provides also an helper method `cms_info()` diff --git a/cms_info/static/description/index.html b/cms_info/static/description/index.html new file mode 100644 index 00000000..6c82cdcd --- /dev/null +++ b/cms_info/static/description/index.html @@ -0,0 +1,499 @@ + + + + + + +CMS info + + + +
+

CMS info

+ + +

Beta License: LGPL-3 OCA/website-cms Translate me on Weblate Try me on Runbot

+

Provide basic information for website records / models via website.published.mixin. +This module is meant to be used as a base to build your own CMS.

+

Table of contents

+ +
+

Usage

+
+

New attributes

+
    +
  • cms_create_url: lead to create view. By default /cms/create/my.model
  • +
  • cms_search_url: lead to search view. By default /cms/search/my.model
  • +
  • cms_edit_url (computed field): lead to edit view. By default /cms/edit/my.model/model_id
  • +
+
+

Note

+

No routing provided. +This attributes provide only basic information on contents’ URLs. +If you use cms_form default routes are handled automatically. +If not, is up to you to provide your own routes to handle them.

+
+
+
+

Permission and extra information

+
    +
  • record.cms_is_owner(): current user is the owner of the record?
  • +
  • record.cms_can_edit(): current user can edit this record?
  • +
  • record.cms_can_publish(): current user can publish this record?
  • +
  • record.cms_can_delete(): current user can delete this record?
  • +
  • model.cms_can_create(): current user can create a new record?
  • +
+
+
+

Info all in one

+

When you build CMS UIs you need all those info at once. +This module provides also an helper method cms_info() +that gives you back a dictionary containing:

+
    +
  • is_owner: True/False,
  • +
  • can_edit: True/False,
  • +
  • can_create: True/False,
  • +
  • can_publish: True/False,
  • +
  • can_delete: True/False,
  • +
  • create_url
  • +
  • edit_url
  • +
  • delete_url
  • +
+
+
+
+

Known issues / Roadmap

+

Get rid of website dependency and move website.published.mixin integration +to a glue module.

+
+
+

Changelog

+
+

11.0.1.0.1 (2019-01-18)

+

Fixes

+
    +
  • Info dict default to None values
  • +
  • Test coverage 100%
  • +
+
+
+

11.0.1.0.0 (2018-04-27)

+

Improvements

+
    +
  • Initial release
  • +
+
+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

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.

+
+
+
+ + From 80184be564730ccb1f69d5fee161b877a21a6ec6 Mon Sep 17 00:00:00 2001 From: claudiagn Date: Tue, 16 Feb 2021 17:24:06 +0000 Subject: [PATCH 18/31] Added translation using Weblate (Spanish) --- cms_info/i18n/es.po | 75 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 cms_info/i18n/es.po diff --git a/cms_info/i18n/es.po b/cms_info/i18n/es.po new file mode 100644 index 00000000..56ad08a8 --- /dev/null +++ b/cms_info/i18n/es.po @@ -0,0 +1,75 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * cms_info +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#. module: cms_info +#: model:ir.model,name:cms_info.model_cms_info_mixin +msgid "CMS Info mixin" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_url +#: model:ir.model.fields,field_description:cms_info.field_res_partner__cms_delete_url +#: model:ir.model.fields,field_description:cms_info.field_res_users__cms_delete_url +#: model:ir.model.fields,field_description:cms_info.field_website_page__cms_delete_url +#: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_delete_url +#: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_delete_url +msgid "CMS delete URL" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_confirm_url +#: model:ir.model.fields,field_description:cms_info.field_res_partner__cms_delete_confirm_url +#: model:ir.model.fields,field_description:cms_info.field_res_users__cms_delete_confirm_url +#: model:ir.model.fields,field_description:cms_info.field_website_page__cms_delete_confirm_url +#: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_delete_confirm_url +#: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_delete_confirm_url +msgid "CMS delete confirm URL" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_edit_url +#: model:ir.model.fields,field_description:cms_info.field_res_partner__cms_edit_url +#: model:ir.model.fields,field_description:cms_info.field_res_users__cms_edit_url +#: model:ir.model.fields,field_description:cms_info.field_website_page__cms_edit_url +#: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_edit_url +#: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_edit_url +msgid "CMS edit URL" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__display_name +msgid "Display Name" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__id +msgid "ID" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin____last_update +msgid "Last Modified on" +msgstr "" + +#. module: cms_info +#: model:ir.model,name:cms_info.model_website_published_multi_mixin +msgid "Multi Website Published Mixin" +msgstr "" + +#. module: cms_info +#: model:ir.model,name:cms_info.model_website_published_mixin +msgid "Website Published Mixin" +msgstr "" From 2bc73c5ebf8ce26170f486d5900ea55fc9f6ef1e Mon Sep 17 00:00:00 2001 From: claudiagn Date: Wed, 17 Feb 2021 08:37:25 +0000 Subject: [PATCH 19/31] Added translation using Weblate (Catalan) --- cms_info/i18n/ca.po | 75 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 cms_info/i18n/ca.po diff --git a/cms_info/i18n/ca.po b/cms_info/i18n/ca.po new file mode 100644 index 00000000..c952296e --- /dev/null +++ b/cms_info/i18n/ca.po @@ -0,0 +1,75 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * cms_info +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#. module: cms_info +#: model:ir.model,name:cms_info.model_cms_info_mixin +msgid "CMS Info mixin" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_url +#: model:ir.model.fields,field_description:cms_info.field_res_partner__cms_delete_url +#: model:ir.model.fields,field_description:cms_info.field_res_users__cms_delete_url +#: model:ir.model.fields,field_description:cms_info.field_website_page__cms_delete_url +#: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_delete_url +#: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_delete_url +msgid "CMS delete URL" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_confirm_url +#: model:ir.model.fields,field_description:cms_info.field_res_partner__cms_delete_confirm_url +#: model:ir.model.fields,field_description:cms_info.field_res_users__cms_delete_confirm_url +#: model:ir.model.fields,field_description:cms_info.field_website_page__cms_delete_confirm_url +#: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_delete_confirm_url +#: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_delete_confirm_url +msgid "CMS delete confirm URL" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_edit_url +#: model:ir.model.fields,field_description:cms_info.field_res_partner__cms_edit_url +#: model:ir.model.fields,field_description:cms_info.field_res_users__cms_edit_url +#: model:ir.model.fields,field_description:cms_info.field_website_page__cms_edit_url +#: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_edit_url +#: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_edit_url +msgid "CMS edit URL" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__display_name +msgid "Display Name" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__id +msgid "ID" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin____last_update +msgid "Last Modified on" +msgstr "" + +#. module: cms_info +#: model:ir.model,name:cms_info.model_website_published_multi_mixin +msgid "Multi Website Published Mixin" +msgstr "" + +#. module: cms_info +#: model:ir.model,name:cms_info.model_website_published_mixin +msgid "Website Published Mixin" +msgstr "" From 1bda5bddccaa09186ec1cab217e74f3acd5cab3b Mon Sep 17 00:00:00 2001 From: claudiagn Date: Wed, 17 Feb 2021 08:39:20 +0000 Subject: [PATCH 20/31] Translated using Weblate (Spanish) Currently translated at 100.0% (9 of 9 strings) Translation: website-cms-13.0/website-cms-13.0-cms_info Translate-URL: https://translation.odoo-community.org/projects/website-cms-13-0/website-cms-13-0-cms_info/es/ --- cms_info/i18n/es.po | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/cms_info/i18n/es.po b/cms_info/i18n/es.po index 56ad08a8..0c7169ab 100644 --- a/cms_info/i18n/es.po +++ b/cms_info/i18n/es.po @@ -6,18 +6,20 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2021-02-17 10:45+0000\n" +"Last-Translator: claudiagn \n" "Language-Team: none\n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" #. module: cms_info #: model:ir.model,name:cms_info.model_cms_info_mixin msgid "CMS Info mixin" -msgstr "" +msgstr "CMS Información mix" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_url @@ -27,7 +29,7 @@ msgstr "" #: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_delete_url #: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_delete_url msgid "CMS delete URL" -msgstr "" +msgstr "CMS eliminar URL" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_confirm_url @@ -37,7 +39,7 @@ msgstr "" #: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_delete_confirm_url #: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_delete_confirm_url msgid "CMS delete confirm URL" -msgstr "" +msgstr "CMS confirmar eliminar URL" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_edit_url @@ -47,29 +49,29 @@ msgstr "" #: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_edit_url #: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_edit_url msgid "CMS edit URL" -msgstr "" +msgstr "CMS editar URL" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__display_name msgid "Display Name" -msgstr "" +msgstr "Nombre visible" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__id msgid "ID" -msgstr "" +msgstr "ID" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin____last_update msgid "Last Modified on" -msgstr "" +msgstr "Última modificación el" #. module: cms_info #: model:ir.model,name:cms_info.model_website_published_multi_mixin msgid "Multi Website Published Mixin" -msgstr "" +msgstr "Mixin publicado per varias webs" #. module: cms_info #: model:ir.model,name:cms_info.model_website_published_mixin msgid "Website Published Mixin" -msgstr "" +msgstr "Web Mixin publicado" From c7a41e2317f9dff9159e5f397d65be05faa9cf8d Mon Sep 17 00:00:00 2001 From: claudiagn Date: Wed, 17 Feb 2021 08:38:40 +0000 Subject: [PATCH 21/31] Translated using Weblate (Catalan) Currently translated at 100.0% (9 of 9 strings) Translation: website-cms-13.0/website-cms-13.0-cms_info Translate-URL: https://translation.odoo-community.org/projects/website-cms-13-0/website-cms-13-0-cms_info/ca/ --- cms_info/i18n/ca.po | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/cms_info/i18n/ca.po b/cms_info/i18n/ca.po index c952296e..2fba89e9 100644 --- a/cms_info/i18n/ca.po +++ b/cms_info/i18n/ca.po @@ -6,18 +6,20 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2021-02-17 10:45+0000\n" +"Last-Translator: claudiagn \n" "Language-Team: none\n" "Language: ca\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" #. module: cms_info #: model:ir.model,name:cms_info.model_cms_info_mixin msgid "CMS Info mixin" -msgstr "" +msgstr "CMS Informació mix" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_url @@ -27,7 +29,7 @@ msgstr "" #: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_delete_url #: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_delete_url msgid "CMS delete URL" -msgstr "" +msgstr "CMS eliminar URL" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_confirm_url @@ -37,7 +39,7 @@ msgstr "" #: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_delete_confirm_url #: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_delete_confirm_url msgid "CMS delete confirm URL" -msgstr "" +msgstr "CMS confirmar eliminar URL" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_edit_url @@ -47,29 +49,29 @@ msgstr "" #: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_edit_url #: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_edit_url msgid "CMS edit URL" -msgstr "" +msgstr "CMS editar URL" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__display_name msgid "Display Name" -msgstr "" +msgstr "Nom visible" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__id msgid "ID" -msgstr "" +msgstr "ID" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin____last_update msgid "Last Modified on" -msgstr "" +msgstr "Última modificació el" #. module: cms_info #: model:ir.model,name:cms_info.model_website_published_multi_mixin msgid "Multi Website Published Mixin" -msgstr "" +msgstr "Mixin publicat per diversos llocs web" #. module: cms_info #: model:ir.model,name:cms_info.model_website_published_mixin msgid "Website Published Mixin" -msgstr "" +msgstr "Lloc web Mixin publicat" From 03313fd1c392ae31a9502a99e3faf5a32ee6558e Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Sun, 23 May 2021 17:20:25 +0200 Subject: [PATCH 22/31] cms_info: fix tests model load --- cms_info/tests/test_info_mixin.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cms_info/tests/test_info_mixin.py b/cms_info/tests/test_info_mixin.py index d528cf98..3138f465 100644 --- a/cms_info/tests/test_info_mixin.py +++ b/cms_info/tests/test_info_mixin.py @@ -15,10 +15,9 @@ class TestInfoMixin(test_common.SavepointCase): @classmethod def setUpClass(cls): super().setUpClass() - from .fake_models import FakeModel - cls.loader = FakeModelLoader(cls.env, cls.__module__) cls.loader.backup_registry() + from .fake_models import FakeModel cls.loader.update_registry((FakeModel,)) cls.model = cls.env[FakeModel._name] cls.record = cls.model.create({"name": "Foo"}) From c24c02def8e6b0a2c7a975c43157d5bfed4c3238 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Mon, 23 Aug 2021 19:49:20 +0200 Subject: [PATCH 23/31] Set maintainer on cms* --- cms_info/__manifest__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cms_info/__manifest__.py b/cms_info/__manifest__.py index da926905..4626a086 100644 --- a/cms_info/__manifest__.py +++ b/cms_info/__manifest__.py @@ -8,6 +8,7 @@ "category": "Website", "website": "https://github.com/OCA/website-cms", "author": "Camptocamp, Odoo Community Association (OCA)", + "mainainers": ["simahawk"], "license": "LGPL-3", "installable": True, # TODO: think about make cms stuff independent from `website`. From e0211891201f22863feb2944ed34104f1c595008 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Mon, 23 Aug 2021 18:17:32 +0000 Subject: [PATCH 24/31] [UPD] changelog --- cms_info/readme/HISTORY.rst | 6 ++++++ cms_info/readme/newsfragments/111.feature | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) delete mode 100644 cms_info/readme/newsfragments/111.feature diff --git a/cms_info/readme/HISTORY.rst b/cms_info/readme/HISTORY.rst index f362ecde..5e3f4b46 100644 --- a/cms_info/readme/HISTORY.rst +++ b/cms_info/readme/HISTORY.rst @@ -1,3 +1,9 @@ +13.0.1.0.1 (2021-08-23) +**Features** + +- Migration to v13 (`#111 `_) + + 11.0.1.0.1 (2019-01-18) ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/cms_info/readme/newsfragments/111.feature b/cms_info/readme/newsfragments/111.feature deleted file mode 100644 index 92cdae7c..00000000 --- a/cms_info/readme/newsfragments/111.feature +++ /dev/null @@ -1 +0,0 @@ -Migration to v13 From 565298a2c28139ce31eedd9a42628ce3b6e074b6 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Mon, 23 Aug 2021 18:17:35 +0000 Subject: [PATCH 25/31] [UPD] README.rst --- cms_info/README.rst | 6 +++ cms_info/static/description/index.html | 61 ++++++++++++++------------ 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/cms_info/README.rst b/cms_info/README.rst index af4f46c7..38db29c4 100644 --- a/cms_info/README.rst +++ b/cms_info/README.rst @@ -85,6 +85,12 @@ to a glue module. Changelog ========= +13.0.1.0.1 (2021-08-23) +**Features** + +- Migration to v13 (`#111 `_) + + 11.0.1.0.1 (2019-01-18) ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/cms_info/static/description/index.html b/cms_info/static/description/index.html index 6c82cdcd..262ad653 100644 --- a/cms_info/static/description/index.html +++ b/cms_info/static/description/index.html @@ -373,31 +373,31 @@

CMS info

Table of contents

-

Usage

+

Usage

-

New attributes

+

New attributes

  • cms_create_url: lead to create view. By default /cms/create/my.model
  • cms_search_url: lead to search view. By default /cms/search/my.model
  • @@ -412,7 +412,7 @@

    New attributes

-

Permission and extra information

+

Permission and extra information

  • record.cms_is_owner(): current user is the owner of the record?
  • record.cms_can_edit(): current user can edit this record?
  • @@ -422,7 +422,7 @@

    Permission and extra information

-

Info all in one

+

Info all in one

When you build CMS UIs you need all those info at once. This module provides also an helper method cms_info() that gives you back a dictionary containing:

@@ -439,22 +439,27 @@

Info all in one

-

Known issues / Roadmap

+

Known issues / Roadmap

Get rid of website dependency and move website.published.mixin integration to a glue module.

-

Changelog

-
-

11.0.1.0.1 (2019-01-18)

+

Changelog

+

13.0.1.0.1 (2021-08-23) +Features

+
    +
  • Migration to v13 (#111)
  • +
+
+

11.0.1.0.1 (2019-01-18)

Fixes

  • Info dict default to None values
  • Test coverage 100%
-
-

11.0.1.0.0 (2018-04-27)

+
+

11.0.1.0.0 (2018-04-27)

Improvements

-

Bug Tracker

+

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 smashing it by providing a detailed and welcomed @@ -470,21 +475,21 @@

Bug Tracker

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

-

Credits

+

Credits

-

Authors

+

Authors

  • Camptocamp
-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose From 71ee26aeb8bd4cd76917ca7d5f51203f8a5522e0 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Mon, 23 Aug 2021 18:17:37 +0000 Subject: [PATCH 26/31] cms_info 13.0.1.0.1 --- cms_info/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cms_info/__manifest__.py b/cms_info/__manifest__.py index 4626a086..301c4ebb 100644 --- a/cms_info/__manifest__.py +++ b/cms_info/__manifest__.py @@ -4,7 +4,7 @@ { "name": "CMS info", "summary": """A set of basic information needed on all published records.""", - "version": "13.0.1.0.0", + "version": "13.0.1.0.1", "category": "Website", "website": "https://github.com/OCA/website-cms", "author": "Camptocamp, Odoo Community Association (OCA)", From 1e83b5a377e30177756c19d3aae985ce955970f8 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Mon, 23 Aug 2021 21:40:16 +0200 Subject: [PATCH 27/31] cms_info: migrate to v14 Main improvement: drop dependency on website --- cms_info/__manifest__.py | 13 ++++++------- cms_info/models/__init__.py | 1 - cms_info/models/cms_mixin.py | 10 +++++----- cms_info/models/website_mixin.py | 9 --------- cms_info/tests/fake_models.py | 2 +- cms_info/tests/test_info_mixin.py | 19 +++++++++---------- 6 files changed, 21 insertions(+), 33 deletions(-) delete mode 100644 cms_info/models/website_mixin.py diff --git a/cms_info/__manifest__.py b/cms_info/__manifest__.py index 301c4ebb..3c81fdaf 100644 --- a/cms_info/__manifest__.py +++ b/cms_info/__manifest__.py @@ -3,16 +3,15 @@ { "name": "CMS info", - "summary": """A set of basic information needed on all published records.""", - "version": "13.0.1.0.1", - "category": "Website", + "summary": """ + A set of basic information needed to expose any kind of record in your CMS. + """, + "version": "14.0.1.0.0", + "category": "CMS", "website": "https://github.com/OCA/website-cms", "author": "Camptocamp, Odoo Community Association (OCA)", "mainainers": ["simahawk"], "license": "LGPL-3", "installable": True, - # TODO: think about make cms stuff independent from `website`. - # If you want to use these features in portal only it shouldn't be required - # to install `website`. - "depends": ["website"], + "depends": ["base"], } diff --git a/cms_info/models/__init__.py b/cms_info/models/__init__.py index 5b8657bf..5dbf2b3a 100644 --- a/cms_info/models/__init__.py +++ b/cms_info/models/__init__.py @@ -1,2 +1 @@ from . import cms_mixin -from . import website_mixin diff --git a/cms_info/models/cms_mixin.py b/cms_info/models/cms_mixin.py index 57d8bd83..4b886fcc 100644 --- a/cms_info/models/cms_mixin.py +++ b/cms_info/models/cms_mixin.py @@ -4,8 +4,7 @@ class CMSInfoMixin(models.AbstractModel): - """Provide core information for CMS records. - """ + """Provide core information for CMS records.""" _name = "cms.info.mixin" _description = "CMS Info mixin" @@ -34,17 +33,18 @@ def cms_after_delete_url(self): return "/" cms_edit_url = fields.Char( - string="CMS edit URL", compute="_compute_cms_edit_url", readonly=True, + string="CMS edit URL", + compute="_compute_cms_edit_url", ) cms_delete_url = fields.Char( - string="CMS delete URL", compute="_compute_cms_delete_url", readonly=True, + string="CMS delete URL", + compute="_compute_cms_delete_url", ) cms_delete_confirm_url = fields.Char( string="CMS delete confirm URL", compute="_compute_cms_delete_url", - readonly=True, ) def _compute_cms_edit_url(self): diff --git a/cms_info/models/website_mixin.py b/cms_info/models/website_mixin.py deleted file mode 100644 index 73dbb74b..00000000 --- a/cms_info/models/website_mixin.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2018 Simone Orsi (Camptocamp) -# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). -from odoo import models - - -class WebsiteMixin(models.AbstractModel): - _name = "website.published.mixin" - # Apply cms mixin to website published one - _inherit = ["website.published.mixin", "cms.info.mixin"] diff --git a/cms_info/tests/fake_models.py b/cms_info/tests/fake_models.py index 0a85ea28..26b7ccd6 100644 --- a/cms_info/tests/fake_models.py +++ b/cms_info/tests/fake_models.py @@ -6,7 +6,7 @@ class FakeModel(models.TransientModel): _name = "fake.model" - _description = "Testing fake model" _inherit = "cms.info.mixin" + _description = "Testing fake model" name = fields.Char() diff --git a/cms_info/tests/test_info_mixin.py b/cms_info/tests/test_info_mixin.py index 3138f465..a157bc8d 100644 --- a/cms_info/tests/test_info_mixin.py +++ b/cms_info/tests/test_info_mixin.py @@ -3,21 +3,18 @@ import mock from odoo_test_helper import FakeModelLoader -import odoo.tests.common as test_common from odoo import exceptions +from odoo.tests.common import SavepointCase -class TestInfoMixin(test_common.SavepointCase): - - post_install = True - at_install = False - +class TestInfoMixin(SavepointCase): @classmethod def setUpClass(cls): super().setUpClass() cls.loader = FakeModelLoader(cls.env, cls.__module__) cls.loader.backup_registry() from .fake_models import FakeModel + cls.loader.update_registry((FakeModel,)) cls.model = cls.env[FakeModel._name] cls.record = cls.model.create({"name": "Foo"}) @@ -29,7 +26,6 @@ def setUpClass(cls): "name": "User 1", "login": "user1", "email": "user1@email.com", - "groups_id": [(6, 0, [cls.env.ref("base.group_portal").id])], } ) @@ -46,19 +42,22 @@ def test_search_url(self): def test_edit_url(self): self.assertEqual( - self.record.cms_edit_url, "/cms/edit/fake.model/%s" % self.record.id, + self.record.cms_edit_url, + "/cms/edit/fake.model/%s" % self.record.id, ) def test_delete_url(self): self.assertEqual( - self.record.cms_delete_url, "/cms/delete/fake.model/%s" % self.record.id, + self.record.cms_delete_url, + "/cms/delete/fake.model/%s" % self.record.id, ) self.assertEqual( self.record.cms_delete_confirm_url, "/cms/delete/fake.model/%s/confirm" % self.record.id, ) self.assertEqual( - self.record.cms_after_delete_url, "/", + self.record.cms_after_delete_url, + "/", ) def test_is_owner(self): From b9771b319aa9e8c2c77a0ed7b9042bddb42c71a9 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Wed, 25 Aug 2021 19:43:06 +0000 Subject: [PATCH 28/31] [UPD] Update cms_info.pot --- cms_info/i18n/ca.po | 27 ++++----------------- cms_info/i18n/cms_info.pot | 49 ++++++++++++++++++++++++++++++++++++++ cms_info/i18n/es.po | 27 ++++----------------- 3 files changed, 57 insertions(+), 46 deletions(-) create mode 100644 cms_info/i18n/cms_info.pot diff --git a/cms_info/i18n/ca.po b/cms_info/i18n/ca.po index 2fba89e9..78e53bbc 100644 --- a/cms_info/i18n/ca.po +++ b/cms_info/i18n/ca.po @@ -23,31 +23,16 @@ msgstr "CMS Informació mix" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_url -#: model:ir.model.fields,field_description:cms_info.field_res_partner__cms_delete_url -#: model:ir.model.fields,field_description:cms_info.field_res_users__cms_delete_url -#: model:ir.model.fields,field_description:cms_info.field_website_page__cms_delete_url -#: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_delete_url -#: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_delete_url msgid "CMS delete URL" msgstr "CMS eliminar URL" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_confirm_url -#: model:ir.model.fields,field_description:cms_info.field_res_partner__cms_delete_confirm_url -#: model:ir.model.fields,field_description:cms_info.field_res_users__cms_delete_confirm_url -#: model:ir.model.fields,field_description:cms_info.field_website_page__cms_delete_confirm_url -#: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_delete_confirm_url -#: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_delete_confirm_url msgid "CMS delete confirm URL" msgstr "CMS confirmar eliminar URL" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_edit_url -#: model:ir.model.fields,field_description:cms_info.field_res_partner__cms_edit_url -#: model:ir.model.fields,field_description:cms_info.field_res_users__cms_edit_url -#: model:ir.model.fields,field_description:cms_info.field_website_page__cms_edit_url -#: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_edit_url -#: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_edit_url msgid "CMS edit URL" msgstr "CMS editar URL" @@ -66,12 +51,8 @@ msgstr "ID" msgid "Last Modified on" msgstr "Última modificació el" -#. module: cms_info -#: model:ir.model,name:cms_info.model_website_published_multi_mixin -msgid "Multi Website Published Mixin" -msgstr "Mixin publicat per diversos llocs web" +#~ msgid "Multi Website Published Mixin" +#~ msgstr "Mixin publicat per diversos llocs web" -#. module: cms_info -#: model:ir.model,name:cms_info.model_website_published_mixin -msgid "Website Published Mixin" -msgstr "Lloc web Mixin publicat" +#~ msgid "Website Published Mixin" +#~ msgstr "Lloc web Mixin publicat" diff --git a/cms_info/i18n/cms_info.pot b/cms_info/i18n/cms_info.pot new file mode 100644 index 00000000..fe414caf --- /dev/null +++ b/cms_info/i18n/cms_info.pot @@ -0,0 +1,49 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * cms_info +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: cms_info +#: model:ir.model,name:cms_info.model_cms_info_mixin +msgid "CMS Info mixin" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_url +msgid "CMS delete URL" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_confirm_url +msgid "CMS delete confirm URL" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_edit_url +msgid "CMS edit URL" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__display_name +msgid "Display Name" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__id +msgid "ID" +msgstr "" + +#. module: cms_info +#: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin____last_update +msgid "Last Modified on" +msgstr "" diff --git a/cms_info/i18n/es.po b/cms_info/i18n/es.po index 0c7169ab..b6b1f58c 100644 --- a/cms_info/i18n/es.po +++ b/cms_info/i18n/es.po @@ -23,31 +23,16 @@ msgstr "CMS Información mix" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_url -#: model:ir.model.fields,field_description:cms_info.field_res_partner__cms_delete_url -#: model:ir.model.fields,field_description:cms_info.field_res_users__cms_delete_url -#: model:ir.model.fields,field_description:cms_info.field_website_page__cms_delete_url -#: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_delete_url -#: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_delete_url msgid "CMS delete URL" msgstr "CMS eliminar URL" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_delete_confirm_url -#: model:ir.model.fields,field_description:cms_info.field_res_partner__cms_delete_confirm_url -#: model:ir.model.fields,field_description:cms_info.field_res_users__cms_delete_confirm_url -#: model:ir.model.fields,field_description:cms_info.field_website_page__cms_delete_confirm_url -#: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_delete_confirm_url -#: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_delete_confirm_url msgid "CMS delete confirm URL" msgstr "CMS confirmar eliminar URL" #. module: cms_info #: model:ir.model.fields,field_description:cms_info.field_cms_info_mixin__cms_edit_url -#: model:ir.model.fields,field_description:cms_info.field_res_partner__cms_edit_url -#: model:ir.model.fields,field_description:cms_info.field_res_users__cms_edit_url -#: model:ir.model.fields,field_description:cms_info.field_website_page__cms_edit_url -#: model:ir.model.fields,field_description:cms_info.field_website_published_mixin__cms_edit_url -#: model:ir.model.fields,field_description:cms_info.field_website_published_multi_mixin__cms_edit_url msgid "CMS edit URL" msgstr "CMS editar URL" @@ -66,12 +51,8 @@ msgstr "ID" msgid "Last Modified on" msgstr "Última modificación el" -#. module: cms_info -#: model:ir.model,name:cms_info.model_website_published_multi_mixin -msgid "Multi Website Published Mixin" -msgstr "Mixin publicado per varias webs" +#~ msgid "Multi Website Published Mixin" +#~ msgstr "Mixin publicado per varias webs" -#. module: cms_info -#: model:ir.model,name:cms_info.model_website_published_mixin -msgid "Website Published Mixin" -msgstr "Web Mixin publicado" +#~ msgid "Website Published Mixin" +#~ msgstr "Web Mixin publicado" From ca9f9b07dcb4fa52cfdd7f8748dd9e628fda0b51 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Wed, 25 Aug 2021 19:55:51 +0000 Subject: [PATCH 29/31] [UPD] README.rst --- cms_info/README.rst | 10 +++++----- cms_info/static/description/index.html | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cms_info/README.rst b/cms_info/README.rst index 38db29c4..2f2c4436 100644 --- a/cms_info/README.rst +++ b/cms_info/README.rst @@ -14,13 +14,13 @@ CMS info :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/13.0/cms_info + :target: https://github.com/OCA/website-cms/tree/14.0/cms_info :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-13-0/website-cms-13-0-cms_info + :target: https://translation.odoo-community.org/projects/website-cms-14-0/website-cms-14-0-cms_info :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/225/13.0 + :target: https://runbot.odoo-community.org/runbot/225/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -113,7 +113,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 smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -143,6 +143,6 @@ 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. -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_info/static/description/index.html b/cms_info/static/description/index.html index 262ad653..6ce9c057 100644 --- a/cms_info/static/description/index.html +++ b/cms_info/static/description/index.html @@ -367,7 +367,7 @@

CMS info

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: LGPL-3 OCA/website-cms Translate me on Weblate Try me on Runbot

+

Beta License: LGPL-3 OCA/website-cms Translate me on Weblate Try me on Runbot

Provide basic information for website records / models via website.published.mixin. This module is meant to be used as a base to build your own CMS.

Table of contents

@@ -471,7 +471,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 smashing it by providing a detailed and welcomed -feedback.

+feedback.

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

@@ -495,7 +495,7 @@

Maintainers

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.

-

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.

From d35b4be1e8cca53e3badc2a610b0fc1609732dd2 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 20 Apr 2023 18:51:52 +0200 Subject: [PATCH 30/31] cms_info: migrate to v16 --- cms_info/__manifest__.py | 2 +- cms_info/readme/HISTORY.rst | 10 ++++++++++ cms_info/tests/test_info_mixin.py | 7 ++++--- setup/cms_info/odoo/addons/cms_info | 1 + setup/cms_info/setup.py | 6 ++++++ 5 files changed, 22 insertions(+), 4 deletions(-) create mode 120000 setup/cms_info/odoo/addons/cms_info create mode 100644 setup/cms_info/setup.py diff --git a/cms_info/__manifest__.py b/cms_info/__manifest__.py index 3c81fdaf..7c9265da 100644 --- a/cms_info/__manifest__.py +++ b/cms_info/__manifest__.py @@ -6,7 +6,7 @@ "summary": """ A set of basic information needed to expose any kind of record in your CMS. """, - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "category": "CMS", "website": "https://github.com/OCA/website-cms", "author": "Camptocamp, Odoo Community Association (OCA)", diff --git a/cms_info/readme/HISTORY.rst b/cms_info/readme/HISTORY.rst index 5e3f4b46..3c60ca43 100644 --- a/cms_info/readme/HISTORY.rst +++ b/cms_info/readme/HISTORY.rst @@ -1,4 +1,14 @@ +16.0.1.0.0 (2023-05-13) +~~~~~~~~~~~~~~~~~~~~~~~ + +**Features** + +- Migration to v16 (`#127 `_) + + 13.0.1.0.1 (2021-08-23) +~~~~~~~~~~~~~~~~~~~~~~~ + **Features** - Migration to v13 (`#111 `_) diff --git a/cms_info/tests/test_info_mixin.py b/cms_info/tests/test_info_mixin.py index a157bc8d..0b1e3dcd 100644 --- a/cms_info/tests/test_info_mixin.py +++ b/cms_info/tests/test_info_mixin.py @@ -1,13 +1,14 @@ # Copyright 2018 Simone Orsi # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) -import mock +from unittest import mock + from odoo_test_helper import FakeModelLoader from odoo import exceptions -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase -class TestInfoMixin(SavepointCase): +class TestInfoMixin(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/setup/cms_info/odoo/addons/cms_info b/setup/cms_info/odoo/addons/cms_info new file mode 120000 index 00000000..ff2e4661 --- /dev/null +++ b/setup/cms_info/odoo/addons/cms_info @@ -0,0 +1 @@ +../../../../cms_info \ No newline at end of file diff --git a/setup/cms_info/setup.py b/setup/cms_info/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/cms_info/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From 5d86133bc93d12073f89c5839fe25cba0af2f57d Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 20 Apr 2023 18:52:32 +0200 Subject: [PATCH 31/31] Update test-requirements --- test-requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test-requirements.txt diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..4ad8e0ec --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-test-helper