diff options
| author | Romain Derie <rde@odoo.com> | 2019-05-13 17:29:24 +0000 |
|---|---|---|
| committer | Jeremy Kersten <jke@odoo.com> | 2019-08-03 09:51:22 +0000 |
| commit | cc1d78a80b518bd5eaec7eb70d7bc14ec4c31275 (patch) | |
| tree | 9f5dff2b44804e14701e4fe7bc9603086df9af55 /addons/website_slides/controllers/main.py | |
| parent | f9c2716b3e76ce9bc36d87d69a37a897391c9cdb (diff) | |
[IMP] *: correctly read/write website_published
The `website_published` field from the website's mixins is basically a readonly
from `is_published` field.
On read, this field will simply read `is_published` and check if the record's
website_id is accessible (only for the multi mixin).
On write, it will always write on `is_published`.
This commit improves a few things:
- A lot of code was writting on website_published which was just then writting
on is_published. Writting directly on is_published makes more sense.
- Some backend fields would still reference `website_published` instead of
`is_published` which would just go through the related for no reason.
Plus, using `is_published` will make the field tooltip more accurate as we
are not in a website context ('Visible on current website' to 'Is Published')
- Filter and search on tree view were still using the `website_published`
related field, which is just a readonly when we are not in a frontend
context.
- Some create and write function would have security check on
`website_published` value but that was wrong as the user could bypass that by
simply writting on `is_published`. For the write method, check `is_published`
is more accurate as it will cover both case since `website_published` will
then call the write method on `is_published`
Diffstat (limited to 'addons/website_slides/controllers/main.py')
| -rw-r--r-- | addons/website_slides/controllers/main.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py index 57c25a04af0..634da160459 100644 --- a/addons/website_slides/controllers/main.py +++ b/addons/website_slides/controllers/main.py @@ -820,7 +820,7 @@ class WebsiteSlides(WebsiteProfile): try: values['user_id'] = request.env.uid - values['website_published'] = values.get('website_published', False) and can_publish + values['is_published'] = values.get('is_published', False) and can_publish slide = request.env['slide.slide'].sudo().create(values) except (UserError, AccessError) as e: _logger.error(e) @@ -836,17 +836,17 @@ class WebsiteSlides(WebsiteProfile): redirect_url += "?enable_editor=1" if slide.slide_type == "quiz": action_id = request.env.ref('website_slides.action_slides_slides').id - redirect_url = '/web#id=%s&action=%s&model=slide.slide&view_type=form' %(slide.id,action_id) + redirect_url = '/web#id=%s&action=%s&model=slide.slide&view_type=form' % (slide.id, action_id) return { 'url': redirect_url, 'channel_type': channel.channel_type, 'slide_id': slide.id, 'category_id': slide.category_id - } + } def _get_valid_slide_post_values(self): return ['name', 'url', 'tag_ids', 'slide_type', 'channel_id', 'is_preview', - 'mime_type', 'datas', 'description', 'image_1920', 'index_content', 'website_published'] + 'mime_type', 'datas', 'description', 'image_1920', 'index_content', 'is_published'] @http.route(['/slides/tag/search_read'], type='json', auth='user', methods=['POST'], website=True) def slide_tag_search_read(self, fields, domain): |
