e088762a21
- Affected Modules: website_sale, website_blog, website_partner, website_crm_partner_assign, website_customer, website_slides, website_links, website_membership, website_hr, website_hr_recruitment, website_payment, website_sale_delivery, website_forum, website_event - Remove unnecessary model `website.product.pricelist` from website_sale, All its mechanism already transferd to existing model `product.pricelist` - Change in `product.pricelist` model, make website_id(o2m) to website_ids(m2m), As user can choose that same pricelist can be used in multiple websites - Added `default_website` as default values in `website_ids(m2m)` & `website_id(m2o)` field in almost all affected modules (mentioned above!!) - To use/publish things(like... product, pricelist, blog, forum, events, etc...) in website, User have to set `website_published` mechanism `on` (if it's available for that model/object), Also have to set/assign different websites in `website_ids` field as per needs
62 lines
2.9 KiB
Python
62 lines
2.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
|
|
|
|
from flectra.addons.website_blog.tests.common import TestWebsiteBlogCommon
|
|
|
|
|
|
class TestWebsiteBlogFlow(TestWebsiteBlogCommon):
|
|
|
|
def test_website_blog_followers(self):
|
|
""" Test the flow of followers and notifications for blogs. Intended
|
|
flow :
|
|
|
|
- people subscribe to a blog
|
|
- when creating a new post, nobody except the creator follows it
|
|
- people subscribed to the blog does not receive comments on posts
|
|
- when published, a notification is sent to all blog followers
|
|
- if someone subscribe to the post or comment it, it become follower
|
|
and receive notification for future comments. """
|
|
|
|
website = self.env['website'].browse(1)
|
|
# Create a new blog, subscribe the employee to the blog
|
|
test_blog = self.env['blog.blog'].sudo(self.user_blogmanager).create({
|
|
'name': 'New Blog',
|
|
})
|
|
self.assertIn(
|
|
self.user_blogmanager.partner_id, test_blog.message_partner_ids,
|
|
'website_blog: blog create should be in the blog followers')
|
|
test_blog.message_subscribe([self.user_employee.partner_id.id, self.user_public.partner_id.id])
|
|
|
|
# Create a new post, blog followers should not follow the post
|
|
test_blog_post = self.env['blog.post'].sudo(self.user_blogmanager).create({
|
|
'name': 'New Post',
|
|
'blog_id': test_blog.id,
|
|
})
|
|
self.assertNotIn(
|
|
self.user_employee.partner_id, test_blog_post.message_partner_ids,
|
|
'website_blog: subscribing to a blog should not subscribe to its posts')
|
|
self.assertNotIn(
|
|
self.user_public.partner_id, test_blog_post.message_partner_ids,
|
|
'website_blog: subscribing to a blog should not subscribe to its posts')
|
|
|
|
# Publish the blog
|
|
test_blog_post.write({'website_published': True, 'website_ids': [(6, 0, [website.id])]})
|
|
|
|
# Check publish message has been sent to blog followers
|
|
publish_message = next((m for m in test_blog_post.blog_id.message_ids if m.subtype_id.id == self.ref('website_blog.mt_blog_blog_published')), None)
|
|
self.assertEqual(
|
|
publish_message.needaction_partner_ids,
|
|
self.user_employee.partner_id | self.user_public.partner_id,
|
|
'website_blog: peuple following a blog should be notified of a published post')
|
|
|
|
# Armand posts a message -> becomes follower
|
|
test_blog_post.sudo().message_post(
|
|
body='Armande BlogUser Commented',
|
|
message_type='comment',
|
|
author_id=self.user_employee.partner_id.id,
|
|
subtype='mt_comment',
|
|
)
|
|
self.assertIn(
|
|
self.user_employee.partner_id, test_blog_post.message_partner_ids,
|
|
'website_blog: people commenting a post should follow it afterwards')
|