[ADD] added functionality to close question, added icon for edit and other links.
bzr revid: tpa@tinyerp.com-20140321125747-lq3otpnakwua08w0
This commit is contained in:
parent
7738af32e2
commit
d7e179a6df
|
@ -446,6 +446,39 @@ class website_forum(http.Controller):
|
|||
}, context=context)
|
||||
return correct
|
||||
|
||||
@http.route('/forum/<model("website.forum"):forum>/close/question/<model("website.forum.post"):post>', type='http', auth="user", multilang=True, website=True)
|
||||
def close_question(self, forum, post, **kwarg):
|
||||
#have to remove by applying selection widget
|
||||
reasons = [{'name': 'duplicate', 'value': 'duplicate question'},
|
||||
{'name': 'off_topic', 'value': 'question is off-topic or not relevant'},
|
||||
{'name': 'argumentative', 'value': 'too subjective and argumentative'},
|
||||
{'name': 'not_question', 'value': 'not a real question'},
|
||||
{'name': 'answer_accepted', 'value': 'the question is answered, right answer was accepted'},
|
||||
{'name': 'out_dated', 'value': 'question is not relevant or out dated'},
|
||||
{'name': 'offensive', 'value': 'question contains offensive or malicious remarks'},
|
||||
{'name': 'advertising', 'value': 'spam or advertising'},
|
||||
{'name': 'localized', 'value': 'too localized'}
|
||||
]
|
||||
|
||||
values = {
|
||||
'post': post,
|
||||
'forum': forum,
|
||||
'searches': kwarg,
|
||||
'reasons': reasons,
|
||||
'notifications': self._get_notifications(),
|
||||
}
|
||||
return request.website.render("website_forum.close_question", values)
|
||||
|
||||
@http.route('/forum/<model("website.forum"):forum>/question/close/', type='http', auth="user", multilang=True, methods=['POST'], website=True)
|
||||
def save_edited_question(self, forum, **post):
|
||||
request.registry['website.forum.post'].write( request.cr, request.uid, [int(post.get('post_id'))], {
|
||||
'state': 'close',
|
||||
'closed_by': request.uid,
|
||||
'closed_date': datetime.today().strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
'reason': post.get('reason'),
|
||||
}, context=request.context)
|
||||
return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum),post.get('post_id')))
|
||||
|
||||
@http.route('/forum/<model("website.forum"):forum>/edit/profile/<model("res.users"):user>', type='http', auth="user", multilang=True, website=True)
|
||||
def edit_profile(self, forum, user, **kwarg):
|
||||
cr,context = request.cr, request.context
|
||||
|
|
|
@ -150,7 +150,21 @@ class Post(osv.Model):
|
|||
'website.forum.post.vote': (_get_vote, [], 10),
|
||||
}
|
||||
),
|
||||
|
||||
'correct': fields.boolean('Correct Answer'),
|
||||
'reason': fields.selection([
|
||||
('duplicate', 'duplicate question'),
|
||||
('off_topic', 'question is off-topic or not relevant'),
|
||||
('argumentative','too subjective and argumentative'),
|
||||
('not_question', 'not a real question'),
|
||||
('answer_accepted', 'the question is answered, right answer was accepted'),
|
||||
('out_dated', 'question is not relevant or out dated'),
|
||||
('offensive', 'question contains offensive or malicious remarks'),
|
||||
('advertising', 'spam or advertising'),
|
||||
('localized', 'too localized'),
|
||||
], 'Reason'),
|
||||
'closed_by': fields.many2one('res.users', 'Closed by'),
|
||||
'closed_date': fields.datetime('Closed on', readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'state': 'active',
|
||||
|
|
|
@ -307,6 +307,31 @@
|
|||
</t>
|
||||
</template>
|
||||
|
||||
<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/close/" method="post" role="form">
|
||||
<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">
|
||||
<t t-foreach="reasons" t-as="reason">
|
||||
<option t-att-value="reason.get('name')" t-att-selected="reason.get('name') == post.reason"><t t-esc="reason.get('value')"/></option>
|
||||
</t>
|
||||
<!--div t-field="post.reason" t-field-options='{"widget":"selection"}'/-->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-primary btn-lg">Close</button>
|
||||
</div>
|
||||
</form>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="post_description_full" name="Question Navigation">
|
||||
<t t-call="website_forum.header">
|
||||
|
||||
|
@ -341,20 +366,28 @@
|
|||
</div>
|
||||
<ul class="list-inline">
|
||||
<li>
|
||||
<a style="cursor: pointer" data-toggle="collapse" class="text-muted"
|
||||
<a style="cursor: pointer" data-toggle="collapse" class="text-muted fa fa-comment-o"
|
||||
t-attf-data-target="#comment#{ question._name.replace('.','') + '-' + str(question.id) }">
|
||||
comment
|
||||
</a>
|
||||
</li>
|
||||
<li><a class="text-muted" t-attf-href="/forum/#{ slug(forum) }/edit/question/#{ question.id }">edit</a></li>
|
||||
<li><a class="text-muted" t-attf-href="/forum/#{ slug(forum) }/delete/question/#{ question.id }">delete</a></li>
|
||||
<li><a class="text-muted" href="">share</a></li>
|
||||
<li><a class="text-muted fa fa-times" t-attf-href="/forum/#{ slug(forum) }/close/question/#{ question.id }">close</a></li>
|
||||
<li><a class="text-muted fa fa-edit" t-attf-href="/forum/#{ slug(forum) }/edit/question/#{ question.id }">edit</a></li>
|
||||
<li><a class="text-muted fa fa-trash-o" t-attf-href="/forum/#{ slug(forum) }/delete/question/#{ question.id }">delete</a></li>
|
||||
<li><a class="text-muted fa fa-share" href="">share</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<t t-set="user" t-value="question.user_id"/>
|
||||
<t t-call="website_forum.user_detail">
|
||||
<span class="text-muted">Asked on <span t-field="question.write_date"/></span>
|
||||
</t>
|
||||
<div class="alert alert-info" t-if="question.state == 'close'">
|
||||
<p class="mt32 mb32" style="text-align: center;">
|
||||
<b>The question has been closed for the following reason "<span t-field="question.reason"/>"
|
||||
<i>by <a t-attf-href="/forum/#{ slug(forum) }/user/#{ slug(question.closed_by) }" t-field="question.closed_by.name"/> </i>
|
||||
<br/>close date <span t-field="question.closed_date"/></b>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<t t-call="website_forum.comments">
|
||||
<t t-set="object" t-value="question"/>
|
||||
|
@ -386,14 +419,14 @@
|
|||
<div class="mt16">
|
||||
<ul class="list-inline pull-right">
|
||||
<li>
|
||||
<a style="cursor: pointer" data-toggle="collapse" class="text-muted"
|
||||
<a style="cursor: pointer" data-toggle="collapse" class="text-muted fa fa-comment-o"
|
||||
t-attf-data-target="#comment#{ answer._name.replace('.','') + '-' + str(answer.id) }">
|
||||
comment
|
||||
</a>
|
||||
</li>
|
||||
<li><a class="text-muted" t-attf-href="/forum/#{ slug(forum) }/answer/#{ question.id }/edit/#{ answer.id }">edit</a></li>
|
||||
<li><a class="text-muted delete" href="" t-attf-id="#{answer.id}">delete</a></li>
|
||||
<li><a class="text-muted" t-attf-href="/forum/#{ slug(forum) }/question/#{ question.id }/#answer-#{ answer.id }">share</a></li>
|
||||
<li><a class="text-muted fa fa-edit" t-attf-href="/forum/#{ slug(forum) }/answer/#{ question.id }/edit/#{ answer.id }">edit</a></li>
|
||||
<li><a class="text-muted delete fa fa-trash-o" href="" t-attf-id="#{answer.id}">delete</a></li>
|
||||
<li><a class="text-muted fa fa-share" t-attf-href="/forum/#{ slug(forum) }/question/#{ question.id }/#answer-#{ answer.id }">share</a></li>
|
||||
</ul>
|
||||
<t t-set="user" t-value="answer.user_id"/>
|
||||
<t t-call="website_forum.user_detail">
|
||||
|
|
Loading…
Reference in New Issue