Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cs_comments_service
Overview
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
cs_comments_service
Commits
f60b0f0f
Commit
f60b0f0f
authored
Jul 16, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change name for vote handler
parent
d592009d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
app.rb
+6
-6
No files found.
app.rb
View file @
f60b0f0f
...
...
@@ -90,22 +90,22 @@ end
put
'/api/v1/comments/:comment_id/votes'
do
|
comment_id
|
comment
=
Comment
.
find
(
comment_id
)
handle_
vote_for
comment
vote_for
comment
end
delete
'/api/v1/comments/:comment_id/votes'
do
|
comment_id
|
comment
=
Comment
.
find
(
comment_id
)
handle_un
vote_for
comment
delete_
vote_for
comment
end
put
'/api/v1/threads/:thread_id/votes'
do
|
thread_id
|
thread
=
CommentThread
.
find
(
thread_id
)
handle_
vote_for
thread
vote_for
thread
end
delete
'/api/v1/threads/:thread_id/votes'
do
|
thread_id
|
thread
=
CommentThread
.
find
(
thread_id
)
handle_un
vote_for
thread
delete_
vote_for
thread
end
get
'/api/v1/users/:user_id/notifications'
do
|
user_id
|
...
...
@@ -150,13 +150,13 @@ if env.to_s == "development"
end
end
def
handle_
vote_for
(
obj
)
def
vote_for
(
obj
)
user
=
User
.
find_or_create_by
(
external_id:
params
[
"user_id"
])
user
.
vote
(
obj
,
params
[
"value"
].
to_sym
)
obj
.
reload
.
to_hash
.
to_json
end
def
handle_un
vote_for
(
obj
)
def
delete_
vote_for
(
obj
)
user
=
User
.
find_or_create_by
(
external_id:
params
[
"user_id"
])
user
.
unvote
(
obj
)
obj
.
reload
.
to_hash
.
to_json
...
...
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