diff options
author | barthc <mackintosh02@gmail.com> | 2016-08-17 12:21:06 +0100 |
---|---|---|
committer | barthc <mackintosh02@gmail.com> | 2016-08-28 18:15:55 +0100 |
commit | 76872372376e57cd7d55ba9b9c63b25fe53c82df (patch) | |
tree | 1d7a93bd75644fdecd292e835b46c80046e4b222 /app/models/concerns/awardable.rb | |
parent | 68b3c8c2973a8fe1ee3f51091394acef2a25789d (diff) | |
download | gitlab-ce-76872372376e57cd7d55ba9b9c63b25fe53c82df.tar.gz |
prevent authored awardable thumbs votes
prevent authored awardable thumbs votes
prevent authored awardable thumbs votes
Diffstat (limited to 'app/models/concerns/awardable.rb')
-rw-r--r-- | app/models/concerns/awardable.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/concerns/awardable.rb b/app/models/concerns/awardable.rb index 800a16ab246..e25420c0edf 100644 --- a/app/models/concerns/awardable.rb +++ b/app/models/concerns/awardable.rb @@ -59,6 +59,15 @@ module Awardable true end + def awardable_votes?(name) + AwardEmoji::UPVOTE_NAME == name || AwardEmoji::DOWNVOTE_NAME == name + end + + def user_can_award?(current_user, name) + name = normalize_name(name) + !(self.user_authored?(current_user) && awardable_votes?(name)) + end + def awarded_emoji?(emoji_name, current_user) award_emoji.where(name: emoji_name, user: current_user).exists? end |