2013-09-20 13:56:43 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
# Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2014-03-27 07:23:34 +00:00
|
|
|
import random
|
|
|
|
import werkzeug
|
|
|
|
from datetime import datetime
|
|
|
|
|
2013-09-20 13:56:43 +00:00
|
|
|
from openerp.addons.web import http
|
|
|
|
from openerp.addons.web.http import request
|
|
|
|
from openerp.tools.translate import _
|
2014-01-14 10:58:02 +00:00
|
|
|
from openerp import SUPERUSER_ID
|
2014-02-19 09:31:03 +00:00
|
|
|
from openerp.tools import html2plaintext
|
2013-11-18 14:35:30 +00:00
|
|
|
|
2013-09-30 14:33:57 +00:00
|
|
|
class WebsiteBlog(http.Controller):
|
2014-03-22 21:16:23 +00:00
|
|
|
_blog_post_per_page = 20
|
|
|
|
_post_comment_per_page = 10
|
2013-09-20 13:56:43 +00:00
|
|
|
|
2013-11-14 14:45:30 +00:00
|
|
|
def nav_list(self):
|
|
|
|
blog_post_obj = request.registry['blog.post']
|
2013-11-20 09:44:23 +00:00
|
|
|
groups = blog_post_obj.read_group(request.cr, request.uid, [], ['name', 'create_date'],
|
2013-11-18 10:33:29 +00:00
|
|
|
groupby="create_date", orderby="create_date asc", context=request.context)
|
|
|
|
for group in groups:
|
|
|
|
group['date'] = "%s_%s" % (group['__domain'][0][2], group['__domain'][1][2])
|
|
|
|
return groups
|
2013-11-14 14:45:30 +00:00
|
|
|
|
2014-01-20 15:37:33 +00:00
|
|
|
@http.route([
|
2013-11-17 10:16:57 +00:00
|
|
|
'/blog',
|
2014-03-22 21:16:23 +00:00
|
|
|
'/blog/page/<int:page>',
|
2014-01-20 15:37:33 +00:00
|
|
|
], type='http', auth="public", website=True, multilang=True)
|
2013-11-17 10:16:57 +00:00
|
|
|
def blogs(self, page=1):
|
|
|
|
BYPAGE = 60
|
|
|
|
cr, uid, context = request.cr, request.uid, request.context
|
|
|
|
blog_obj = request.registry['blog.post']
|
|
|
|
total = blog_obj.search(cr, uid, [], count=True, context=context)
|
|
|
|
pager = request.website.pager(
|
2014-03-14 16:23:46 +00:00
|
|
|
url='/blog',
|
2013-11-17 10:16:57 +00:00
|
|
|
total=total,
|
|
|
|
page=page,
|
|
|
|
step=BYPAGE,
|
|
|
|
)
|
2014-03-22 22:15:07 +00:00
|
|
|
bids = blog_obj.search(cr, uid, [], offset=pager['offset'], limit=BYPAGE, context=context)
|
2013-11-17 10:16:57 +00:00
|
|
|
blogs = blog_obj.browse(cr, uid, bids, context=context)
|
2013-11-18 10:33:29 +00:00
|
|
|
return request.website.render("website_blog.latest_blogs", {
|
2013-11-17 10:16:57 +00:00
|
|
|
'blogs': blogs,
|
|
|
|
'pager': pager
|
|
|
|
})
|
|
|
|
|
2014-01-20 15:37:33 +00:00
|
|
|
@http.route([
|
2014-03-22 21:16:23 +00:00
|
|
|
'/blog/<model("blog.blog"):blog>',
|
|
|
|
'/blog/<model("blog.blog"):blog>/page/<int:page>',
|
|
|
|
'/blog/<model("blog.blog"):blog>/tag/<model("blog.tag"):tag>',
|
|
|
|
'/blog/<model("blog.blog"):blog>/tag/<model("blog.tag"):tag>/page/<int:page>',
|
|
|
|
'/blog/<model("blog.blog"):blog>/date/<string(length=21):date>',
|
|
|
|
'/blog/<model("blog.blog"):blog>/date/<string(length=21):date>/page/<int:page>',
|
|
|
|
'/blog/<model("blog.blog"):blog>/tag/<model("blog.tag"):tag>/date/<string(length=21):date>',
|
|
|
|
'/blog/<model("blog.blog"):blog>/tag/<model("blog.tag"):tag>/date/<string(length=21):date>/page/<int:page>',
|
2014-01-20 15:37:33 +00:00
|
|
|
], type='http', auth="public", website=True, multilang=True)
|
2014-01-24 16:22:51 +00:00
|
|
|
def blog(self, blog=None, tag=None, date=None, page=1, **opt):
|
2013-09-23 13:47:02 +00:00
|
|
|
""" Prepare all values to display the blog.
|
|
|
|
|
2014-01-24 16:22:51 +00:00
|
|
|
:param blog: blog currently browsed.
|
2013-11-08 14:21:49 +00:00
|
|
|
:param tag: tag that is currently used to filter blog posts
|
2014-01-24 16:22:51 +00:00
|
|
|
:param integer page: current page of the pager. Can be the blog or
|
2013-09-23 13:47:02 +00:00
|
|
|
post pager.
|
2013-11-18 10:33:29 +00:00
|
|
|
:param date: date currently used to filter blog posts (dateBegin_dateEnd)
|
2013-09-23 13:47:02 +00:00
|
|
|
|
|
|
|
:return dict values: values for the templates, containing
|
|
|
|
|
|
|
|
- 'blog_posts': list of browse records that are the posts to display
|
2014-01-24 16:22:51 +00:00
|
|
|
in a given blog, if not blog_post_id
|
|
|
|
- 'blog': browse of the current blog, if blog_id
|
|
|
|
- 'blogs': list of browse records of blogs
|
|
|
|
- 'pager': the pager to display posts pager in a blog
|
2014-03-26 07:30:57 +00:00
|
|
|
- 'tag': current tag, if tag_id
|
2013-09-23 13:47:02 +00:00
|
|
|
- 'nav_list': a dict [year][month] for archives navigation
|
|
|
|
"""
|
2013-09-20 13:56:43 +00:00
|
|
|
cr, uid, context = request.cr, request.uid, request.context
|
|
|
|
blog_post_obj = request.registry['blog.post']
|
2013-09-30 14:33:57 +00:00
|
|
|
|
2014-01-24 16:22:51 +00:00
|
|
|
blog_obj = request.registry['blog.blog']
|
|
|
|
blog_ids = blog_obj.search(cr, uid, [], context=context)
|
|
|
|
blogs = blog_obj.browse(cr, uid, blog_ids, context=context)
|
2013-09-23 15:40:39 +00:00
|
|
|
|
2013-11-18 11:07:47 +00:00
|
|
|
path_filter = ""
|
2013-11-18 10:33:29 +00:00
|
|
|
domain = []
|
2014-01-24 16:22:51 +00:00
|
|
|
if blog:
|
|
|
|
path_filter += "%s/" % blog.id
|
2014-03-22 17:53:29 +00:00
|
|
|
domain += [("blog_id", "=", [blog.id])]
|
2013-11-18 10:33:29 +00:00
|
|
|
if tag:
|
2013-11-18 11:07:47 +00:00
|
|
|
path_filter += 'tag/%s/' % tag.id
|
2014-03-22 17:53:29 +00:00
|
|
|
domain += [("tag_ids", "in", [tag.id])]
|
2013-11-18 10:33:29 +00:00
|
|
|
if date:
|
2014-03-14 16:23:46 +00:00
|
|
|
path_filter += "date/%s" % date
|
2013-11-18 14:41:08 +00:00
|
|
|
domain += [("create_date", ">=", date.split("_")[0]), ("create_date", "<=", date.split("_")[1])]
|
2013-11-18 10:33:29 +00:00
|
|
|
|
2014-03-22 21:16:23 +00:00
|
|
|
blog_post_count = blog_post_obj.search(cr, uid, domain, count=True, context=context)
|
2013-11-14 14:45:30 +00:00
|
|
|
pager = request.website.pager(
|
2013-11-18 11:07:47 +00:00
|
|
|
url="/blog/%s" % path_filter,
|
2014-03-22 21:16:23 +00:00
|
|
|
total=blog_post_count,
|
2013-11-14 14:45:30 +00:00
|
|
|
page=page,
|
2014-01-24 16:22:51 +00:00
|
|
|
step=self._blog_post_per_page,
|
2014-03-22 21:16:23 +00:00
|
|
|
scope=10
|
2013-11-14 14:45:30 +00:00
|
|
|
)
|
2014-03-22 21:39:14 +00:00
|
|
|
blog_post_ids = blog_post_obj.search(cr, uid, domain, context=context, limit=self._blog_post_per_page, offset=pager['offset'])
|
|
|
|
blog_posts = blog_post_obj.browse(cr, uid, blog_post_ids, context=context)
|
2013-09-23 13:47:02 +00:00
|
|
|
|
2013-11-18 15:05:10 +00:00
|
|
|
tag_obj = request.registry['blog.tag']
|
|
|
|
tag_ids = tag_obj.search(cr, uid, [], context=context)
|
|
|
|
tags = tag_obj.browse(cr, uid, tag_ids, context=context)
|
|
|
|
|
2013-09-23 13:47:02 +00:00
|
|
|
values = {
|
2014-01-24 16:22:51 +00:00
|
|
|
'blog': blog,
|
|
|
|
'blogs': blogs,
|
2013-11-18 15:05:10 +00:00
|
|
|
'tags': tags,
|
2013-09-23 15:40:39 +00:00
|
|
|
'tag': tag,
|
|
|
|
'blog_posts': blog_posts,
|
2013-09-20 13:56:43 +00:00
|
|
|
'pager': pager,
|
2013-11-14 14:45:30 +00:00
|
|
|
'nav_list': self.nav_list(),
|
2013-11-18 11:07:47 +00:00
|
|
|
'path_filter': path_filter,
|
2013-11-18 14:35:30 +00:00
|
|
|
'date': date,
|
2013-09-23 13:47:02 +00:00
|
|
|
}
|
2014-02-16 05:41:55 +00:00
|
|
|
response = request.website.render("website_blog.blog_post_short", values)
|
|
|
|
return response
|
2013-09-20 13:56:43 +00:00
|
|
|
|
2014-01-20 15:37:33 +00:00
|
|
|
@http.route([
|
2014-03-22 21:16:23 +00:00
|
|
|
'/blog/<model("blog.blog"):blog>/post/<model("blog.post"):blog_post>',
|
2014-01-20 15:37:33 +00:00
|
|
|
], type='http', auth="public", website=True, multilang=True)
|
2014-03-22 21:16:23 +00:00
|
|
|
def blog_post(self, blog, blog_post, enable_editor=None, **post):
|
2013-11-14 14:45:30 +00:00
|
|
|
""" Prepare all values to display the blog.
|
|
|
|
|
|
|
|
:param blog_post: blog post currently browsed. If not set, the user is
|
2014-01-24 16:22:51 +00:00
|
|
|
browsing the blog and a post pager is calculated.
|
2013-11-14 14:45:30 +00:00
|
|
|
If set the user is reading the blog post and a
|
|
|
|
comments pager is calculated.
|
2014-01-24 16:22:51 +00:00
|
|
|
:param blog: blog currently browsed.
|
2013-11-18 11:07:47 +00:00
|
|
|
:param tag: tag that is currently used to filter blog posts
|
2014-01-24 16:22:51 +00:00
|
|
|
:param integer page: current page of the pager. Can be the blog or
|
2013-11-14 14:45:30 +00:00
|
|
|
post pager.
|
2013-11-18 11:07:47 +00:00
|
|
|
:param date: date currently used to filter blog posts (dateBegin_dateEnd)
|
2013-11-14 14:45:30 +00:00
|
|
|
|
|
|
|
- 'enable_editor': editor control
|
|
|
|
|
|
|
|
:return dict values: values for the templates, containing
|
|
|
|
|
|
|
|
- 'blog_post': browse of the current post, if blog_post_id
|
2014-01-24 16:22:51 +00:00
|
|
|
- 'blog': browse of the current blog, if blog_id
|
|
|
|
- 'blogs': list of browse records of blogs
|
2013-11-14 14:45:30 +00:00
|
|
|
- 'pager': the pager to display comments pager in a blog post
|
2013-11-18 11:07:47 +00:00
|
|
|
- 'tag': current tag, if tag_id
|
2013-11-14 14:45:30 +00:00
|
|
|
- 'nav_list': a dict [year][month] for archives navigation
|
2014-02-16 05:41:55 +00:00
|
|
|
- 'next_blog': next blog post , display in footer
|
2013-11-14 14:45:30 +00:00
|
|
|
"""
|
2013-11-15 08:56:32 +00:00
|
|
|
cr, uid, context = request.cr, request.uid, request.context
|
2014-03-22 21:16:23 +00:00
|
|
|
if not blog_post.blog_id.id==blog.id:
|
|
|
|
return request.redirect("/blog/%s/post/%s" % (blog_post.blog_id.id, blog_post.id))
|
2014-01-29 12:45:40 +00:00
|
|
|
blog_post_obj = request.registry.get('blog.post')
|
2014-02-23 18:12:05 +00:00
|
|
|
|
|
|
|
# Find next Post
|
|
|
|
visited_blogs = request.httprequest.cookies.get('visited_blogs') or ''
|
2014-03-22 21:16:23 +00:00
|
|
|
visited_ids = filter(None, visited_blogs.split(','))
|
|
|
|
visited_ids = map(lambda x: int(x), visited_ids)
|
2014-02-23 18:12:05 +00:00
|
|
|
if blog_post.id not in visited_ids:
|
|
|
|
visited_ids.append(blog_post.id)
|
|
|
|
next_post_id = blog_post_obj.search(cr, uid, [
|
|
|
|
('id', 'not in', visited_ids),
|
2014-03-22 21:16:23 +00:00
|
|
|
], order='ranking desc', limit=1, context=context)
|
2014-02-23 18:12:05 +00:00
|
|
|
next_post = next_post_id and blog_post_obj.browse(cr, uid, next_post_id[0], context=context) or False
|
2014-02-16 05:41:55 +00:00
|
|
|
|
2013-11-14 14:45:30 +00:00
|
|
|
values = {
|
2014-03-22 21:16:23 +00:00
|
|
|
'blog': blog,
|
2013-11-14 14:45:30 +00:00
|
|
|
'blog_post': blog_post,
|
2013-12-16 08:56:36 +00:00
|
|
|
'main_object': blog_post,
|
2013-11-14 14:45:30 +00:00
|
|
|
'enable_editor': enable_editor,
|
2014-02-16 05:41:55 +00:00
|
|
|
'next_post' : next_post,
|
2013-11-14 14:45:30 +00:00
|
|
|
}
|
2014-02-16 05:41:55 +00:00
|
|
|
response = request.website.render("website_blog.blog_post_complete", values)
|
2014-02-23 18:12:05 +00:00
|
|
|
response.set_cookie('visited_blogs', ','.join(map(str, visited_ids)))
|
2014-03-22 21:16:23 +00:00
|
|
|
|
|
|
|
# Increase counter and ranking ratio for order
|
|
|
|
d = datetime.now() - datetime.strptime(blog_post.create_date, "%Y-%m-%d %H:%M:%S")
|
|
|
|
blog_post_obj.write(cr, SUPERUSER_ID, [blog_post.id], {
|
|
|
|
'visits': blog_post.visits+1,
|
2014-03-22 22:42:09 +00:00
|
|
|
'ranking': blog_post.visits * (0.5+random.random()) / max(3, d.days)
|
2014-03-22 21:16:23 +00:00
|
|
|
},context=context)
|
2014-02-16 05:41:55 +00:00
|
|
|
return response
|
2014-02-23 18:12:05 +00:00
|
|
|
|
2014-02-24 09:22:55 +00:00
|
|
|
def _blog_post_message(self, user, blog_post_id=0, **post):
|
|
|
|
cr, uid, context = request.cr, request.uid, request.context
|
|
|
|
blog_post = request.registry['blog.post']
|
2014-03-27 07:23:34 +00:00
|
|
|
partner_obj = request.registry['res.partner']
|
|
|
|
thread_obj = request.registry['mail.thread']
|
|
|
|
website = request.registry['website']
|
|
|
|
|
|
|
|
public_id = website.get_public_user(cr, uid, context)
|
|
|
|
if uid != public_id:
|
|
|
|
partner_ids = [user.partner_id.id]
|
|
|
|
else:
|
|
|
|
partner_ids = blog_post._find_partner_from_emails(
|
|
|
|
cr, SUPERUSER_ID, 0, [post.get('email')], context=context)
|
|
|
|
if not partner_ids or not partner_ids[0]:
|
|
|
|
partner_ids = [partner_obj.create(cr, SUPERUSER_ID, {'name': post.get('name'), 'email': post.get('email')}, context=context)]
|
|
|
|
|
2014-02-24 09:22:55 +00:00
|
|
|
message_id = blog_post.message_post(
|
2014-03-23 19:55:31 +00:00
|
|
|
cr, SUPERUSER_ID, int(blog_post_id),
|
2014-02-24 09:22:55 +00:00
|
|
|
body=post.get('comment'),
|
|
|
|
type='comment',
|
|
|
|
subtype='mt_comment',
|
2014-03-27 07:23:34 +00:00
|
|
|
author_id=partner_ids[0],
|
2014-02-24 09:22:55 +00:00
|
|
|
discussion=post.get('discussion'),
|
|
|
|
context=dict(context, mail_create_nosubcribe=True))
|
|
|
|
return message_id
|
|
|
|
|
|
|
|
@http.route(['/blogpost/comment'], type='http', auth="public", methods=['POST'], website=True)
|
|
|
|
def blog_post_comment(self, blog_post_id=0, **post):
|
2013-09-20 13:56:43 +00:00
|
|
|
cr, uid, context = request.cr, request.uid, request.context
|
2013-11-16 17:36:36 +00:00
|
|
|
if post.get('comment'):
|
2014-03-22 22:15:07 +00:00
|
|
|
user = request.registry['res.users'].browse(cr, uid, uid, context=context)
|
|
|
|
blog_post = request.registry['blog.post']
|
|
|
|
blog_post.check_access_rights(cr, uid, 'read')
|
|
|
|
self._blog_post_message(user, blog_post_id, **post)
|
2013-11-05 09:56:22 +00:00
|
|
|
return werkzeug.utils.redirect(request.httprequest.referrer + "#comments")
|
2013-09-20 13:56:43 +00:00
|
|
|
|
2014-03-25 13:20:42 +00:00
|
|
|
def _get_discussion_detail(self, ids, publish=False, **post):
|
2014-02-24 09:22:55 +00:00
|
|
|
cr, uid, context = request.cr, request.uid, request.context
|
2014-02-12 10:33:01 +00:00
|
|
|
values = []
|
2014-03-25 13:20:42 +00:00
|
|
|
mail_obj = request.registry.get('mail.message')
|
|
|
|
for message in mail_obj.browse(cr, SUPERUSER_ID, ids, context=context):
|
|
|
|
values.append({
|
|
|
|
"id": message.id,
|
2014-03-27 07:23:34 +00:00
|
|
|
"author_name": message.author_id.name,
|
|
|
|
"author_image": message.author_id.image and \
|
2014-03-25 13:20:42 +00:00
|
|
|
("data:image/png;base64,%s" % message.author_id.image) or \
|
2014-03-23 19:55:31 +00:00
|
|
|
'/website_blog/static/src/img/anonymous.png',
|
2014-03-25 13:20:42 +00:00
|
|
|
"date": message.date,
|
|
|
|
'body': html2plaintext(message.body),
|
|
|
|
'website_published' : message.website_published,
|
|
|
|
'publish' : publish,
|
|
|
|
})
|
2014-02-12 10:33:01 +00:00
|
|
|
return values
|
2014-03-25 13:20:42 +00:00
|
|
|
|
|
|
|
@http.route(['/blogpost/post_discussion'], type='json', auth="public", website=True)
|
|
|
|
def post_discussion(self, blog_post_id=0, **post):
|
|
|
|
cr, uid, context = request.cr, request.uid, request.context
|
|
|
|
publish = request.registry['res.users'].has_group(cr, uid, 'base.group_website_publisher')
|
|
|
|
user = request.registry['res.users'].browse(cr, uid, uid, context=context)
|
|
|
|
id = self._blog_post_message(user, blog_post_id, **post)
|
|
|
|
return self._get_discussion_detail([id], publish, **post)
|
2014-02-12 10:33:01 +00:00
|
|
|
|
2014-01-20 15:37:33 +00:00
|
|
|
@http.route('/blogpost/new', type='http', auth="public", website=True, multilang=True)
|
2014-01-24 16:22:51 +00:00
|
|
|
def blog_post_create(self, blog_id, **post):
|
2013-09-20 13:56:43 +00:00
|
|
|
cr, uid, context = request.cr, request.uid, request.context
|
|
|
|
create_context = dict(context, mail_create_nosubscribe=True)
|
2014-03-22 21:21:13 +00:00
|
|
|
new_blog_post_id = request.registry['blog.post'].create(cr, uid, {
|
2014-01-24 16:22:51 +00:00
|
|
|
'blog_id': blog_id,
|
2013-12-03 15:48:39 +00:00
|
|
|
'name': _("Blog Post Title"),
|
2014-03-05 12:19:25 +00:00
|
|
|
'sub_title': _("Subtitle"),
|
2013-09-20 13:56:43 +00:00
|
|
|
'content': '',
|
|
|
|
'website_published': False,
|
|
|
|
}, context=create_context)
|
2014-03-22 21:21:13 +00:00
|
|
|
return werkzeug.utils.redirect("/blog/%s/post/%s/?enable_editor=1" % (blog_id, new_blog_post_id))
|
2013-10-11 13:00:59 +00:00
|
|
|
|
2014-01-20 15:37:33 +00:00
|
|
|
@http.route('/blogpost/duplicate', type='http', auth="public", website=True)
|
2013-11-25 12:47:22 +00:00
|
|
|
def blog_post_copy(self, blog_post_id, **post):
|
2013-11-18 14:35:30 +00:00
|
|
|
""" Duplicate a blog.
|
|
|
|
|
|
|
|
:param blog_post_id: id of the blog post currently browsed.
|
|
|
|
|
|
|
|
:return redirect to the new blog created
|
|
|
|
"""
|
2013-10-11 13:00:59 +00:00
|
|
|
cr, uid, context = request.cr, request.uid, request.context
|
|
|
|
create_context = dict(context, mail_create_nosubscribe=True)
|
2014-03-22 21:21:13 +00:00
|
|
|
nid = request.registry['blog.post'].copy(cr, uid, blog_post_id, {}, context=create_context)
|
|
|
|
post = request.registry['blog.post'].browse(cr, uid, nid, context)
|
|
|
|
return werkzeug.utils.redirect("/blog/%s/post/%s/?enable_editor=1" % (post.blog_id.id, nid))
|
2014-01-30 13:25:28 +00:00
|
|
|
|
2014-03-13 11:14:52 +00:00
|
|
|
@http.route('/blogpost/get_discussion/', type='json', auth="public", website=True)
|
2014-03-25 13:20:42 +00:00
|
|
|
def discussion(self, post_id=0, discussion=None, count=False, **post):
|
2014-03-22 22:15:07 +00:00
|
|
|
cr, uid, context = request.cr, request.uid, request.context
|
2014-02-07 10:17:02 +00:00
|
|
|
mail_obj = request.registry.get('mail.message')
|
2014-03-25 11:04:28 +00:00
|
|
|
domain = [('res_id', '=', int(post_id)) ,('model','=','blog.post'), ('discussion', '=', discussion)]
|
|
|
|
#check current user belongs to website publisher group
|
2014-03-25 13:20:42 +00:00
|
|
|
publish = request.registry['res.users'].has_group(cr, uid, 'base.group_website_publisher')
|
|
|
|
if not publish:
|
2014-03-25 11:04:28 +00:00
|
|
|
domain.append(('website_published', '=', True))
|
2014-03-25 13:20:42 +00:00
|
|
|
ids = mail_obj.search(cr, SUPERUSER_ID, domain, count=count)
|
|
|
|
if count:
|
|
|
|
return ids
|
|
|
|
return self._get_discussion_detail(ids, publish, **post)
|
2014-02-16 05:41:55 +00:00
|
|
|
|
2014-02-13 13:36:54 +00:00
|
|
|
@http.route('/blogpsot/change_background', type='json', auth="public", website=True)
|
2014-03-22 22:15:07 +00:00
|
|
|
def change_bg(self, post_id=0, image=None, **post):
|
2014-02-13 13:36:54 +00:00
|
|
|
post_obj = request.registry.get('blog.post')
|
|
|
|
values = {'content_image' : image}
|
2014-03-25 11:04:28 +00:00
|
|
|
|
2014-03-22 22:15:07 +00:00
|
|
|
ids = post_obj.write(request.cr, request.uid, [int(post_id)], values, request.context)
|
2014-02-13 13:36:54 +00:00
|
|
|
return []
|
2014-02-24 11:03:52 +00:00
|
|
|
|
2014-03-25 11:04:28 +00:00
|
|
|
@http.route('/blog/get_user/', type='json', auth="public", website=True)
|
|
|
|
def get_user(self, **post):
|
|
|
|
return [False if request.session.uid else True]
|