class WebsiteBlog(http.Controller):
- _category_post_per_page = 6
+ _blog_post_per_page = 6
_post_comment_per_page = 6
def nav_list(self):
})
@http.route([
- '/blog/<model("blog.category"):category>/',
- '/blog/<model("blog.category"):category>/page/<int:page>/',
- '/blog/<model("blog.category"):category>/tag/<model("blog.tag"):tag>/',
- '/blog/<model("blog.category"):category>/tag/<model("blog.tag"):tag>/page/<int:page>/',
- '/blog/<model("blog.category"):category>/date/<string(length=21):date>/',
- '/blog/<model("blog.category"):category>/date/<string(length=21):date>/page/<int:page>/',
- '/blog/<model("blog.category"):category>/tag/<model("blog.tag"):tag>/date/<string(length=21):date>/',
- '/blog/<model("blog.category"):category>/tag/<model("blog.tag"):tag>/date/<string(length=21):date>/page/<int:page>/',
+ '/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>/',
], type='http', auth="public", website=True, multilang=True)
- def blog(self, category=None, tag=None, date=None, page=1, **opt):
+ def blog(self, blog=None, tag=None, date=None, page=1, **opt):
""" Prepare all values to display the blog.
- :param category: category currently browsed.
+ :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 category or
+ :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 category, if not blog_post_id
- - 'category': browse of the current category, if category_id
- - 'categories': list of browse records of categories
- - 'pager': the pager to display posts pager in a category
+ 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
- 'nav_list': a dict [year][month] for archives navigation
"""
blog_posts = None
- category_obj = request.registry['blog.category']
- category_ids = category_obj.search(cr, uid, [], context=context)
- categories = category_obj.browse(cr, uid, category_ids, context=context)
+ 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)
path_filter = ""
domain = []
- if category:
- path_filter += "%s/" % category.id
- domain += [("id", "in", [blog.id for blog in category.blog_post_ids])]
+ if blog:
+ path_filter += "%s/" % blog.id
+ domain += [("id", "in", [post.id for post in blog.blog_post_ids])]
if tag:
path_filter += 'tag/%s/' % tag.id
- domain += [("id", "in", [blog.id for blog in tag.blog_post_ids])]
+ domain += [("id", "in", [post.id for post in tag.blog_post_ids])]
if date:
path_filter += "date/%s/" % date
domain += [("create_date", ">=", date.split("_")[0]), ("create_date", "<=", date.split("_")[1])]
url="/blog/%s" % path_filter,
total=len(blog_posts),
page=page,
- step=self._category_post_per_page,
+ step=self._blog_post_per_page,
scope=BYPAGE
)
- pager_begin = (page - 1) * self._category_post_per_page
- pager_end = page * self._category_post_per_page
+ pager_begin = (page - 1) * self._blog_post_per_page
+ pager_end = page * self._blog_post_per_page
blog_posts = blog_posts[pager_begin:pager_end]
tag_obj = request.registry['blog.tag']
tags = tag_obj.browse(cr, uid, tag_ids, context=context)
values = {
- 'category': category,
- 'categories': categories,
+ 'blog': blog,
+ 'blogs': blogs,
'tags': tags,
'tag': tag,
'blog_posts': blog_posts,
""" Prepare all values to display the blog.
:param blog_post: blog post currently browsed. If not set, the user is
- browsing the category and a post pager is calculated.
+ 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 category: category currently browsed.
+ :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 category or
+ :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_post': browse of the current post, if blog_post_id
- - 'category': browse of the current category, if category_id
- - 'categories': list of browse records of categories
+ - 'blog': browse of the current blog, if blog_id
+ - 'blogs': list of browse records of blogs
- 'pager': the pager to display comments pager in a blog post
- 'tag': current tag, if tag_id
- 'nav_list': a dict [year][month] for archives navigation
blog_post.website_message_ids = blog_post.website_message_ids[pager_begin:pager_end]
cr, uid, context = request.cr, request.uid, request.context
- category_obj = request.registry['blog.category']
- category_ids = category_obj.search(cr, uid, [], context=context)
- categories = category_obj.browse(cr, uid, category_ids, context=context)
+ 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)
values = {
- 'category': blog_post.category_id,
- 'categories': categories,
+ 'blog': blog_post.blog_id,
+ 'blogs': blogs,
'tags': tags,
'tag': tag and request.registry['blog.tag'].browse(cr, uid, int(tag), context=context) or None,
'blog_post': blog_post,
return werkzeug.utils.redirect(request.httprequest.referrer + "#comments")
@http.route('/blogpost/new', type='http', auth="public", website=True, multilang=True)
- def blog_post_create(self, category_id, **post):
+ def blog_post_create(self, blog_id, **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(
request.cr, request.uid, {
- 'category_id': category_id,
+ 'blog_id': blog_id,
'name': _("Blog Post Title"),
'content': '',
'website_published': False,
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data noupdate="1">
- <!-- CATEGORIES -->
- <record id="blog_category_1" model="blog.category">
+ <record id="blog_blog_1" model="blog.blog">
<field name="name">News</field>
<field name="description">Presentation of new OpenERP features</field>
</record>
<record id="menu_blog" model="website.menu">
<field name="name">News</field>
- <field name="url" eval="'/blog/'+str(ref('website_blog.blog_category_1'))"/>
+ <field name="url" eval="'/blog/'+str(ref('website_blog.blog_blog_1'))"/>
<field name="parent_id" ref="website.main_menu"/>
<field name="sequence" type="int">40</field>
</record>
<record id="action_open_website" model="ir.actions.act_url">
<field name="name">Website Blogs</field>
<field name="target">self</field>
- <field name="url" eval="'/blog/'+str(ref('website_blog.blog_category_1'))+'/?tutorial.blog=true'"/>
+ <field name="url" eval="'/blog/'+str(ref('website_blog.blog_blog_1'))+'/?tutorial.blog=true'"/>
</record>
<record id="base.open_menu" model="ir.actions.todo">
<field name="action_id" ref="action_open_website"/>
</record>
<!-- Project-related subtypes for messaging / Chatter -->
- <record id="mt_blog_category_post_new" model="mail.message.subtype">
+ <record id="mt_blog_blog_post_new" model="mail.message.subtype">
<field name="name">New Post</field>
- <field name="res_model">blog.category</field>
+ <field name="res_model">blog.blog</field>
<field name="default" eval="True"/>
<field name="parent_id" eval="ref('mt_blog_post_new')"/>
- <field name="relation_field">category_id</field>
+ <field name="relation_field">blog_id</field>
</record>
<!-- POSTS -->
<record id="blog_post_1" model="blog.post">
<field name="name">OpenERP v8 New Features</field>
- <field name="category_id" ref="blog_category_1"/>
+ <field name="blog_id" ref="blog_blog_1"/>
<field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1')])]"/>
<field name="website_published" eval="True"/>
<field name="website_meta_keywords">OpenERP, Point of Sale, Hardware, Interface, Payment Terminal, Store</field>
<record id="blog_post_2" model="blog.post">
<field name="name">New Hardware Integration</field>
- <field name="category_id" ref="blog_category_1"/>
+ <field name="blog_id" ref="blog_blog_1"/>
<field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1')])]"/>
<field name="content">
<![CDATA[<section class="mt16 mb16" data-snippet-id='big-picture'>
<record id="blog_post_3" model="blog.post">
<field name="name">Touchscreen Point of Sale for 6.1</field>
- <field name="category_id" ref="blog_category_1"/>
+ <field name="blog_id" ref="blog_blog_1"/>
<field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1'), ref('blog_tag_2')])]"/>
<field name="website_meta_keywords">Point of Sale, Hardware, Interface, Payment Terminal, Store</field>
<field name="website_meta_description">Point of Sale with no installation required that runs online and offline.</field>
<record id="blog_post_4" model="blog.post">
<field name="name">Announcing a New Partnership</field>
- <field name="category_id" ref="blog_category_1"/>
+ <field name="blog_id" ref="blog_blog_1"/>
<field name="tag_ids" eval="[(6, 0, [ref('blog_tag_1')])]"/>
<field name="website_published" eval="True"/>
<field name="website_meta_keywords">OpenERP, Partnership, News, Accounting</field>
import difflib
-class BlogCategory(osv.Model):
- _name = 'blog.category'
- _description = 'Blog Category'
+class Blog(osv.Model):
+ _name = 'blog.blog'
+ _description = 'Blogs'
_inherit = ['mail.thread', 'website.seo.metadata']
_order = 'name'
'name': fields.char('Name', required=True),
'description': fields.text('Description'),
'blog_post_ids': fields.one2many(
- 'blog.post', 'category_id',
+ 'blog.post', 'blog_id',
'Blogs',
),
}
_columns = {
'name': fields.char('Title', required=True),
- 'category_id': fields.many2one(
- 'blog.category', 'Category',
+ 'blog_id': fields.many2one(
+ 'blog.blog', 'Blog',
required=True, ondelete='cascade',
),
'tag_ids': fields.many2many(
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink\r
-blog_category_all,blog.category,model_blog_category,,1,0,0,0\r
+blog_blog_all,blog.blog,model_blog_blog,,1,0,0,0\r
blog_post_all,blog.post,model_blog_post,,1,0,0,0\r
blog_post,blog.post,model_blog_post,base.group_document_user,1,1,1,1\r
blog_post_history,blog.post.history,model_blog_post_history,base.group_document_user,1,0,1,0\r
},
},
{
- stepId: 'choose-category',
+ stepId: 'choose-blog',
element: '.modal select',
placement: 'right',
title: "Which Blog?",
- content: "Blog posts are organized in multiple categories (news, job offers, events, etc). Select <em>News</em> and click <em>Continue</em>.",
+ content: "Blog posts are organized in multiple blogs (news, job offers, events, etc). Select <em>News</em> and click <em>Continue</em>.",
trigger: {
id: 'change',
},
},
{
- stepId: 'continue-category',
+ stepId: 'continue-blog',
element: '.modal button.btn-primary',
placement: 'right',
title: "Create Blog Post",
window_title: "New Blog Post",
select: "Select Blog",
init: function (field) {
- return website.session.model('blog.category')
+ return website.session.model('blog.blog')
.call('name_search', [], { context: website.get_context() });
},
}).then(function (cat_id) {
- document.location = '/blogpost/new?category_id=' + cat_id;
+ document.location = '/blogpost/new?blog_id=' + cat_id;
});
}
}),
-
- In order to test the document_page in OpenERP, I create a new page to category blog_category_1
+ In order to test the document_page in OpenERP, I create a new page to blog blog_blog_1
-
!record {model: blog.post, id: test_page0}:
name: Test Page0
- category_id: blog_category_1
+ blog_id: blog_blog_1
content: 'Test content
The Open ERP wiki allows you to manage your enterprise contents using wiki
FAQs, quality manuals, technical references, etc.'
# -
-# I check the category index contains my page.
+# I check the blog index contains my page.
# -
# !python {model: blog.post}: |
- # res = self.read(cr, uid, [ref('blog_category_1')], ['display_content'])
+ # res = self.read(cr, uid, [ref('blog_blog_1')], ['display_content'])
# assert res[0]['display_content'].find('Test Page') > 1
-
!record {model: blog.post, id: test_page0}:
<!-- 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-href="/blog/%(website_blog.blog_category_1)d/">News</a></li>
+ <li><a t-href="/blog/%(website_blog.blog_blog_1)d/">News</a></li>
</xpath>
</template>
<div class="text-muted">
<span class="fa fa-calendar"> <span t-field="blog.create_date"/> &nbsp;</span>
<span class="fa fa-folder-open"> In
- <a t-href="/blog/#{ slug(blog.category_id) }">
- <span t-field="blog.category_id"/>
+ <a t-href="/blog/#{ slug(blog.blog_id) }">
+ <span t-field="blog.blog_id"/>
</a> &nbsp;
</span>
</div>
<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">
- <a t-href="/blog/#{ slug(category) }/tag/#{ slug(tag) }" t-esc="tag.name"/> &nbsp;
+ <a t-href="/blog/#{ slug(blog) }/tag/#{ slug(tag) }" t-esc="tag.name"/> &nbsp;
</t>
</p>
</xpath>
<div class="row">
<div class="col-sm-9">
<ol class="breadcrumb">
- <li><a t-href="/blog/#{ slug(category) }"><span t-field="category.name"/></a></li>
- <li t-if="tag"><a t-href="/blog/#{ slug(category) }/tag/#{ slug(tag) }"><span t-field="tag.name"/></a></li>
- <li t-if="tag and date"><a t-href="/blog/#{ slug(category) }/tag/#{ slug(tag) }/date/#{ date }" t-esc="date_name"/></li>
- <li t-if="not tag and date"><a t-href="/blog/#{ slug(category) }/date/#{ date }" t-esc="date_name"/></li>
+ <li><a t-href="/blog/#{ slug(blog) }"><span t-field="blog.name"/></a></li>
+ <li t-if="tag"><a t-href="/blog/#{ slug(blog) }/tag/#{ slug(tag) }"><span t-field="tag.name"/></a></li>
+ <li t-if="tag and date"><a t-href="/blog/#{ slug(blog) }/tag/#{ slug(tag) }/date/#{ date }" t-esc="date_name"/></li>
+ <li t-if="not tag and date"><a t-href="/blog/#{ slug(blog) }/date/#{ date }" t-esc="date_name"/></li>
<li class="active"><span t-field="blog_post.name"/></li>
</ol>
</div><div class="col-sm-3">
</xpath>
</template>
-<!-- Options: Blog Post: show category -->
-<template id="opt_blog_post_complete_category" name="Blog Category"
+<!-- Options: Blog Post: show blog -->
+<template id="opt_blog_post_complete_blog" name="Blog"
inherit_option_id="website_blog.blog_post_complete">
<xpath expr="//span[@class='fa fa-calendar oe_date']" position="after">
- <span class="fa fa-folder-open"> In <span t-field="blog_post.category_id"/> &nbsp;</span>
+ <span class="fa fa-folder-open"> In <span t-field="blog_post.blog_id"/> &nbsp;</span>
</xpath>
</template>
<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">
- <a t-href="/blog/#{ slug(category) }/tag/#{ slug(tag) }" t-esc="tag.name"/> &nbsp;
+ <a t-href="/blog/#{ slug(blog) }/tag/#{ slug(tag) }" t-esc="tag.name"/> &nbsp;
</t>
</p>
</xpath>
<ul class="nav nav-pills nav-stacked">
<t t-foreach="tags" t-as="tag_id">
<li t-att-class="tag and tag_id.id == tag.id and 'active' or None" style="display: inline-block;">
- <a t-href="/blog/#{ slug(category) }/tag/#{ slug(tag_id) }"><span t-field="tag_id.name"/></a>
+ <a t-href="/blog/#{ slug(blog) }/tag/#{ slug(tag_id) }"><span t-field="tag_id.name"/></a>
</li>
</t>
</ul>
<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/#{ slug(category) }/#{ tag and 'tag/%s/' % slug(tag) or '' }date/#{ months['date'] }"><t t-esc="months['create_date']"/><span class="pull-right badge" t-esc="months['create_date_count']"/></a>
+ <a t-ignore="True" t-href="/blog/#{ slug(blog) }/#{ tag and 'tag/%s/' % slug(tag) 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>
</xpath>
<xpath expr="//div[@id='blog_right_column']" position="inside">
<section class="mt32">
- <h4>Follow us<small t-if="category">: <t t-esc="category.name"/></small></h4>
- <t t-if="category">
+ <h4>Follow us<small t-if="blog">: <t t-esc="blog.name"/></small></h4>
+ <t t-if="blog">
<t t-call="website_mail.follow">
<t t-set="email" t-value="user_id.email"/>
- <t t-set="object" t-value="category"/>
+ <t t-set="object" t-value="blog"/>
</t>
</t>
<p class="text-muted mb0 mt16">
</xpath>
</template>
-<!-- Option: Right Column: categories -->
-<template id="opt_blog_rc_categories" name="Our Blogs" priority="6"
+<!-- Option: Right Column: blogs -->
+<template id="opt_blog_rc_blogs" name="Our Blogs" priority="6"
inherit_option_id="website_blog.index">
<xpath expr="//div[@id='blog_left_column']" position="attributes">
<attribute name="class">col-lg-8 col-sm-8</attribute>
<section class="mt32 mb32">
<h4>Our Blogs</h4>
<ul class="nav nav-pills nav-stacked">
- <t t-foreach="categories" t-as="nav_category">
- <li t-att-class="nav_category.id == category.id and 'active' or ''">
- <a t-href="/blog/#{ slug(nav_category) }">
- <span t-field="nav_category.name"/>
+ <t t-foreach="blogs" t-as="nav_blog">
+ <li t-att-class="nav_blog.id == blog.id and 'active' or ''">
+ <a t-href="/blog/#{ slug(nav_blog) }">
+ <span t-field="nav_blog.name"/>
</a>
</li>
</t>
<menuitem name="Knowledge" id="knowledge.menu_document"/>
<menuitem name="Blog Posts" id="menu_wiki" parent="knowledge.menu_document" sequence="20" />
- <!-- Category views -->
- <record model="ir.ui.view" id="view_blog_category_list">
- <field name="name">blog.category.list</field>
- <field name="model">blog.category</field>
+ <!-- Blog views -->
+ <record model="ir.ui.view" id="view_blog_blog_list">
+ <field name="name">blog.blog.list</field>
+ <field name="model">blog.blog</field>
<field name="arch" type="xml">
- <tree string="Blog Categories">
+ <tree string="Blogs">
<field name="name"/>
</tree>
</field>
</record>
- <record model="ir.ui.view" id="view_blog_category_form">
- <field name="name">blog.category.form</field>
- <field name="model">blog.category</field>
+ <record model="ir.ui.view" id="view_blog_blog_form">
+ <field name="name">blog.blog.form</field>
+ <field name="model">blog.blog</field>
<field name="arch" type="xml">
- <form string="Blog Category" version="7.0">
+ <form string="Blog" version="7.0">
<sheet>
<group>
<field name="name"/>
<field name="arch" type="xml">
<tree string="Blog Posts">
<field name="name"/>
- <field name="category_id"/>
+ <field name="blog_id"/>
<field name="create_uid" invisible="1"/>
<field name="write_uid"/>
<field name="write_date"/>
<h1><field name="name" placeholder="Name"/></h1>
<field name="tag_ids" widget="many2many_tags"/>
<group>
- <field name="category_id" string="Category"/>
+ <field name="blog_id"/>
</group>
<field name="content" placeholder="e.g. Once upon a time..." widget="html"/>
<group string="Technical" groups="base.group_no_one">
<search string="Blog Post">
<field name="name" string="Content" filter_domain="['|', ('name','ilike',self), ('content','ilike',self)]"/>
<field name="write_uid"/>
- <field name="category_id"/>
+ <field name="blog_id"/>
<group expand="0" string="Group By...">
- <filter string="Category" domain="[]" context="{'group_by': 'category_id'}"/>
+ <filter string="Blog" domain="[]" context="{'group_by': 'blog_id'}"/>
<filter string="Author" domain="[]" context="{'group_by': 'create_uid'}"/>
<filter string="Last Contributor" domain="[]" context="{'group_by': 'write_uid'}"/>
</group>
</record>
<menuitem id="menu_page" parent="menu_wiki" name="Blog Posts" action="action_blog_post" sequence="10"/>
- <record model="ir.actions.act_window" id="action_blog_category">
- <field name="name">Category</field>
- <field name="res_model">blog.category</field>
+ <record model="ir.actions.act_window" id="action_blog_blog">
+ <field name="name">Blogs</field>
+ <field name="res_model">blog.blog</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
- <menuitem id="menu_category" parent="menu_wiki" name="Categories" action="action_blog_category" sequence="20"/>
+ <menuitem id="menu_blog" parent="menu_wiki" name="Blogs" action="action_blog_blog" sequence="20"/>
<!-- History Tree view -->
<record model="ir.ui.view" id="view_blog_history_tree">