Skip to content

Commit

Permalink
[FIX] close and reopen questions
Browse files Browse the repository at this point in the history
bzr revid: fp@tinyerp.com-20140421184347-c86uyuw8l61dxl5o
  • Loading branch information
fpodoo committed Apr 21, 2014
1 parent 64c7152 commit 19da27c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 24 deletions.
3 changes: 2 additions & 1 deletion addons/website_forum/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def question_ask_for_close(self, forum, question, **post):
values = self._prepare_forum_values(**post)
values.update({
'post': question,
'question': question,
'forum': forum,
'reasons': reasons,
})
Expand All @@ -236,7 +237,7 @@ def question_close(self, forum, question, **post):
'state': 'close',
'closed_uid': request.uid,
'closed_date': datetime.today().strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT),
'closed_reason_id': post.get('reason_id', False),
'closed_reason_id': int(post.get('reason_id', False)),
}, context=request.context)
return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(question)))

Expand Down
3 changes: 2 additions & 1 deletion addons/website_forum/models/forum.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,9 @@ def set_viewed(self, cr, uid, ids, context=None):
class PostReason(osv.Model):
_name = "forum.post.reason"
_description = "Post Closing Reason"
_order = 'name'
_columns = {
'name': fields.char('Post Reason', required=True),
'name': fields.char('Post Reason', required=True, translate=True),
}


Expand Down
58 changes: 36 additions & 22 deletions addons/website_forum/views/website_forum.xml
Original file line number Diff line number Diff line change
Expand Up @@ -302,23 +302,36 @@
<!-- Moderation: close a question -->
<template id="close_question">
<t t-call="website_forum.header">
<h3 class=""><b>Close question</b></h3><br/>
<form t-attf-action="/forum/#{ slug(forum) }/question/#{slug(question)}/close" method="post" role="form">
<h1 class="mt0">Close question</h1>
<p class="text-muted">
If you close this question, it will be hidden for most users. Only
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">
<input name="post_id" t-att-value="post.id" type="hidden"/>
<span class="pull-left">Close the question:</span>
<a t-attf-href="/forum/#{ slug(forum) }/question/#{ slug(post) }" t-field="post.name"/>
<div class="mt16">
<label class="col-md-2 control-label mb16" for="reason">Reasons:</label>
<div class="col-md-9 mb16">
<select class="form-control" name="reason">
<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"/>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label" for="reason">Reason:</label>
<div class="col-md-8">
<select class="form-control" name="reason_id">
<t t-foreach="reasons or []" t-as="reason">
<option t-att-value="reason.id" t-att-selected="reason.id == post.closed_reason_id.id"><t t-esc="reason.name"/></option>
</t>
</select>
</div>
</div>
<div>
<button class="btn btn-primary btn-lg">Close</button>
<div class="form-group">
<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>
</div>
</div>
</form>
</t>
Expand Down Expand Up @@ -382,6 +395,19 @@
<span t-if="not question.active"><b> [Deleted]</b></span>
<span t-if="question.state == 'close'"><b> [Closed]</b></span>
</h1>
<div class="alert alert-info" t-if="question.state == 'close'">
<p class="mt32 mb16 text-center">
<b>The question has been closed for reason: <i t-esc="question.closed_reason_id.name"/>
<br/>
<t t-if="question.closed_uid">
<i>by <a t-attf-href="/forum/#{ slug(forum) }/user/#{ slug(question.closed_uid) }" t-field="question.closed_uid"/> </i>
</t>
on <span t-field="question.closed_date"/></b>
</p>
<div t-if="question.state == 'close' and user.karma&gt;=500" class="mb24 text-center">
<a class="fa fa-arrow-right" t-attf-href="/forum/#{ slug(forum) }/question/#{slug(question)}/reopen"> Reopen</a>
</div>
</div>
<t t-raw="question.content"/>

<div class="mt16 clearfix">
Expand All @@ -401,9 +427,6 @@
<li t-if="question.state != 'close' and (user.id == question.create_uid.id or user.karma&gt;=100)">
<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.karma&gt;=500">
<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 or user.karma&gt;=300">
<a class="text-muted fa fa-edit" t-attf-href="/forum/#{ slug(forum) }/post/#{slug(question)}/edit"> Edit</a>
</li>
Expand All @@ -425,15 +448,6 @@
<div t-field="question.create_uid" t-field-options='{"widget": "contact", "badges": true, "fields": ["karma"]}'/>
</div>
</div>
<div class="alert alert-info" t-if="question.state == 'close'">
<p class="mt32 mb32 text-center">
<b>The question has been closed for the following reason "<span t-field="question.closed_reason_id.name"/>"
<t t-if="question.closed_uid">
<i>by <a t-attf-href="/forum/#{ slug(forum) }/user/#{ slug(question.closed_uid) }" t-field="question.closed_uid.name"/> </i>
</t>
<br/>close date <span t-field="question.closed_date"/></b>
</p>
</div>
</div>
<t t-call="website_forum.post_comment">
<t t-set="object" t-value="question"/>
Expand Down

0 comments on commit 19da27c

Please sign in to comment.