# -*- 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/>.
-#
-##############################################################################
import datetime
import werkzeug
def nav_list(self):
blog_post_obj = request.registry['blog.post']
- groups = blog_post_obj.read_group(request.cr, request.uid, [], ['name', 'create_date'],
+ groups = blog_post_obj.read_group(
+ request.cr, request.uid, [], ['name', 'create_date'],
groupby="create_date", orderby="create_date asc", context=request.context)
for group in groups:
begin_date = datetime.datetime.strptime(group['__domain'][0][2], tools.DEFAULT_SERVER_DATETIME_FORMAT).date()
def blog(self, blog=None, tag=None, page=1, **opt):
""" Prepare all values to display the blog.
- :param blog: blog currently browsed.
- :param tag: tag that is currently used to filter blog posts
- :param integer page: current page of the pager. Can be the blog or
- post pager.
- :param date: date currently used to filter blog posts (dateBegin_dateEnd)
-
:return dict values: values for the templates, containing
- - 'blog_posts': list of browse records that are the posts to display
- 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
- - 'tag': current tag, if tag_id
+ - 'blog': current blog
+ - 'blogs': all blogs for navigation
+ - 'pager': pager of posts
+ - 'tag': current tag
+ - 'tags': all tags, for navigation
- 'nav_list': a dict [year][month] for archives navigation
+ - 'date': date_begin optional parameter, used in archives navigation
+ - 'blog_url': help object to create URLs
"""
date_begin, date_end = opt.get('date_begin'), opt.get('date_end')
def blog_post(self, blog, blog_post, tag_id=None, page=1, enable_editor=None, **post):
""" Prepare all values to display the blog.
- :param blog_post: blog post currently browsed. If not set, the user is
- browsing the blog and a post pager is calculated.
- If set the user is reading the blog post and a
- comments pager is calculated.
- :param blog: blog currently browsed.
- :param tag: tag that is currently used to filter blog posts
- :param integer page: current page of the pager. Can be the blog or
- post pager.
- :param date: date currently used to filter blog posts (dateBegin_dateEnd)
-
- - 'enable_editor': editor control
-
:return dict values: values for the templates, containing
- - 'blog_post': browse of the current post, if blog_post_id
- - 'blog': browse of the current blog, if blog_id
+ - 'blog_post': browse of the current post
+ - 'blog': browse of the current blog
- 'blogs': list of browse records of blogs
- - 'pager': the pager to display comments pager in a blog post
- - 'tag': current tag, if tag_id
+ - 'tag': current tag, if tag_id in parameters
+ - 'tags': all tags, for tag-based navigation
+ - 'pager': a pager on the comments
- 'nav_list': a dict [year][month] for archives navigation
- - 'next_blog': next blog post , display in footer
+ - 'next_post': next blog post, to direct the user towards the next interesting post
"""
+ cr, uid, context = request.cr, request.uid, request.context
+ tag_obj = request.registry['blog.tag']
+ blog_post_obj = request.registry['blog.post']
date_begin, date_end = post.get('date_begin'), post.get('date_end')
pager_url = "/blogpost/%s" % blog_post.id
post_url = QueryURL('', ['blogpost'], blogpost=blog_post, tag_id=tag_id, date_begin=date_begin, date_end=date_end)
blog_url = QueryURL('', ['blog', 'tag'], blog=blog_post.blog_id, tag=tag, date_begin=date_begin, date_end=date_end)
- cr, uid, context = request.cr, request.uid, request.context
- if not blog_post.blog_id.id==blog.id:
+ if not blog_post.blog_id.id == blog.id:
return request.redirect("/blog/%s/post/%s" % (blog_post.blog_id.id, blog_post.id))
- blog_post_obj = request.registry.get('blog.post')
-
- 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)
- 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)
+ tags = tag_obj.browse(cr, uid, tag_obj.search(cr, uid, [], context=context), context=context)
# Find next Post
visited_blogs = request.httprequest.cookies.get('visited_blogs') or ''
visited_ids.append(blog_post.id)
next_post_id = blog_post_obj.search(cr, uid, [
('id', 'not in', visited_ids),
- ], order='ranking desc', limit=1, context=context)
+ ], order='ranking desc', limit=1, context=context)
next_post = next_post_id and blog_post_obj.browse(cr, uid, next_post_id[0], context=context) or False
+ print next_post
values = {
- 'blog': blog,
- 'blogs': blogs,
'tags': tags,
'tag': tag,
+ 'blog': blog,
'blog_post': blog_post,
'main_object': blog_post,
'nav_list': self.nav_list(),
'enable_editor': enable_editor,
- 'next_post' : next_post,
+ 'next_post': next_post,
'date': date_begin,
'post_url': post_url,
'blog_url': blog_url,
def discussion(self, post_id=0, discussion=None, count=False, **post):
cr, uid, context = request.cr, request.uid, request.context
mail_obj = request.registry.get('mail.message')
- domain = [('res_id', '=', int(post_id)) ,('model','=','blog.post'), ('discussion', '=', discussion)]
+ domain = [('res_id', '=', int(post_id)) ,('model','=','blog.post'), ('discussion_key', '=', discussion)]
#check current user belongs to website publisher group
publish = request.registry['res.users'].has_group(cr, uid, 'base.group_website_publisher')
if not publish:
return ids
return self._get_discussion_detail(ids, publish, **post)
- @http.route('/blogpsot/change_background', type='json', auth="public", website=True)
+ @http.route('/blogpost/change_background', type='json', auth="public", website=True)
def change_bg(self, post_id=0, image=None, **post):
- post_obj = request.registry.get('blog.post')
- values = {'content_image' : image}
-
- ids = post_obj.write(request.cr, request.uid, [int(post_id)], values, request.context)
- return []
+ if not post_id:
+ return False
+ return request.registry['blog.post'].write(request.cr, request.uid, [int(post_id)], {'background_image': image}, request.context)
@http.route('/blog/get_user/', type='json', auth="public", website=True)
def get_user(self, **post):
</t>
</template>
-
-<!-- Blog Post Summary -->
+<!-- Blog Post List: Displaying a list of Blog Posts -->
<template id="blog_post_short" name="Blog Posts">
<t t-call="website_blog.index">
<div class="oe_structure">
<div t-foreach="blog_posts" t-as="blog_post" class="mb32">
<img class="img-circle pull-right mt16"
- t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(blog_post.create_uid.partner_id.id)"
+ t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(blog_post.author_id.id)"
style="width: 50px;"/>
<a t-attf-href="/blog/#{ slug(blog_post.blog_id) }/post/#{ slug(blog_post) }">
<div class="text-muted">
<h4
- t-field="blog_post.sub_title"
+ t-field="blog_post.subtitle"
class="mb4 mt4"/>
- <p name='blog_post_data' class="mb0">
-
- <span t-field="blog_post.create_uid.partner_id.name"/>
+ <div name='blog_post_data' class='mb0'>
+ <span t-field="blog_post.author_id" style="display: inline-block;" t-field-options='{
+ "widget": "contact",
+ "fields": ["name"]
+ }'/>
  <span t-field="blog_post.create_date" t-field-options='{"format": "MMMM yyyy"}'/>
<span t-if="len(blog_post.message_ids) > 0">
  <t t-esc="len(blog_post.message_ids)"/>
</span>
<span t-if="not blog_post.website_published" class="label label-danger">not published</span>
- </p>
+ </div>
</div>
</div>
</t>
</template>
-<!-- Option: Blog Post Summary: show tags -->
+<!-- Option: Blog Post List: show tags -->
<template id="opt_blog_post_short_tags" name="Tags"
inherit_option_id="website_blog.blog_post_short" inherit_id="website_blog.blog_post_short">
- <xpath expr="//p[@name='blog_post_data']" position="after">
+ <xpath expr="//div[@name='blog_post_data']" position="inside">
<p class="post-meta text-muted text-center" t-if="len(blog_post.tag_ids)">
<span class="fa fa-tags"/>
<t t-foreach="blog_post.tag_ids" t-as="tag">
<template id="blog_post_complete" name="Blog Post">
<t t-call="website_blog.index">
- <div class="cover js_fullheight" id="title" t-attf-style="background-image: url(#{blog_post.content_image})" t-ignore="True">
+ <div class="cover js_fullheight" id="title" t-attf-style="background-image: url(#{blog_post.background_image})" t-ignore="True">
<div class="container">
<div class="container text-right mt16">
<div class="btn-group css_non_editable_mode_hidden">
</div>
<div class="blog_title">
<h1 t-field="blog_post.name" id="blog_post_name" t-att-data-blog-id="blog_post.id"/>
- <h2 t-field="blog_post.sub_title"/>
+ <h2 t-field="blog_post.subtitle"/>
<p class="post-meta text-muted text-center" name="blog_post_data"/>
<div>
- <img class="img-circle" t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(blog_post.create_uid.partner_id.id)" style="width: 30px; margin-right: 10px;"/>
- <small id="blog_author" t-field="blog_post.create_uid.partner_id.name"/><br/>
+ <img class="img-circle" t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(blog_post.author_id.id)" style="width: 30px; margin-right: 10px;"/>
+ <span t-field="blog_post.author_id" style="display: inline-block;" t-field-options='{
+ "widget": "contact",
+ "fields": ["name"]
+ }'/>
</div>
- <div t-if="blog_post.content_image" id="blog_angle_down">
+ <div t-if="blog_post.background_image" id="blog_angle_down">
<strong><a href="#blog_content" class="fa fa-angle-down fa-3x fa-inverse mt32"/></strong>
</div>
</div>
<t t-call="website.publish_short">
<t t-set="object" t-value="message"/>
</t>
- <strong t-field="message.author_id"/> <span class="text-muted">on <span t-field="message.date"/></span>
+ <!-- <strong t-field="message.author_id"/> -->
+ <span t-field="message.author_id" style="display: inline-block;" t-field-options='{
+ "widget": "contact",
+ "fields": ["name"]
+ }'/>
+ <span class="text-muted">on <span t-field="message.date"/></span>
<div t-field="message.body"/>
</div>
</li>
</section>
<t t-if="next_post">
- <div class="cover cover_footer mb0 text-center" t-attf-style="background-image: url(#{next_post.content_image})" t-ignore="True">
+ <div class="cover cover_footer mb0 text-center" t-attf-style="background-image: url(#{next_post.background_image})" t-ignore="True">
<div class="blog_title">
<a class="hidden js_next" t-attf-href="/blog/#{ slug(next_post.blog_id) }/post/#{ slug(next_post) }/#wrap"/>
<h1 t-field="next_post.name"/>
- <h2 t-field="next_post.sub_title"/>
+ <h2 t-field="next_post.subtitle"/>
<div>
- <img class="img-circle" t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(next_post.create_uid.partner_id.id)" style="width: 30px; margin-right: 10px;"/>
- <small id="blog_author" t-field="next_post.create_uid.partner_id.name"/>
+ <img class="img-circle" t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(next_post.author_id.id)" style="width: 30px; margin-right: 10px;"/>
+ <span t-field="next_post.author_id" style="display: inline-block;" t-field-options='{
+ "widget": "contact",
+ "fields": ["name"]
+ }'/>
</div>
<p class="mt32">Read Next <span class="fa fa-long-arrow-right"/></p>
</div>
</t>
</template>
+<!-- Options: Blog Post: breadcrumb -->
<template id="blog_breadcrumb" name="Breadcrumb"
inherit_option_id="website_blog.blog_post_complete">
<xpath expr="//div[@id='title']" position="before">