[IMP] website published mechanism

This commit is contained in:
Kaushal Prajapati 2017-12-29 12:19:11 +05:30 committed by Siddharth Bhalgami
parent a612251a13
commit aba211d99b
11 changed files with 35 additions and 36 deletions

View File

@ -24,7 +24,7 @@ class WebsiteBlog(http.Controller):
dom = blog and [('blog_id', '=', blog.id)] or []
if not request.env.user.has_group('website.group_website_designer'):
dom += [('post_date', '<=', fields.Datetime.now()),
("website_ids", "in", request.website.id)]
'|', ("website_ids", "in", request.website.id), ('website_ids', '=', False)]
groups = request.env['blog.post']._read_group_raw(
dom,
['name', 'post_date'],
@ -64,7 +64,7 @@ class WebsiteBlog(http.Controller):
page=page,
step=self._blog_post_per_page,
)
posts = BlogPost.search([("website_ids", "in", request.website.id)], offset=(page - 1) * self._blog_post_per_page, limit=self._blog_post_per_page)
posts = BlogPost.search(['|', ("website_ids", "in", request.website.id), ('website_ids', '=', False)], offset=(page - 1) * self._blog_post_per_page, limit=self._blog_post_per_page)
blog_url = QueryURL('', ['blog', 'tag'])
return request.render("website_blog.latest_blogs", {
'posts': posts,
@ -114,16 +114,16 @@ class WebsiteBlog(http.Controller):
domain += [("post_date", ">=", date_begin), ("post_date", "<=", date_end)]
if request.env.user.has_group('website.group_website_designer'):
count_domain = domain + [("website_published", "=", True), ("website_ids", "in", request.website.id), ("post_date", "<=", fields.Datetime.now())]
count_domain = domain + [("website_published", "=", True), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False), ("post_date", "<=", fields.Datetime.now())]
published_count = BlogPost.search_count(count_domain)
unpublished_count = BlogPost.search_count(domain) - published_count
if state == "published":
domain += [("website_published", "=", True), ("website_ids", "in", request.website.id), ("post_date", "<=", fields.Datetime.now())]
domain += [("website_published", "=", True), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False), ("post_date", "<=", fields.Datetime.now())]
elif state == "unpublished":
domain += ['|', ("website_published", "=", False), ("website_ids", "not in", request.website.id), ("post_date", ">", fields.Datetime.now())]
domain += ['|', ("website_published", "=", False), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False), ("post_date", ">", fields.Datetime.now())]
else:
domain += [("post_date", "<=", fields.Datetime.now()), ("website_ids", "in", request.website.id)]
domain += [("post_date", "<=", fields.Datetime.now()), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False)]
blog_url = QueryURL('', ['blog', 'tag'], blog=blog, tag=tag, date_begin=date_begin, date_end=date_end)
@ -331,7 +331,7 @@ class WebsiteBlog(http.Controller):
#check current user belongs to website publisher group
publish = request.env.user.has_group('website.group_website_publisher')
if not publish:
domain.append(('website_published', '=', True), ("website_ids", "in", request.website.id))
domain.append(('website_published', '=', True), '|', ("website_ids", "in", request.website.id), ('website_ids', '=', False))
messages = request.env['mail.message'].sudo().search(domain, count=count)
if count:
return messages.ids

View File

@ -57,7 +57,7 @@
<t t-foreach="posts" t-as="post">
<div class="col-md-4">
<h4>
<a t-attf-href="#{blog_url('', ['blog', 'post'], blog=post.blog_id, post=post)}" t-field="post.name"></a>
<a t-attf-href="#{blog_url('', ['blog', 'post'], blog=post.blog_id, post=post)}" t-field="post.name"/>
<span t-if="not post.website_published" class="text-warning">
<span class="fa fa-exclamation-triangle ml8" title="Unpublished"/>
</span>
@ -133,7 +133,7 @@
</p>
</div>
<div t-foreach="blog_posts" t-as="blog_post" class="mb32" name="blog_post" t-att-data-publish="website in blog_post.website_ids and 'on' or 'off'">
<div t-foreach="blog_posts" t-as="blog_post" class="mb32" name="blog_post" t-attf-data-publish="#{not blog_post.website_ids or website in blog_post.website_ids and 'on' or 'off'}">
<a t-attf-href="/blog/#{ slug(blog_post.blog_id) }/post/#{ slug(blog_post) }">
<h2 t-field="blog_post.name" class="mb4 o_blog_post_title">Untitled Post</h2>
</a>

View File

@ -185,14 +185,14 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
yield {'loc': '/partners'}
Grade = env['res.partner.grade']
dom = [('website_published', '=', True), ('website_ids', 'in', request.website.id)]
dom = [('website_published', '=', True), '|', ('website_ids', 'in', request.website.id), ('website_ids', '=', False)]
dom += sitemap_qs2dom(qs=qs, route='/partners/grade/', field=Grade._rec_name)
for grade in env['res.partner.grade'].search(dom):
loc = '/partners/grade/%s' % slug(grade)
if not qs or qs.lower() in loc:
yield {'loc': loc}
partners_dom = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True), ('website_ids', 'in', request.website.id), ('grade_id.website_published', '=', True)]
partners_dom = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True), '|', ('website_ids', 'in', request.website.id), ('website_ids', '=', False), ('grade_id.website_published', '=', True)]
dom += sitemap_qs2dom(qs=qs, route='/partners/country/')
countries = env['res.partner'].sudo().read_group(partners_dom, fields=['id', 'country_id'], groupby='country_id')
for country in countries:
@ -221,7 +221,7 @@ class WebsiteCrmPartnerAssign(WebsitePartnerPage):
base_partner_domain = [('is_company', '=', True), ('grade_id', '!=', False), ('website_published', '=', True)]
if not request.env['res.users'].has_group('website.group_website_publisher'):
base_partner_domain += [('grade_id.website_published', '=', True), ('grade_id.website_ids', 'in', request.website.id)]
base_partner_domain += [('grade_id.website_published', '=', True), '|', ('grade_id.website_ids', 'in', request.website.id), ('grade_id.website_ids', '=', False)]
if search:
base_partner_domain += ['|', ('name', 'ilike', search), ('website_description', 'ilike', search)]

View File

@ -162,7 +162,7 @@
<template id="grade_in_detail" inherit_id="website_partner.partner_detail">
<xpath expr="//*[@id='partner_name']" position="after">
<h3 class="col-md-12 text-center text-muted" t-if="partner.grade_id and partner.grade_id.website_published and website in partner.grade_id.website_published">
<h3 class="col-md-12 text-center text-muted" t-if="partner.grade_id and partner.grade_id.website_published and (website in partner.grade_id.website_ids or not partner.grade_id.website_ids)">
<span t-field="partner.grade_id"/> Partner</h3>
</xpath>
</template>
@ -171,7 +171,7 @@
<t t-if="any([p.website_published for p in partner.implemented_partner_ids])">
<h3 id="references">References</h3>
<div t-foreach="partner.implemented_partner_ids" t-as="reference" class="media">
<t t-if="website in reference.website_ids and reference.website_published">
<t t-if="(not reference.website_ids or website in reference.website_ids) and reference.website_published">
<a class="pull-left" t-attf-href="/customers/#{slug(reference)}">
<span t-field="reference.image_small" t-options='{"widget": "image", "class": "center-block"}'/>
</a>

View File

@ -47,7 +47,7 @@ class WebsiteCustomer(http.Controller):
Partner = request.env['res.partner']
search_value = post.get('search')
domain = [('website_published', '=', True), ('website_ids', 'in', request.website.id), ('assigned_partner_id', '!=', False)]
domain = [('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id), ('assigned_partner_id', '!=', False)]
if search_value:
domain += [
'|', '|',
@ -118,7 +118,7 @@ class WebsiteCustomer(http.Controller):
google_map_partner_ids = ','.join(str(it) for it in partners.ids)
google_maps_api_key = request.env['ir.config_parameter'].sudo().get_param('google_maps_api_key')
tags = Tag.search([('website_published', '=', True), ('website_ids', 'in', request.website.id), ('partner_ids', 'in', partners.ids)], order='classname, name ASC')
tags = Tag.search([('website_published', '=', True), '|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id), ('partner_ids', 'in', partners.ids)], order='classname, name ASC')
tag = tag_id and Tag.browse(tag_id) or False
values = {
@ -145,7 +145,7 @@ class WebsiteCustomer(http.Controller):
_, partner_id = unslug(partner_id)
if partner_id:
partner = request.env['res.partner'].sudo().browse(partner_id)
if partner.exists() and partner.website_published and request.website in partner.website_ids:
if partner.exists() and partner.website_published and (request.website in partner.website_ids or not partner.website_ids):
values = {}
values['main_object'] = values['partner'] = partner
return request.render("website_customer.details", values)

View File

@ -189,7 +189,7 @@
</template>
<template id="implemented_by_block" name="Partner Implemented By Block">
<t t-if="partner.assigned_partner_id and partner.assigned_partner_id.website_published and website in partner.assigned_partner_id.website_ids">
<t t-if="partner.assigned_partner_id and partner.assigned_partner_id.website_published and (website in partner.assigned_partner_id.website_ids or not partner.assigned_partner_id.website_ids)">
<div class="panel panel-default">
<div class="panel-heading">
<h4>Implemented By</h4>
@ -198,7 +198,7 @@
<h4>
<a t-attf-href="/partners/#{slug(partner.assigned_partner_id)}">
<span t-field="partner.assigned_partner_id"/>
<span class="small"> (<t t-esc="len([p for p in partner.assigned_partner_id.implemented_partner_ids if p.website_published and website in p.website_ids])"/> reference(s))</span>
<span class="small"> (<t t-esc="len([p for p in partner.assigned_partner_id.implemented_partner_ids if p.website_published and (p.website_ids or website in p.website_ids)])"/> reference(s))</span>
</a>
</h4>
<div><a t-attf-href="/partners/#{slug(partner.assigned_partner_id)}"
@ -218,10 +218,10 @@
</template>
<template id="references_block" name="Partner References Block">
<t t-if="any([p.website_published and website in p.website_ids for p in partner.implemented_partner_ids])">
<t t-if="any([p.website_published and (website in p.website_ids or not p.website_ids) for p in partner.implemented_partner_ids])">
<h3 id="references">References</h3>
<div t-foreach="partner.implemented_partner_ids" t-as="reference" class="media">
<t t-if="reference.website_published and website in reference.website_ids">
<t t-if="reference.website_published and (website in reference.website_ids or not reference.website_ids)">
<a class="pull-left" t-attf-href="/customers/#{slug(reference)}">
<span t-field="reference.image_small" t-options='{"widget": "image", "class": "center-block"}'/>
</a>

View File

@ -83,7 +83,7 @@ class WebsiteEventController(http.Controller):
def dom_without(without):
domain = [('state', "in", ['draft', 'confirm', 'done'])]
domain += [('website_ids', 'in', request.website.id)] if \
domain += ['|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id)] if \
not request.env.user.has_group('website.group_website_publisher') else []
for key, search in domain_search.items():
if key != without:

View File

@ -53,12 +53,12 @@
</div>
<ul class="media-list">
<li t-foreach="event_ids" t-as="event" class="media">
<div itemscope="itemscope" itemtype="http://schema.org/Event" class="media-body" t-att-data-publish="website in event.website_ids and 'on' or 'off'">
<div itemscope="itemscope" itemtype="http://schema.org/Event" class="media-body" t-attf-data-publish="#{not event.website_ids or website in event.website_ids and 'on' or 'off'}">
<h4 class="media-heading">
<a itemprop="url" t-att-class="event.state == 'done' and 'text-success'" t-attf-href="/event/#{ slug(event) }/#{(not event.menu_id) and 'register' or ''}"><span itemprop="name" t-field="event.name"> </span></a>
<small t-if="event.is_participating" class="label label-info">Participating</small>
<small t-if="not event.is_online" class="label label-info">Online</small>
<small t-if="not event.website_published and website not in event.website_ids" class="label label-danger">unpublished</small>
<small t-if="not event.website_published and (not event.website_ids or website not in event.website_ids)" class="label label-danger">unpublished</small>
</h4>
<div>
<t t-if="event.organizer_id">
@ -680,7 +680,7 @@
<h4><b>Upcoming Events</b></h4>
</t>
<div t-foreach="events[:5]" t-as="event_dict" class="oe_website_overflow_ellipsis mb8">
<t t-if="not event_dict['event'].website_published and website not in event_dict['event'].wesite_ids">
<t t-if="not event_dict['event'].website_published and (website not in event_dict['event'].wesite_ids or not event_dict['event'].wesite_ids)">
<span class="label label-danger"><i class="fa fa-ban"></i></span>
</t>
<t t-if="event_dict['event'].address_id">

View File

@ -83,7 +83,7 @@ class WebsiteForum(http.Controller):
def forum(self, **kwargs):
domain = []
if not request.env.user.has_group('website.group_website_designer'):
domain += [('website_ids', '!=', False), ('website_ids', 'in', request.website.id)]
domain += ['|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id)]
forums = request.env['forum.forum'].search(domain)
return request.render("website_forum.forum_all", {'forums': forums})
@ -120,7 +120,7 @@ class WebsiteForum(http.Controller):
def questions(self, forum, tag=None, page=1, filters='all', sorting=None, search='', post_type=None, **post):
Post = request.env['forum.post']
domain = [('forum_id', '=', forum.id), ('parent_id', '=', False), ('state', '=', 'active'), ('website_id', '=', request.website.id)]
domain = [('forum_id', '=', forum.id), ('parent_id', '=', False), ('state', '=', 'active'), '|', ('website_id', '=', request.website.id), ('website_id', '=', False)]
if search:
domain += ['|', ('name', 'ilike', search), ('content', 'ilike', search)]
if tag:
@ -555,9 +555,9 @@ class WebsiteForum(http.Controller):
def users(self, forum, page=1, **searches):
User = request.env['res.users']
step = 30
tag_count = User.sudo().search_count([('karma', '>', 1), ('website_published', '=', True), (('website_ids', '!=', False), ('website_ids', 'in', request.website.id))])
tag_count = User.sudo().search_count([('karma', '>', 1), ('website_published', '=', True), ('|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id))])
pager = request.website.pager(url="/forum/%s/users" % slug(forum), total=tag_count, page=page, step=step, scope=30)
user_obj = User.sudo().search([('karma', '>', 1), ('website_published', '=', True), (('website_ids', '!=', False), ('website_ids', 'in', request.website.id))], limit=step, offset=pager['offset'], order='karma DESC')
user_obj = User.sudo().search([('karma', '>', 1), ('website_published', '=', True), ('|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id))], limit=step, offset=pager['offset'], order='karma DESC')
# put the users in block of 3 to display them as a table
users = [[] for i in range(len(user_obj) // 3 + 1)]
for index, user in enumerate(user_obj):

View File

@ -191,7 +191,7 @@ class WebsiteSale(http.Controller):
if attrib:
domain += [('attribute_line_ids.value_ids', 'in', ids)]
if not request.env.user.has_group('website.group_website_publisher'):
domain += [('website_ids', 'in', request.website.id)]
domain += ['|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id)]
if tag_values:
domain += [('tag_ids', 'in', tag_values)]
@ -254,7 +254,7 @@ class WebsiteSale(http.Controller):
if attrib_list:
post['attrib'] = attrib_list
categs = request.env['product.public.category'].search([('parent_id', '=', False), ('website_ids', 'in', request.website.id)])
categs = request.env['product.public.category'].search([('parent_id', '=', False), '|', ('website_ids', '=', False), ('website_ids', 'in', request.website.id)])
Product = request.env['product.template']
parent_category_ids = []
@ -290,7 +290,6 @@ class WebsiteSale(http.Controller):
tags = ProductTag.browse(tag_set)
limits = request.env['product.view.limit'].search([])
values = {
'search': search,
'category': category,

View File

@ -229,7 +229,7 @@
<t t-foreach="products" t-as="product">
<div id="grid_list"
class="col-md-4 oe_product oe_grid oe_product_cart oe-height-4"
t-att-data-publish="website in product.website_ids and 'on' or 'off'">
t-attf-data-publish="#{product.website_published &amp; (not product.website_ids or website in product.website_ids) and 'on' or 'off'}">
<t t-call="website_sale.products_item">
</t>
</div>
@ -288,7 +288,7 @@
<!-- Add to cart button-->
<template id="categories_recursive" name="Category list">
<li t-att-class="'active' if c.id == int(category or 0) else None" t-if="website in c.website_ids">
<li t-att-class="'active' if c.id == int(category or 0) else None" t-if="website in c.website_ids or not c.website_ids">
<a t-att-href="keep('/shop/category/' + slug(c), category=0)" t-field="c.name"></a>
<ul t-if="c.child_id" class="nav nav-pills nav-stacked nav-hierarchy">
<t t-foreach="c.child_id" t-as="c">
@ -395,7 +395,7 @@
<template id="products_list_view" inherit_id="website_sale.products" name="List View" active="False">
<xpath expr="//div[@id='products_grid']/t/div[@id='grid_list']" position="replace">
<div class="oe_product oe_list oe_product_cart"
t-att-data-publish="website in product.website_ids and 'on' or 'off'">
t-attf-data-publish="#{product.website_published &amp; (not product.website_ids or website in product.website_ids) and 'on' or 'off'}">
<t t-call="website_sale.products_item">
<t t-set="show_publish" t-value="True" />
</t>
@ -1757,7 +1757,7 @@
<template id="quick_view_products_item" inherit_id="website_sale.products_item"
active="True" customize_show="True" name="Product Quick View">
<xpath expr="//div[hasclass('oe_product_image')]/a[1]" position="after">
<div t-attf-class="quick" t-if="product.website_published and website in product.website_ids">
<div t-attf-class="quick" t-if="(not product.website_ids or website in product.website_ids) and product.website_published">
<div class="quick-view-bgr">
<a class="quick-view btn btn-primary" t-attf-href="##{ product.id }"
role="button" data-toggle="modal" title="Quick view">