[imp]:user activity based on karma
bzr revid: sunilsharma.sharma07@gmail.com-20140328101915-w6uq2m5sbjlb1qpg
This commit is contained in:
parent
26def8a7f5
commit
9de4ff0358
|
@ -171,6 +171,7 @@ class website_forum(http.Controller):
|
|||
following = True if partner_id in message_follower_ids else False
|
||||
|
||||
filters = 'question'
|
||||
user = request.registry['res.users'].browse(cr, uid, uid, context=None)
|
||||
values = {
|
||||
'question': question,
|
||||
'question_data': True,
|
||||
|
@ -181,6 +182,7 @@ class website_forum(http.Controller):
|
|||
'answer_done': answer_done,
|
||||
'reversed': reversed,
|
||||
'forum': forum,
|
||||
'user': user,
|
||||
}
|
||||
return request.website.render("website_forum.post_description_full", values)
|
||||
|
||||
|
@ -514,7 +516,8 @@ class website_forum(http.Controller):
|
|||
cr, uid, context = request.cr, request.uid, request.context
|
||||
Post = request.registry['website.forum.post']
|
||||
post = Post.browse(cr, uid, int(kwarg.get('post_id')), context=context)
|
||||
if post.user_id.id == uid:
|
||||
user = request.registry['res.users'].browse(cr, uid, uid, context=None)
|
||||
if post.user_id.id == uid or user.karma >= 500:
|
||||
correct = False if post.correct else True
|
||||
#Note: only one answer can be right.
|
||||
for child in post.parent_id.child_ids:
|
||||
|
@ -525,7 +528,7 @@ class website_forum(http.Controller):
|
|||
Post.write( cr, uid, [post.id, post.parent_id.id], {
|
||||
'correct': correct,
|
||||
}, context=context)
|
||||
return correct
|
||||
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):
|
||||
|
|
|
@ -349,6 +349,9 @@ class Vote(osv.Model):
|
|||
post = self.pool['website.forum.post'].browse(cr, uid, post_id, context=context)
|
||||
if post.user_id.id == uid:
|
||||
return {'error': 'own_post'}
|
||||
user = self.pool['res.users'].browse(cr, uid, uid, context=None)
|
||||
if (vote == '-1') and (user.karma <= 10):
|
||||
return {'error': 'lessthen_10_karma'}
|
||||
vote_ids = self.search(cr, uid, [('post_id', '=', post_id), ('user_id','=',uid)], context=context)
|
||||
if vote_ids:
|
||||
#when user will click again on vote it should set it 0.
|
||||
|
|
|
@ -21,6 +21,13 @@ $(document).ready(function () {
|
|||
'Sorry, anonymous users cannot vote'+
|
||||
'</div>');
|
||||
}
|
||||
else if (data['error'] == 'lessthen_10_karma')
|
||||
{
|
||||
var $warning = $('<div class="alert alert-danger alert-dismissable" id="vote_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
|
||||
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">×</button>'+
|
||||
'10 karma required to downvote'+
|
||||
'</div>');
|
||||
}
|
||||
vote_alert = $link.parent().find("#vote_alert");
|
||||
if (vote_alert.length == 0) {
|
||||
$link.parent().append($warning);
|
||||
|
|
|
@ -416,16 +416,16 @@
|
|||
comment
|
||||
</a>
|
||||
</li>
|
||||
<li t-if="question.state != 'close' and uid">
|
||||
<li t-if="question.state != 'close' and user.id == question.user_id.id and user.karma>=100">
|
||||
<a class="text-muted fa fa-times" t-attf-href="/forum/#{ slug(forum) }/close/question/#{ question.id }">close</a>
|
||||
</li>
|
||||
<li t-if="question.state == 'close' and uid">
|
||||
<a class="text-muted fa fa-undo" t-attf-href="/forum/#{ slug(forum) }/reopen/question/#{ question.id }">reopen</a>
|
||||
</li>
|
||||
<li t-if="uid">
|
||||
<li t-if="user.id == question.user_id.id or user.karma>=300">
|
||||
<a class="text-muted fa fa-edit" t-attf-href="/forum/#{ slug(forum) }/edit/question/#{ question.id }">edit</a>
|
||||
</li>
|
||||
<li t-if="question.active and uid == question.user_id.id">
|
||||
<li t-if="question.active and user.id == question.user_id.id or user.karma>=1000">
|
||||
<a class="text-muted fa fa-trash-o" t-attf-href="/forum/#{ slug(forum) }/delete/question/#{ question.id }">delete</a>
|
||||
</li>
|
||||
<li t-if="uid == question.user_id.id and not question.active">
|
||||
|
@ -480,10 +480,10 @@
|
|||
t-attf-data-target="#comment#{ answer._name.replace('.','') + '-' + str(answer.id) }">comment
|
||||
</a>
|
||||
</li>
|
||||
<li t-if="uid">
|
||||
<li t-if="user.id == answer.user_id.id or user.karma>=300">
|
||||
<a class="text-muted fa fa-edit" t-attf-href="/forum/#{ slug(forum) }/answer/#{ question.id }/edit/#{ answer.id }">edit</a>
|
||||
</li>
|
||||
<li t-if="uid == answer.user_id.id">
|
||||
<li t-if="user.id == answer.user_id.id or user.karma>=1000">
|
||||
<a class="text-muted delete fa fa-trash-o" href="" t-attf-id="#{answer.id}">delete</a>
|
||||
</li>
|
||||
<li t-if="uid">
|
||||
|
@ -516,7 +516,7 @@
|
|||
<div class="col-sm-10 col-sm-offset-2">
|
||||
<div t-foreach="reversed(object.website_message_ids)" t-as="message" id="comment" class="oe_grey" style="padding: 4px;">
|
||||
<small class="text-muted">
|
||||
<button type="button" t-if="uid == message.create_uid.id" t-att-id="message.id" class="close comment_delete">&times;</button>
|
||||
<button type="button" t-if="user.id == message.create_uid.id or user.karma>=750" t-att-id="message.id" class="close comment_delete">&times;</button>
|
||||
<span t-field="message.body"/>
|
||||
<a t-attf-href="/forum/#{ slug(forum) }/user/#{ message.create_uid.id }" t-field="message.create_uid"/>
|
||||
on <span t-field="message.date" t-field-options='{"format":"short"}'/>
|
||||
|
|
Loading…
Reference in New Issue