Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
29f818e6
Commit
29f818e6
authored
Aug 30, 2016
by
barthc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent authored awardable thumbs votes
parent
76872372
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
app/controllers/concerns/toggle_award_emoji.rb
app/controllers/concerns/toggle_award_emoji.rb
+7
-5
app/models/concerns/awardable.rb
app/models/concerns/awardable.rb
+5
-2
No files found.
app/controllers/concerns/toggle_award_emoji.rb
View file @
29f818e6
...
@@ -8,12 +8,14 @@ module ToggleAwardEmoji
...
@@ -8,12 +8,14 @@ module ToggleAwardEmoji
def
toggle_award_emoji
def
toggle_award_emoji
name
=
params
.
require
(
:name
)
name
=
params
.
require
(
:name
)
return
render
json:
{
ok:
false
}
unless
awardable
.
user_can_award?
(
current_user
,
name
)
if
awardable
.
user_can_award?
(
current_user
,
name
)
awardable
.
toggle_award_emoji
(
name
,
current_user
)
awardable
.
toggle_award_emoji
(
name
,
current_user
)
TodoService
.
new
.
new_award_emoji
(
to_todoable
(
awardable
),
current_user
)
TodoService
.
new
.
new_award_emoji
(
to_todoable
(
awardable
),
current_user
)
render
json:
{
ok:
true
}
render
json:
{
ok:
true
}
else
render
json:
{
ok:
false
}
end
end
end
private
private
...
...
app/models/concerns/awardable.rb
View file @
29f818e6
...
@@ -64,8 +64,11 @@ module Awardable
...
@@ -64,8 +64,11 @@ module Awardable
end
end
def
user_can_award?
(
current_user
,
name
)
def
user_can_award?
(
current_user
,
name
)
name
=
normalize_name
(
name
)
if
user_authored?
(
current_user
)
!
(
self
.
user_authored?
(
current_user
)
&&
awardable_votes?
(
name
))
!
awardable_votes?
(
normalize_name
(
name
))
else
true
end
end
end
def
awarded_emoji?
(
emoji_name
,
current_user
)
def
awarded_emoji?
(
emoji_name
,
current_user
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment