[IMP] [FIX] website_forum: better control of actions based on karma; those
actions are calculated in the controller, based on forum.forum values instead of values hardcoded in the view. bzr revid: tde@openerp.com-20140418135724-k64yey6hhrki0b6h
This commit is contained in:
parent
a6103a08be
commit
b153fcd35e
|
@ -32,12 +32,21 @@ class WebsiteForum(http.Controller):
|
|||
return msg
|
||||
|
||||
def _prepare_forum_values(self, forum=None, **kwargs):
|
||||
Forum = request.registry['forum.forum']
|
||||
user = request.registry['res.users'].browse(request.cr, request.uid, request.uid, context=request.context)
|
||||
public_uid = request.registry['website'].get_public_user(request.cr, request.uid, request.context)
|
||||
values = {'user': user, 'is_public_user': user.id == public_uid,
|
||||
'notifications': self._get_notifications(),
|
||||
'header': kwargs.get('header', dict()),
|
||||
'searches': kwargs.get('searches', dict())}
|
||||
'searches': kwargs.get('searches', dict()),
|
||||
'can_edit_own': True,
|
||||
'can_edit_all': user.karma > Forum._karma_modo_edit_all,
|
||||
'can_close_own': user.karma > Forum._karma_modo_close_own,
|
||||
'can_close_all': user.karma > Forum._karma_modo_close_all,
|
||||
'can_unlink_own': user.karma > Forum._karma_modo_unlink_own,
|
||||
'can_unlink_all': user.karma > Forum._karma_modo_unlink_all,
|
||||
'can_unlink_comment': user.karma > Forum._karma_modo_unlink_comment,
|
||||
}
|
||||
if forum:
|
||||
values['forum'] = forum
|
||||
elif kwargs.get('forum_id'):
|
||||
|
|
|
@ -17,15 +17,21 @@ class Forum(osv.Model):
|
|||
_karma_upvote = 5 # done
|
||||
_karma_downvote = 50 # done
|
||||
_karma_answer_accept_own = 20 # done
|
||||
_karma_answer_own_question_immediately = 50
|
||||
_karma_answer_accept_own_now = 50
|
||||
_karma_answer_accept_all = 500
|
||||
_karma_editor_link_files = 30 # done
|
||||
_karma_editor_clickable_link = 50
|
||||
_karma_comment = 1
|
||||
_karma_modo_retag = 75
|
||||
_karma_modo_close_own = 100
|
||||
_karma_modo_edit_all = 300
|
||||
_karma_modo_unlink_comment = 400
|
||||
_karma_modo_close_all = 900
|
||||
_karma_modo_unlink_all = 1000
|
||||
_karma_modo_flag = 100
|
||||
_karma_modo_flag_see_all = 300
|
||||
_karma_modo_unlink_comment = 750
|
||||
_karma_modo_edit_own = 1 # done
|
||||
_karma_modo_edit_all = 300 # done
|
||||
_karma_modo_close_own = 100 # done
|
||||
_karma_modo_close_all = 900 # done
|
||||
_karma_modo_unlink_own = 500 # done
|
||||
_karma_modo_unlink_all = 1000 # done
|
||||
# karma generation
|
||||
_karma_gen_quest_new = 2 # done
|
||||
_karma_gen_upvote_quest = 5 # done
|
||||
|
|
|
@ -430,19 +430,19 @@
|
|||
comment
|
||||
</a>
|
||||
</li>
|
||||
<li t-if="question.state != 'close' and (user.id == question.create_uid.id or user.karma>=100)">
|
||||
<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-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>=500">
|
||||
<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>
|
||||
</li>
|
||||
<li t-if="user.id == question.create_uid.id or user.karma>=300">
|
||||
<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>
|
||||
</li>
|
||||
<li t-if="question.active and user.id == question.create_uid.id or user.karma>=1000">
|
||||
<li t-if="question.active and ((user.id == question.create_uid.id and can_unlink_own) or can_unlink_all)">
|
||||
<a class="text-muted fa fa-trash-o" t-attf-href="/forum/#{ slug(forum) }/question/#{slug(question)}/delete">delete</a>
|
||||
</li>
|
||||
<li t-if="uid == question.create_uid.id and not question.active">
|
||||
<li t-if="not question.active and ((user.id == question.create_uid.id and can_unlink_own) or can_unlink_all)">
|
||||
<a class="text-muted fa fa-trash-o" t-attf-href="/forum/#{ slug(forum) }/question/#{slug(question)}/undelete">undelete</a>
|
||||
</li>
|
||||
<li><a class="text-muted fa fa-share" t-attf-href="/forum/#{slug(forum)}/question/#{slug(question)}">share</a></li>
|
||||
|
@ -496,10 +496,10 @@
|
|||
t-attf-data-target="#comment#{ answer._name.replace('.','') + '-' + str(answer.id) }">comment
|
||||
</a>
|
||||
</li>
|
||||
<li t-if="user.id == answer.create_uid.id or user.karma>=300">
|
||||
<li t-if="(user.id == answer.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(answer)}/edit">edit</a>
|
||||
</li>
|
||||
<li t-if="user.id == answer.create_uid.id or user.karma>=1000">
|
||||
<li t-if="(user.id == answer.create_uid.id and can_unlink_own) or can_unlink_all">
|
||||
<a class="text-muted fa fa-trash-o" t-attf-href="/forum/#{slug(forum)}/post/#{slug(answer)}/delete">delete</a>
|
||||
</li>
|
||||
<li t-if="user.id == answer.create_uid.id">
|
||||
|
|
Loading…
Reference in New Issue