BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
toggle_award_emoji.rb
app/controllers/concerns/toggle_award_emoji.rb
+7
-5
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
)
TodoService
.
new
.
new_award_emoji
(
to_todoable
(
awardable
),
current_user
)
awardable
.
toggle_award_emoji
(
name
,
current_user
)
render
json:
{
ok:
true
}
TodoService
.
new
.
new_award_emoji
(
to_todoable
(
awardable
),
current_user
)
else
render
json:
{
ok:
false
}
render
json:
{
ok:
true
}
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