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
149c1bb3
Commit
149c1bb3
authored
Nov 16, 2012
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow flagging for abuse and spoilers
parent
9f0bbe59
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
2 deletions
+18
-2
Rakefile
+2
-2
lib/helpers.rb
+7
-0
models/comment.rb
+2
-0
models/comment_thread.rb
+2
-0
models/content.rb
+5
-0
No files found.
Rakefile
View file @
149c1bb3
...
...
@@ -156,9 +156,9 @@ namespace :db do
"comment_count"
=>
0
,
"title"
=>
Faker
::
Lorem
.
sentence
(
6
),
"author_id"
=>
rand
(
1
..
10
).
to_s
,
"body"
=>
Faker
::
Lorem
.
paragraphs
.
join
(
"
\n\n
"
),
"course_id"
=>
COURSE_ID
,
"created_at"
=>
Time
.
now
,
"commentable_id"
=>
COURSE_ID
,
"closed"
=>
[
true
,
false
].
sample
,
"updated_at"
=>
Time
.
now
,
"last_activity_at"
=>
Time
.
now
,
"votes"
=>
{
"count"
=>
0
,
"down"
=>
[],
"down_count"
=>
0
,
"point"
=>
0
,
"up"
=>
[],
"
up
_count"
=>
[]}}
"votes"
=>
{
"count"
=>
0
,
"down"
=>
[],
"down_count"
=>
0
,
"point"
=>
0
,
"up"
=>
[],
"
spoiler
_count"
=>
[]}}
coll
.
insert
(
doc
)
end
end
son
if
hes
working
that
woul
binding
.
pry
Tire
.
index
(
'comment_threads'
).
delete
CommentThread
.
create_elasticsearch_index
...
...
lib/helpers.rb
View file @
149c1bb3
...
...
@@ -37,11 +37,18 @@ helpers do
obj
.
reload
.
to_hash
.
to_json
end
def
flag_as_abuse
(
obj
)
raise
ArgumentError
,
"User id is required"
unless
user
obj
.
abuse_flaggers
<<
user
.
id
unless
obj
.
abuse_flaggers
.
include?
user
.
id
obj
.
reload
.
to_hash
.
to_json
end
def
undo_vote_for
(
obj
)
raise
ArgumentError
,
"must provide user id"
unless
user
user
.
unvote
(
obj
)
obj
.
reload
.
to_hash
.
to_json
end
def
value_to_boolean
(
value
)
!!
(
value
.
to_s
=~
/^true$/i
)
...
...
models/comment.rb
View file @
149c1bb3
...
...
@@ -60,6 +60,8 @@ class Comment < Content
.
merge
(
"thread_id"
=>
comment_thread
.
id
)
.
merge
(
"commentable_id"
=>
comment_thread
.
commentable_id
)
.
merge
(
"votes"
=>
votes
.
slice
(
*
%w[count up_count down_count point]
))
.
merge
(
"abuse_flaggers"
=>
comment_thread
.
abuse_flaggers
)
.
merge
(
"spoiler_flaggers"
=>
comment_thread
.
spoiler_flaggers
)
.
merge
(
"type"
=>
"comment"
)
end
end
...
...
models/comment_thread.rb
View file @
149c1bb3
...
...
@@ -158,6 +158,8 @@ class CommentThread < Content
.
merge
(
"id"
=>
_id
,
"user_id"
=>
author
.
id
,
"username"
=>
author
.
username
,
"votes"
=>
votes
.
slice
(
*
%w[count up_count down_count point]
),
"abuse_flaggers"
=>
abuse_flaggers
,
"spoiler_flaggers"
=>
spoiler_flaggers
,
"tags"
=>
tags_array
,
"type"
=>
"thread"
,
"endorsed"
=>
endorsed?
)
...
...
models/content.rb
View file @
149c1bb3
...
...
@@ -2,6 +2,10 @@ class Content
include
Mongoid
::
Document
field
:visible
,
type:
Boolean
,
default:
true
field
:abuse_flaggers
,
type:
Array
,
default:
[]
field
:spoiler_flaggers
,
type:
Array
,
default:
[]
def
author_with_anonymity
(
attr
=
nil
,
attr_when_anonymous
=
nil
)
if
not
attr
(
anonymous
||
anonymous_to_peers
)
?
nil
:
author
...
...
@@ -9,4 +13,5 @@ class Content
(
anonymous
||
anonymous_to_peers
)
?
attr_when_anonymous
:
author
.
send
(
attr
)
end
end
end
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