[IMP] name is name (and not URL in case of links
This commit is contained in:
@@ -79,7 +79,7 @@ class WebsiteForum(http.Controller):
|
||||
'''/forum/<model("forum.forum"):forum>/tag/<model("forum.tag", "[('forum_id','=',forum[0])]"):tag>/questions''',
|
||||
'''/forum/<model("forum.forum"):forum>/tag/<model("forum.tag", "[('forum_id','=',forum[0])]"):tag>/questions/page/<int:page>''',
|
||||
], type='http', auth="public", website=True)
|
||||
def questions(self, forum, tag=None, page=1, filters='all', sorting='relevancy', search='', post_type='all', **post):
|
||||
def questions(self, forum, tag=None, page=1, filters='all', sorting=None, search='', post_type='all', **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
Post = request.registry['forum.post']
|
||||
user = request.registry['res.users'].browse(cr, uid, uid, context=context)
|
||||
@@ -103,17 +103,8 @@ class WebsiteForum(http.Controller):
|
||||
elif post_type == 'discussion':
|
||||
domain += [('type', '=', 'discussion')]
|
||||
|
||||
if sorting == 'answered':
|
||||
order = 'child_count desc'
|
||||
elif sorting == 'vote':
|
||||
order = 'vote_count desc'
|
||||
elif sorting == 'date':
|
||||
order = 'write_date desc'
|
||||
elif sorting == 'creation':
|
||||
order = 'create_date desc'
|
||||
else:
|
||||
sorting == 'relevancy'
|
||||
order = 'relevancy'
|
||||
if not sorting:
|
||||
sorting = forum.default_order
|
||||
|
||||
question_count = Post.search(cr, uid, domain, count=True, context=context)
|
||||
if tag:
|
||||
@@ -121,18 +112,18 @@ class WebsiteForum(http.Controller):
|
||||
else:
|
||||
url = "/forum/%s" % slug(forum)
|
||||
|
||||
url_args = {}
|
||||
url_args = {
|
||||
'sorting': sorting
|
||||
}
|
||||
if search:
|
||||
url_args['search'] = search
|
||||
if filters:
|
||||
url_args['filters'] = filters
|
||||
if sorting:
|
||||
url_args['sorting'] = sorting
|
||||
pager = request.website.pager(url=url, total=question_count, page=page,
|
||||
step=self._post_per_page, scope=self._post_per_page,
|
||||
url_args=url_args)
|
||||
|
||||
obj_ids = Post.search(cr, uid, domain, limit=self._post_per_page, offset=pager['offset'], order=order, context=context)
|
||||
obj_ids = Post.search(cr, uid, domain, limit=self._post_per_page, offset=pager['offset'], order=sorting, context=context)
|
||||
question_ids = Post.browse(cr, uid, obj_ids, context=context)
|
||||
|
||||
values = self._prepare_forum_values(forum=forum, searches=post)
|
||||
@@ -296,6 +287,7 @@ class WebsiteForum(http.Controller):
|
||||
'forum_id': forum.id,
|
||||
'name': post.get('post_name', ''),
|
||||
'content': post.get('content'),
|
||||
'content_link': post.get('content_link', False),
|
||||
'parent_id': post_parent and post_parent.id or False,
|
||||
'tag_ids': post_tag_ids,
|
||||
'type': post_parent and post_parent.type or post_type,
|
||||
|
||||
@@ -65,8 +65,8 @@ In simple words does Odoo became CMS+ERP platform?</p>]]></field>
|
||||
|
||||
<!-- Article-->
|
||||
<record id="article_0" model="forum.post">
|
||||
<field name="name">https://www.odoo.com/forum/how-to/developers-13/the-different-openerp-model-inheritance-mechanisms-whats-the-difference-between-them-and-when-should-they-be-used-46</field>
|
||||
<field name="content">OpenERP S.A. - The different "openerp model inheritance" mechanisms: what's the difference between them, and when should they be used ?</field>
|
||||
<field name="content_link">https://www.odoo.com</field>
|
||||
<field name="name">Discover Odoo, an open source ERP.</field>
|
||||
<field name="forum_id" ref="website_forum.forum_help"/>
|
||||
<field name="type">link</field>
|
||||
<field name="views">6</field>
|
||||
|
||||
@@ -30,10 +30,11 @@ class Forum(osv.Model):
|
||||
'relevancy_option_first': fields.float('First Relevancy Parameter'),
|
||||
'relevancy_option_second': fields.float('Second Relevancy Parameter'),
|
||||
'default_order': fields.selection([
|
||||
('creation','Newest'),
|
||||
('date','Last Updated'),
|
||||
('vote','Most Voted'),
|
||||
('relevancy','Relevancy'),
|
||||
('create_date desc','Newest'),
|
||||
('write_date desc','Last Updated'),
|
||||
('vote_count desc','Most Voted'),
|
||||
('relevancy desc','Relevancy'),
|
||||
('child_count desc','Answered'),
|
||||
], 'Default Order', required=True),
|
||||
'default_allow': fields.selection([('post_link','Link'),('ask_question','Question'),('post_discussion','Discussion')], 'Default Post', required=True),
|
||||
'allow_link': fields.boolean('Links', help="When clicking on the post, it redirects to an external link"),
|
||||
@@ -80,14 +81,14 @@ class Forum(osv.Model):
|
||||
return False
|
||||
|
||||
_defaults = {
|
||||
'default_order': 'date',
|
||||
'default_order': 'write_date desc',
|
||||
'allow_question': True,
|
||||
'default_allow': 'ask_question',
|
||||
'allow_link': False,
|
||||
'allow_discussion': False,
|
||||
'description': 'This community is for professionals and enthusiasts of our products and services.',
|
||||
'faq': _get_default_faq,
|
||||
'introduction_message': """<h1>Welcome to Odoo Forum</h1>
|
||||
'introduction_message': """<h1 class="mt0">Welcome!</h1>
|
||||
<p> This community is for professionals and enthusiasts of our products and services.
|
||||
Share and discuss the best content and new marketing ideas,
|
||||
build your professional profile and become a better marketer together.
|
||||
@@ -249,6 +250,7 @@ class Post(osv.Model):
|
||||
'name': fields.char('Title'),
|
||||
'forum_id': fields.many2one('forum.forum', 'Forum', required=True),
|
||||
'content': fields.html('Content'),
|
||||
'content_link': fields.char('URL', help="URL of Link Articles"),
|
||||
'tag_ids': fields.many2many('forum.tag', 'forum_tag_rel', 'forum_id', 'forum_tag_id', 'Tags'),
|
||||
'state': fields.selection([('active', 'Active'), ('close', 'Close'), ('offensive', 'Offensive')], 'Status'),
|
||||
'views': fields.integer('Number of Views'),
|
||||
|
||||
@@ -349,7 +349,7 @@
|
||||
<form t-attf-action="/forum/#{ slug(forum) }/link/new" method="post" role="form" class="tag_text form-horizontal">
|
||||
<input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="post_name">URL to Share</label>
|
||||
<label class="col-sm-2 control-label" for="content_link">URL to Share</label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" name="post_name" required="True" t-attf-value="#{post_name}"
|
||||
class="form-control mb16 link_url" placeholder="e.g. https://www.odoo.com"/>
|
||||
@@ -363,7 +363,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="post_name">Tags</label>
|
||||
<label class="col-sm-2 control-label" for="post_tags">Tags</label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" name="post_tags" readonly="True" class="form-control load_tags"/>
|
||||
</div>
|
||||
@@ -566,7 +566,7 @@
|
||||
<div t-attf-class="col-md-10 #{not question.active and 'alert alert-danger' or ''}">
|
||||
<h1 class="mt0">
|
||||
<t t-if="question.type == 'link'">
|
||||
<a t-att-href="question.name" t-raw="question.content"/>
|
||||
<a t-att-href="question.content_link" t-raw="question.name"/>
|
||||
</t>
|
||||
<t t-if="question.type in ('question', 'discussion')">
|
||||
<a t-attf-href="/forum/#{ slug(forum) }/question/#{ slug(question) }" t-field="question.name"/>
|
||||
|
||||
Reference in New Issue
Block a user