[IMP] website_blog: add breadcrumb; [IMP] clean links
bzr revid: chm@openerp.com-20131118143530-5205sp6q7xp6lbj7
This commit is contained in:
@@ -27,6 +27,11 @@ from openerp.tools.translate import _
|
||||
import werkzeug
|
||||
|
||||
|
||||
MONTHS = [None, _('January'), _('February'), _('March'), _('April'),
|
||||
_('May'), _('June'), _('July'), _('August'), _('September'),
|
||||
_('October'), _('November'), _('December')]
|
||||
|
||||
|
||||
class WebsiteBlog(http.Controller):
|
||||
_category_post_per_page = 6
|
||||
_post_comment_per_page = 6
|
||||
@@ -62,17 +67,16 @@ class WebsiteBlog(http.Controller):
|
||||
})
|
||||
|
||||
@website.route([
|
||||
'/blog',
|
||||
'/blog/page/<int:page>/',
|
||||
'/blog/cat/<model("blog.category"):category>/',
|
||||
'/blog/cat/<model("blog.category"):category>/page/<int:page>/',
|
||||
'/blog/tag/<model("blog.tag"):tag>/',
|
||||
'/blog/tag/<model("blog.tag"):tag>/page/<int:page>/',
|
||||
'/blog/cat/<model("blog.category"):category>/tag/<model("blog.tag"):tag>/',
|
||||
'/blog/cat/<model("blog.category"):category>/tag/<model("blog.tag"):tag>/page/<int:page>/',
|
||||
'/blog/cat/<model("blog.category"):category>/date/<string(length=21):date>/',
|
||||
'/blog/tag/<model("blog.tag"):tag>/date/<string(length=21):date>/',
|
||||
'/blog/tag/<model("blog.tag"):tag>/date/<string(length=21):date>/page/<int:page>/',
|
||||
'/blog/cat/<model("blog.category"):category>/date/<string(length=21):date>/page/<int:page>/',
|
||||
'/blog/cat/<model("blog.category"):category>/tag/<model("blog.tag"):tag>/date/<string(length=21):date>/',
|
||||
'/blog/cat/<model("blog.category"):category>/tag/<model("blog.tag"):tag>/date/<string(length=21):date>/page/<int:page>/',
|
||||
], type='http', auth="public", multilang=True)
|
||||
def blog(self, category=None, tag=None, page=1, date=None):
|
||||
def blog(self, category=None, tag=None, date=None, page=1):
|
||||
""" Prepare all values to display the blog.
|
||||
|
||||
:param category: category currently browsed.
|
||||
@@ -113,8 +117,7 @@ class WebsiteBlog(http.Controller):
|
||||
domain += [("id", "=", [blog.id for blog in tag.blog_post_ids])]
|
||||
if date:
|
||||
path_filter += "date/%s/" % date
|
||||
date = date.split("_")
|
||||
domain = [("create_date", ">=", date[0]), ("create_date", "<=", date[1])]
|
||||
domain = [("create_date", ">=", date.split("_")[0]), ("create_date", "<=", date.split("_")[1])]
|
||||
|
||||
blog_post_ids = blog_post_obj.search(cr, uid, domain, context=context)
|
||||
blog_posts = blog_post_obj.browse(cr, uid, blog_post_ids, context=context)
|
||||
@@ -138,26 +141,14 @@ class WebsiteBlog(http.Controller):
|
||||
'pager': pager,
|
||||
'nav_list': self.nav_list(),
|
||||
'path_filter': path_filter,
|
||||
'date': date,
|
||||
}
|
||||
|
||||
if tag:
|
||||
values['main_object'] = tag
|
||||
elif category:
|
||||
values['main_object'] = category
|
||||
|
||||
return request.website.render("website_blog.blog_post_short", values)
|
||||
|
||||
@website.route([
|
||||
'/blog/<model("blog.post"):blog_post>/page/<int:page>/',
|
||||
'/blog/<model("blog.post"):blog_post>/cat/<model("blog.category"):category>/',
|
||||
'/blog/<model("blog.post"):blog_post>/cat/<model("blog.category"):category>/page/<int:page>/',
|
||||
'/blog/<model("blog.post"):blog_post>/tag/<model("blog.tag"):tag>/',
|
||||
'/blog/<model("blog.post"):blog_post>/tag/<model("blog.tag"):tag>/page/<int:page>/',
|
||||
'/blog/<model("blog.post"):blog_post>/cat/<model("blog.category"):category>/date/<string(length=21):date>/',
|
||||
'/blog/<model("blog.post"):blog_post>/tag/<model("blog.tag"):tag>/date/<string(length=21):date>/',
|
||||
'/blog/<model("blog.post"):blog_post>/tag/<model("blog.tag"):tag>/date/<string(length=21):date>/page/<int:page>/',
|
||||
'/blog/<model("blog.post"):blog_post>/',
|
||||
], type='http', auth="public", multilang=True)
|
||||
def blog_post(self, blog_post=None, category=None, tag=None, page=1, date=None, enable_editor=None, path_filter=''):
|
||||
def blog_post(self, blog_post=None, tag=None, date=None, page=1, enable_editor=None):
|
||||
""" Prepare all values to display the blog.
|
||||
|
||||
:param blog_post: blog post currently browsed. If not set, the user is
|
||||
@@ -184,9 +175,6 @@ class WebsiteBlog(http.Controller):
|
||||
|
||||
pager_url = "/blog/%s" % blog_post.id
|
||||
|
||||
if path_filter:
|
||||
pager_url += path_filter
|
||||
|
||||
pager = request.website.pager(
|
||||
url=pager_url,
|
||||
total=len(blog_post.website_message_ids),
|
||||
@@ -204,14 +192,15 @@ class WebsiteBlog(http.Controller):
|
||||
categories = category_obj.browse(cr, uid, category_ids, context=context)
|
||||
|
||||
values = {
|
||||
'category': category,
|
||||
'category': blog_post.category_id,
|
||||
'categories': categories,
|
||||
'tag': tag,
|
||||
'tag': tag and request.registry['blog.tag'].browse(cr, uid, int(tag), context=context) or None,
|
||||
'blog_post': blog_post,
|
||||
'pager': pager,
|
||||
'nav_list': self.nav_list(),
|
||||
'enable_editor': enable_editor,
|
||||
'path_filter': path_filter,
|
||||
'date': date,
|
||||
'date_name': date and "%s %s" % (MONTHS[int(date.split("-")[1])], date.split("-")[0]) or None
|
||||
}
|
||||
return request.website.render("website_blog.blog_post_complete", values)
|
||||
|
||||
@@ -227,8 +216,8 @@ class WebsiteBlog(http.Controller):
|
||||
context=dict(context, mail_create_nosubcribe=True))
|
||||
return werkzeug.utils.redirect(request.httprequest.referrer + "#comments")
|
||||
|
||||
@website.route(['/blog/<int:category_id><path:path_filter>/new'], type='http', auth="public", multilang=True)
|
||||
def blog_post_create(self, category_id=None, path_filter='', **post):
|
||||
@website.route(['/blog/new'], type='http', auth="public", multilang=True)
|
||||
def blog_post_create(self, category_id=None, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
create_context = dict(context, mail_create_nosubscribe=True)
|
||||
new_blog_post_id = request.registry['blog.post'].create(
|
||||
@@ -238,11 +227,17 @@ class WebsiteBlog(http.Controller):
|
||||
'content': '',
|
||||
'website_published': False,
|
||||
}, context=create_context)
|
||||
return werkzeug.utils.redirect("/blog/%s%s/?enable_editor=1" % (new_blog_post_id, path_filter))
|
||||
return werkzeug.utils.redirect("/blog/%s/?enable_editor=1" % new_blog_post_id)
|
||||
|
||||
@website.route(['/blog/<int:blog_post_id><path:path_filter>/duplicate'], type='http', auth="public")
|
||||
def blog_post_copy(self, blog_post_id=None, path_filter='', **post):
|
||||
@website.route(['/blog/duplicate'], type='http', auth="public")
|
||||
def blog_post_copy(self, blog_post_id=None, **post):
|
||||
""" Duplicate a blog.
|
||||
|
||||
:param blog_post_id: id of the blog post currently browsed.
|
||||
|
||||
:return redirect to the new blog created
|
||||
"""
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
create_context = dict(context, mail_create_nosubscribe=True)
|
||||
new_blog_post_id = request.registry['blog.post'].copy(cr, uid, blog_post_id, {}, context=create_context)
|
||||
return werkzeug.utils.redirect("/blog/%s%s/?enable_editor=1" % (new_blog_post_id, path_filter))
|
||||
return werkzeug.utils.redirect("/blog/%s/?enable_editor=1" % new_blog_post_id)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
.call('name_search', [], { context: website.get_context() });
|
||||
},
|
||||
}).then(function (cat_id) {
|
||||
document.location = '/blog/' + cat_id + '/new';
|
||||
document.location = '/blog/new?category_id=' + cat_id;
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<t t-foreach="blogs" t-as="blog">
|
||||
<div class="col-md-4">
|
||||
<h4>
|
||||
<a t-href="/blog/#{blog.id}/#{ path_filter }" t-field="blog.name"></a>
|
||||
<a t-href="/blog/#{blog.id}?#{ tag and 'tag=%s' % tag.id or '' }#{tag and date and '&' or ''}#{ date and 'date=%s' % date or ''}" t-field="blog.name"></a>
|
||||
<span t-if="not blog.website_published" class="text-warning">
|
||||
&nbsp;
|
||||
<span class="icon-warning-sign" title="Not published"/>
|
||||
@@ -73,7 +73,7 @@
|
||||
</div>
|
||||
<div class="text-muted" t-if="len(blog.message_ids) > 0">
|
||||
<span class="icon-comment">
|
||||
<a t-href="/blog/#{blog.id}/#{ path_filter }/#comment">
|
||||
<a t-href="/blog/#{blog.id}/?#{ tag and 'tag=%s' % tag.id or '' }#{tag and date and '&' or ''}#{ date and 'date=%s' % date or ''}#comment">
|
||||
<t t-if="len(blog.message_ids) <= 1" ><t t-esc="len(blog.message_ids)"/> comment</t>
|
||||
<t t-if="len(blog.message_ids) > 1"><t t-esc="len(blog.message_ids)"/> comments</t>
|
||||
</a>
|
||||
@@ -108,12 +108,12 @@
|
||||
<t t-foreach="blog_posts" t-as="blog_post">
|
||||
<div t-att-data-publish="blog_post.website_published and 'on' or 'off'">
|
||||
<h2 class="text-center">
|
||||
<a t-href="/blog/#{blog_post.id}/#{ path_filter }" t-field="blog_post.name"></a>
|
||||
<a t-href="/blog/#{blog_post.id}/?#{ tag and 'tag=%s' % tag.id or '' }#{tag and date and '&' or ''}#{ date and 'date=%s' % date or ''}" t-field="blog_post.name"></a>
|
||||
</h2>
|
||||
<p class="post-meta text-muted text-center" name='blog_post_data'>
|
||||
<span class="icon-calendar"> <span t-field="blog_post.create_date"/> &nbsp;</span>
|
||||
<span t-if="len(blog_post.message_ids) > 0" class="icon-comment">
|
||||
<a t-href="/blog/#{blog_post.id}/#{ path_filter }/#comment">
|
||||
<a t-href="/blog/#{blog_post.id}/?#{ tag and 'tag=%s' % tag.id or '' }#{tag and date and '&' or ''}#{ date and 'date=%s' % date or ''}#comment">
|
||||
<t t-if="len(blog_post.message_ids) <= 1" ><t t-esc="len(blog_post.message_ids)"/> comment</t>
|
||||
<t t-if="len(blog_post.message_ids) > 1"><t t-esc="len(blog_post.message_ids)"/> comments</t>
|
||||
</a>
|
||||
@@ -151,7 +151,7 @@
|
||||
<p class="post-meta text-muted text-center" t-if="len(blog_post.tag_ids)">
|
||||
<span class="icon-tags"/>
|
||||
<t t-foreach="blog_post.tag_ids" t-as="tag">
|
||||
<a t-href="/blog/tag/#{tag.id}" t-esc="tag.name"/> &nbsp;
|
||||
<a t-href="/blog/cat/#{ category.id }/tag/#{tag.id}" t-esc="tag.name"/> &nbsp;
|
||||
</t>
|
||||
</p>
|
||||
</xpath>
|
||||
@@ -160,12 +160,22 @@
|
||||
<!-- Blog Post Complete -->
|
||||
<template id="blog_post_complete" name="Blog Post">
|
||||
<t t-call="website_blog.index">
|
||||
<div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-9">
|
||||
<ol class="breadcrumb">
|
||||
<li><a t-href="/blog/cat/#{category.id}"><span t-field="category.name"/></a></li>
|
||||
<li t-if="tag"><a t-href="/blog/cat/#{ category.id }/tag/#{tag.id}"><span t-field="tag.name"/></a></li>
|
||||
<li t-if="tag and date"><a t-href="/blog/cat/#{ category.id }/tag/#{tag.id}/date/#{ date }" t-esc="date_name"/></li>
|
||||
<li t-if="not tag and date"><a t-href="/blog/cat/#{ category.id }/date/#{ date }" t-esc="date_name"/></li>
|
||||
<li class="active"><span t-field="blog_post.name"/></li>
|
||||
</ol>
|
||||
</div><div class="col-sm-3">
|
||||
<t t-call="website.publish_management">
|
||||
<t t-set="object" t-value="blog_post"/>
|
||||
<t t-set="publish_edit" t-value="True"/>
|
||||
<li>
|
||||
<a href="#" t-attf-data-href="/blog/#{blog_post.id}/#{ path_filter }/duplicate">Duplicate</a>
|
||||
<a href="#" t-attf-data-href="/blog/duplicate?blog_post_id=#{blog_post.id}">Duplicate</a>
|
||||
<script>
|
||||
var $a=$("[data-href$='/duplicate']");
|
||||
$a.attr("href", $a.data('href')).removeAttr('data-href');
|
||||
@@ -173,7 +183,9 @@
|
||||
</script>
|
||||
</li>
|
||||
</t>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix"/>
|
||||
|
||||
<h1 class="text-center" t-field="blog_post.name"/>
|
||||
@@ -253,7 +265,7 @@
|
||||
<p class="post-meta text-muted text-center" t-if="len(blog_post.tag_ids)">
|
||||
<span class="icon-tags"/>
|
||||
<t t-foreach="blog_post.tag_ids" t-as="tag">
|
||||
<a t-href="/blog/tag/#{tag.id}" t-esc="tag.name"/> &nbsp;
|
||||
<a t-href="/blog/cat/#{ category.id }/tag/#{tag.id}" t-esc="tag.name"/> &nbsp;
|
||||
</t>
|
||||
</p>
|
||||
</xpath>
|
||||
@@ -287,11 +299,12 @@
|
||||
<xpath expr="//div[@id='blog_right_column']" position="inside">
|
||||
<section class="mt32">
|
||||
<h4>Archives</h4>
|
||||
<ul class="list-unstyled">
|
||||
<li t-foreach="nav_list" t-as="months">
|
||||
<a t-ignore="True" t-href="/blog/#{ category and 'cat/%s/' % category.id or '' }#{ tag and 'tag/%s/' % tag.id or '' }date/#{ months['date'] }"><t t-esc="months['create_date']"/></a>
|
||||
<span class="pull-right badge" t-esc="months['create_date_count']"/>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<t t-foreach="nav_list" t-as="months">
|
||||
<li t-att-class="months['date'] == date and 'active' or None">
|
||||
<a t-ignore="True" t-href="/blog/cat/#{ category.id }/#{ tag and 'tag/%s/' % tag.id or '' }date/#{ months['date'] }"><t t-esc="months['create_date']"/><span class="pull-right badge" t-esc="months['create_date_count']"/></a>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
</section>
|
||||
</xpath>
|
||||
|
||||
@@ -32,7 +32,7 @@ class website_hr_recruitment(http.Controller):
|
||||
domain += [('address_id','=', office.id)]
|
||||
if department:
|
||||
domain += [('department_id','=', department.id)]
|
||||
jobpost_ids = hr_job_obj.search(request.cr, request.uid, domain, order="website_published,no_of_recruitment desc", context=request.context)
|
||||
jobpost_ids = hr_job_obj.search(request.cr, request.uid, domain, order="website_published desc,no_of_recruitment desc", context=request.context)
|
||||
jobs = hr_job_obj.browse(request.cr, request.uid, jobpost_ids, request.context)
|
||||
|
||||
return request.website.render("website_hr_recruitment.index", {
|
||||
|
||||
@@ -264,13 +264,9 @@ class Ecommerce(http.Controller):
|
||||
return False
|
||||
|
||||
@website.route(['/shop/filter/'], type='http', auth="public", multilang=True)
|
||||
def filter(self, add_filter="", **post):
|
||||
def filter(self, **post):
|
||||
index = []
|
||||
filter = []
|
||||
if add_filter:
|
||||
filter = simplejson.loads(add_filter)
|
||||
for filt in filter:
|
||||
index.append(filt[0])
|
||||
for key, val in post.items():
|
||||
cat = key.split("-")
|
||||
if len(cat) < 3 or cat[2] in ('max','minmem','maxmem'):
|
||||
@@ -295,7 +291,6 @@ class Ecommerce(http.Controller):
|
||||
|
||||
return request.redirect("/shop/?filter=%s%s%s%s" % (
|
||||
simplejson.dumps(filter),
|
||||
add_filter and "&add_filter=%s" % add_filter or "",
|
||||
post.get("search") and "&search=%s" % post.get("search") or "",
|
||||
post.get("category") and "&category=%s" % post.get("category") or ""
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user