From 870b51134dbe92b623cdc8ab38b7203c4934bd7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Wed, 15 Feb 2017 16:59:31 +0100 Subject: [PATCH] [IMP] website_slide: use classical chatter Slide provided a chatter where you can post message as public user. We decided to drop that feature in order to avoid spamming. Like for all other document, you must at least, be portal user to post a comment. Reusing the standart chatter highly simplify the code. --- addons/website_slides/controllers/main.py | 46 ------------------- addons/website_slides/models/slides.py | 1 + .../website_slides/views/website_slides.xml | 46 ++----------------- 3 files changed, 4 insertions(+), 89 deletions(-) diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py index adc6aeaad39..0b7fdb47982 100644 --- a/addons/website_slides/controllers/main.py +++ b/addons/website_slides/controllers/main.py @@ -168,52 +168,6 @@ class WebsiteSlides(http.Controller): response.mimetype = 'application/pdf' return response - @http.route('''/slides/slide/ cannot create mail.message ? - if not post.get('comment'): - return werkzeug.utils.redirect(request.httprequest.referrer + "#discuss") - # public user: check or find author based on email, do not subscribe public user - # and do not publish their comments by default to avoid direct spam - if request.uid == request.website.user_id.id: - if not post.get('email'): - return werkzeug.utils.redirect(request.httprequest.referrer + "#discuss") - # TDE FIXME: public user has no right to create mail.message, should - # be investigated - using SUPERUSER_ID meanwhile - contextual_slide = slide.sudo().with_context(mail_create_nosubcribe=True) - # TDE FIXME: check in mail_thread, find partner from emails should maybe work as public user - partner_id = slide.sudo()._find_partner_from_emails([post.get('email')])[0] - if partner_id: - partner = request.env['res.partner'].sudo().browse(partner_id) - else: - partner = request.env['res.partner'].sudo().create({ - 'name': post.get('name', post['email']), - 'email': post['email'] - }) - post_kwargs = { - 'author_id': partner.id, - 'website_published': False, - 'email_from': partner.email, - } - # logged user: as usual, published by default - else: - contextual_slide = slide - post_kwargs = {} - - contextual_slide.message_post( - body=post['comment'], - message_type='comment', - subtype='mt_comment', - **post_kwargs - ) - return werkzeug.utils.redirect(request.httprequest.referrer + "#discuss") - @http.route('''/slides/slide//download''', type='http', auth="public", website=True) def slide_download(self, slide): if slide.download_security == 'public' or (slide.download_security == 'user' and request.session.uid): diff --git a/addons/website_slides/models/slides.py b/addons/website_slides/models/slides.py index f8726cf66b2..6607e5cb4ac 100644 --- a/addons/website_slides/models/slides.py +++ b/addons/website_slides/models/slides.py @@ -261,6 +261,7 @@ class Slide(models.Model): _name = 'slide.slide' _inherit = ['mail.thread', 'website.seo.metadata', 'website.published.mixin'] _description = 'Slides' + _mail_post_access = 'read' _PROMOTIONAL_FIELDS = [ '__last_update', 'name', 'image_thumb', 'image_medium', 'slide_type', 'total_views', 'category_id', diff --git a/addons/website_slides/views/website_slides.xml b/addons/website_slides/views/website_slides.xml index 4cea61c1c3e..2dc648e75d0 100644 --- a/addons/website_slides/views/website_slides.xml +++ b/addons/website_slides/views/website_slides.xml @@ -543,49 +543,9 @@
-
- -
- - - -
-
- - -
-
-

- Post comment with email address (confirmation of email is required in order to publish comment on website) or please - login - to post comment -

-
-
- - -
-
-
-
-
    -
  • - - - -
    - - - - - on -
    -
    -
  • -
+ + +