[FIX] website_forum: new batch of fixes :
- fixed reopen link that was broken (python code appearing) - fixed close link that was leading to a 500 error due to post -> question - fixed link to question author, was redirecting to the current user - fixed displayed number of questions in the forum, now displaying actual question number, not number of displayed questions in the page - improved guidelines: added link back to the forum - fixed tags display: now by posts_count desc, unused tags are not shown - users are now displayed by desc karma - converting a comment as an answer does not allow to create a new answer if another one by uid is already present, it just moves the comment bzr revid: tde@openerp.com-20140505154523-6dld9sfm0nc0oulu
This commit is contained in:
parent
5f708d1a21
commit
55479a4cc2
|
@ -124,6 +124,7 @@ class WebsiteForum(http.Controller):
|
|||
values.update({
|
||||
'main_object': tag or forum,
|
||||
'question_ids': question_ids,
|
||||
'question_count': question_count,
|
||||
'pager': pager,
|
||||
'tag': tag,
|
||||
'filters': filters,
|
||||
|
@ -134,7 +135,7 @@ class WebsiteForum(http.Controller):
|
|||
|
||||
@http.route(['/forum/<model("forum.forum"):forum>/faq'], type='http', auth="public", website=True, multilang=True)
|
||||
def forum_faq(self, forum, **post):
|
||||
values = self._prepare_forum_values(forum=forum, searches=dict(), **post)
|
||||
values = self._prepare_forum_values(forum=forum, searches=dict(), header={'is_guidelines': True}, **post)
|
||||
return request.website.render("website_forum.faq", values)
|
||||
|
||||
@http.route('/forum/get_tags', type='http', auth="public", multilang=True, methods=['GET'], website=True)
|
||||
|
@ -147,7 +148,7 @@ class WebsiteForum(http.Controller):
|
|||
def tags(self, forum, page=1, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
Tag = request.registry['forum.tag']
|
||||
obj_ids = Tag.search(cr, uid, [('forum_id', '=', forum.id)], limit=None, context=context)
|
||||
obj_ids = Tag.search(cr, uid, [('forum_id', '=', forum.id), ('posts_count', '>', 0)], limit=None, order='posts_count DESC', context=context)
|
||||
tags = Tag.browse(cr, uid, obj_ids, context=context)
|
||||
values = self._prepare_forum_values(forum=forum, searches={'tags': True}, **post)
|
||||
values.update({
|
||||
|
@ -426,7 +427,7 @@ class WebsiteForum(http.Controller):
|
|||
tag_count = User.search(cr, SUPERUSER_ID, [('karma', '>', 1)], count=True, context=context)
|
||||
pager = request.website.pager(url="/forum/users", total=tag_count, page=page, step=step, scope=30)
|
||||
|
||||
obj_ids = User.search(cr, SUPERUSER_ID, [('karma', '>', 1)], limit=step, offset=pager['offset'], context=context)
|
||||
obj_ids = User.search(cr, SUPERUSER_ID, [('karma', '>', 1)], limit=step, offset=pager['offset'], order='karma DESC', context=context)
|
||||
users = User.browse(cr, SUPERUSER_ID, obj_ids, context=context)
|
||||
searches['users'] = 'True'
|
||||
|
||||
|
@ -590,12 +591,13 @@ class WebsiteForum(http.Controller):
|
|||
|
||||
@http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/comment/<model("mail.message"):comment>/convert_to_answer', type='http', auth="public", multilang=True, website=True)
|
||||
def convert_comment_to_answer(self, forum, post, comment, **kwarg):
|
||||
values = {
|
||||
'content': comment.body,
|
||||
}
|
||||
body = comment.body
|
||||
request.registry['mail.message'].unlink(request.cr, request.uid, [comment.id], context=request.context)
|
||||
question = post.parent_id if post.parent_id else post
|
||||
return self.post_new(forum, question, **values)
|
||||
for answer in question.child_ids:
|
||||
if answer.create_uid.id == request.uid:
|
||||
return self.post_comment(forum, answer, comment=html2plaintext(body))
|
||||
return self.post_new(forum, question, content=body)
|
||||
|
||||
@http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/convert_to_comment', type='http', auth="user", multilang=True, website=True)
|
||||
def convert_answer_to_comment(self, forum, post, **kwarg):
|
||||
|
|
|
@ -92,7 +92,8 @@
|
|||
</div>
|
||||
<div class="panel-body">
|
||||
<t t-raw="forum.description"/><br/>
|
||||
<a t-attf-href="/forum/#{slug(forum)}/faq" class="fa fa-arrow-right"> Read Guidelines</a>
|
||||
<a t-if="not header.get('is_guidelines')" t-attf-href="/forum/#{slug(forum)}/faq" class="fa fa-arrow-right"> Read Guidelines</a>
|
||||
<a t-if="header.get('is_guidelines')" t-attf-href="/forum/#{slug(forum)}" class="fa fa-arrow-right"> Back to <span t-field="forum.name"/></a>
|
||||
</div>
|
||||
</div>
|
||||
<div t-if="header.get('question_data')">
|
||||
|
@ -208,7 +209,7 @@
|
|||
<template id="forum_index" name="Forum">
|
||||
<t t-call="website_forum.header">
|
||||
<h1 class="page-header mt0">
|
||||
<t t-esc="len(question_ids)"/> <span>Questions</span>
|
||||
<t t-esc="question_count"/> <span>Questions</span>
|
||||
<t t-esc="search"/>
|
||||
<small class="dropdown" t-if="filters in ('all', 'unanswered','followed', 'tag')">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
|
@ -332,12 +333,12 @@
|
|||
users having a high karma can see closed questions to moderate
|
||||
them.
|
||||
</p>
|
||||
<form t-attf-action="/forum/#{ slug(forum) }/question/#{slug(post)}/close" method="post" role="form" class="form-horizontal mt32 mb64">
|
||||
<form t-attf-action="/forum/#{ slug(forum) }/question/#{slug(question)}/close" method="post" role="form" class="form-horizontal mt32 mb64">
|
||||
<input name="post_id" t-att-value="question.id" type="hidden"/>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label" for="reason">Question:</label>
|
||||
<div class="col-md-8 mt8">
|
||||
<span t-field="post.name"/>
|
||||
<span t-field="question.name"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@ -354,7 +355,7 @@
|
|||
<div class="col-md-offset-3 col-md-8">
|
||||
<button class="btn btn-primary">Close question</button>
|
||||
<span class="text-muted">or</span>
|
||||
<a class="btn btn-link" t-attf-href="/forum/#{ slug(forum) }/question/#{ slug(post) }">back to question</a>
|
||||
<a class="btn btn-link" t-attf-href="/forum/#{ slug(forum) }/question/#{ slug(question) }">back to question</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -451,7 +452,7 @@
|
|||
<a class="text-muted fa fa-times" t-attf-href="/forum/#{ slug(forum) }/question/#{slug(question)}/ask_for_close"> Close</a>
|
||||
</li>
|
||||
<li t-if="question.state == 'close' and ((user.id == question.create_uid.id and can_close_own) or can_close_all)">
|
||||
<a class="text-muted fa fa-undo" t-attf-href="/forum/#{ slug(forum) }/question/#{slug(question)/reopen">reopen</a>
|
||||
<a class="text-muted fa fa-undo" t-attf-href="/forum/#{ slug(forum) }/question/#{slug(question)}/reopen"> Reopen</a>
|
||||
</li>
|
||||
<li t-if="(user.id == question.create_uid.id and can_edit_own) or can_edit_all">
|
||||
<a class="text-muted fa fa-edit" t-attf-href="/forum/#{ slug(forum) }/post/#{slug(question)}/edit"> Edit</a>
|
||||
|
@ -467,7 +468,7 @@
|
|||
<div>
|
||||
<span t-field="question.create_uid.image" t-field-options='{"widget": "image", "class":"pull-left img img-circle img-avatar"}'/>
|
||||
<div>
|
||||
<a t-attf-href="/forum/#{ slug(forum) }/user/#{ user.id }"
|
||||
<a t-attf-href="/forum/#{ slug(forum) }/user/#{ question.create_uid.id }"
|
||||
t-field="question.create_uid"
|
||||
t-field-options='{"widget": "contact", "country_image": true, "fields": ["name", "country_id"]}'
|
||||
style="display: inline-block;"/>
|
||||
|
|
Loading…
Reference in New Issue