[IMP] instead of selection field on post for closing reason add new model PostReason.
bzr revid: tpa@tinyerp.com-20140324071152-vfklb1umocot3ycz
This commit is contained in:
parent
24b1b1fc81
commit
620892d474
|
@ -459,17 +459,10 @@ class website_forum(http.Controller):
|
|||
|
||||
@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'}
|
||||
]
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
Reason = request.registry['website.forum.post.reason']
|
||||
reason_ids = Reason.search(cr, uid, [], context=context)
|
||||
reasons = Reason.browse(cr, uid, reason_ids, context)
|
||||
|
||||
values = {
|
||||
'post': post,
|
||||
|
@ -486,7 +479,7 @@ class website_forum(http.Controller):
|
|||
'state': 'close',
|
||||
'closed_by': request.uid,
|
||||
'closed_date': datetime.today().strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
'reason': post.get('reason'),
|
||||
'reason_id': post.get('reason'),
|
||||
}, context=request.context)
|
||||
return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum),post.get('post_id')))
|
||||
|
||||
|
|
|
@ -52,5 +52,42 @@
|
|||
<field name="description">Answer edited</field>
|
||||
</record>
|
||||
|
||||
<!-- Reasons for closing Post -->
|
||||
<record id="reason_1" model="website.forum.post.reason">
|
||||
<field name="name">duplicate question</field>
|
||||
</record>
|
||||
|
||||
<record id="reason_2" model="website.forum.post.reason">
|
||||
<field name="name">question is off-topic or not relevant</field>
|
||||
</record>
|
||||
|
||||
<record id="reason_3" model="website.forum.post.reason">
|
||||
<field name="name">too subjective and argumentative</field>
|
||||
</record>
|
||||
|
||||
<record id="reason_4" model="website.forum.post.reason">
|
||||
<field name="name">not a real question</field>
|
||||
</record>
|
||||
|
||||
<record id="reason_5" model="website.forum.post.reason">
|
||||
<field name="name">the question is answered, right answer was accepted</field>
|
||||
</record>
|
||||
|
||||
<record id="reason_6" model="website.forum.post.reason">
|
||||
<field name="name">question is not relevant or out dated</field>
|
||||
</record>
|
||||
|
||||
<record id="reason_7" model="website.forum.post.reason">
|
||||
<field name="name">question contains offensive or malicious remarks</field>
|
||||
</record>
|
||||
|
||||
<record id="reason_8" model="website.forum.post.reason">
|
||||
<field name="name">spam or advertising</field>
|
||||
</record>
|
||||
|
||||
<record id="reason_9" model="website.forum.post.reason">
|
||||
<field name="name">too localized</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -152,17 +152,7 @@ class Post(osv.Model):
|
|||
),
|
||||
|
||||
'correct': fields.boolean('Correct Answer/ Answer on this question accepted.'),
|
||||
'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'),
|
||||
'reason_id': fields.many2one('website.forum.post.reason', 'Reason'),
|
||||
'closed_by': fields.many2one('res.users', 'Closed by'),
|
||||
'closed_date': fields.datetime('Closed on', readonly=True),
|
||||
}
|
||||
|
@ -219,6 +209,13 @@ class Post(osv.Model):
|
|||
self.pool['res.users'].write(cr, uid, [post.user_id.id], {'karma': value}, context=context)
|
||||
return super(Post, self).write(cr, uid, ids, vals, context=context)
|
||||
|
||||
class PostReason(osv.Model):
|
||||
_name = "website.forum.post.reason"
|
||||
_description = "Post Reason"
|
||||
_columns = {
|
||||
'name': fields.char('Post Reason'),
|
||||
}
|
||||
|
||||
class Users(osv.Model):
|
||||
_inherit = 'res.users'
|
||||
|
||||
|
|
|
@ -4,4 +4,6 @@ access_website_forum,website.forum,model_website_forum,base.group_public,1,0,0,0
|
|||
access_website_forum_post,website.forum.post,model_website_forum_post,base.group_public,1,0,0,0
|
||||
access_website_forum_post_history,website.forum.post.history,model_website_forum_post_history,base.group_public,1,0,0,0
|
||||
access_website_forum_post_vote,website.forum.post.vote,model_website_forum_post_vote,base.group_public,1,0,0,0
|
||||
access_website_forum_post_reason,website.forum.post.reason,model_website_forum_post_reason,base.group_public,1,0,0,0
|
||||
access_website_forum_tag,website.forum.tag,model_website_forum_tag,base.group_public,1,0,0,0
|
||||
|
||||
|
|
|
|
@ -320,10 +320,9 @@
|
|||
<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 t-foreach="reasons or []" t-as="reason">
|
||||
<option t-att-value="reason.id" t-att-selected="reason.id == post.reason_id.id"><t t-esc="reason.name"/></option>
|
||||
</t>
|
||||
<!--div t-field="post.reason" t-field-options='{"widget":"selection"}'/-->
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -396,7 +395,7 @@
|
|||
</t>
|
||||
<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.reason"/>"
|
||||
<b>The question has been closed for the following reason "<span t-field="question.reason_id.name"/>"
|
||||
<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>
|
||||
|
|
Loading…
Reference in New Issue