[IMP] ranking of blogs

bzr revid: fp@tinyerp.com-20140322213914-8f09g4k7p3lroehj
This commit is contained in:
Fabien Pinckaers 2014-03-22 22:39:14 +01:00
parent e740be4418
commit 552222b14a
2 changed files with 4 additions and 4 deletions

View File

@ -123,7 +123,8 @@ class WebsiteBlog(http.Controller):
step=self._blog_post_per_page,
scope=10
)
blog_posts = blog_post_obj.browse(cr, uid, blog_post_ids, context=context, limit=self._blog_post_per_page, offset=pager['offset'])
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)
tag_obj = request.registry['blog.tag']
tag_ids = tag_obj.search(cr, uid, [], context=context)
@ -201,7 +202,7 @@ class WebsiteBlog(http.Controller):
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,
'ranking': (blog_post.visits+1) * (1+random.random()) / max(1, 10+d.days)
'ranking': (blog_post.visits+1) * (0.5+random.random()) / max(1, d.days+10)
},context=context)
return response

View File

@ -12,7 +12,7 @@
<!-- Layout add nav and footer -->
<template id="header_footer_custom" inherit_id="website.layout" name="Footer News Blog Link">
<xpath expr="//footer//div[@name='info']/ul" position="inside">
<li><a t-attf-href="/blog/%(website_blog.blog_blog_1)d/">News</a></li>
<li><a t-attf-href="/blog/%(website_blog.blog_blog_1)d">News</a></li>
</xpath>
</template>
@ -195,7 +195,6 @@
<div id="blog_content" t-field="blog_post.content"/>
</div>
<!-- FP Note: should we remove this or put it in options? -->
<section id="comments" class="container">
<ul class="media-list" id="comments-list">
<li t-foreach="blog_post.website_message_ids" t-as="message" class="media">