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
4aefab34
Commit
4aefab34
authored
Dec 07, 2012
by
Kevin Chugh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add rake task to get flagged posts
parent
5826df36
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
0 deletions
+47
-0
lib/tasks/flags.rake
+21
-0
models/comment.rb
+9
-0
models/comment_thread.rb
+6
-0
models/content.rb
+11
-0
No files found.
lib/tasks/flags.rake
0 → 100644
View file @
4aefab34
require
'rest_client'
roots
=
{}
roots
[
'development'
]
=
"http://localhost:8000"
roots
[
'test'
]
=
"http://localhost:8000"
roots
[
'production'
]
=
"http://edx.org"
ROOT
=
roots
[
ENV
[
'SINATRA_ENV'
]]
namespace
:flags
do
task
:flagged
=>
:environment
do
flagged
=
Content
.
flagged
flagged
.
each
do
|
f
|
if
f
.
attributes
.
include?
"comment_thread_id"
id
=
f
.
comment_thread_id
else
id
=
f
.
id
end
puts
"
#{
ROOT
}
/courses/
#{
f
.
course_id
}
/discussion/forum/
#{
f
.
commentable_id
}
/threads/
#{
id
}
"
end
end
end
models/comment.rb
View file @
4aefab34
...
...
@@ -65,6 +65,15 @@ class Comment < Content
end
end
def
commentable_id
#we need this to have a universal access point for the flag rake task
if
self
.
comment_thread_id
t
=
CommentThread
.
find
self
.
comment_thread_id
if
t
t
.
commentable_id
end
end
end
private
def
set_thread_last_activity_at
...
...
models/comment_thread.rb
View file @
4aefab34
...
...
@@ -209,6 +209,11 @@ class CommentThread < Content
!!
(
tag
=~
RE_TAG
)
end
def
comment_thread_id
#so that we can use the comment thread id as a common attribute for flagging
self
.
id
end
private
RE_HEADCHAR
=
/[a-z0-9]/
...
...
@@ -237,4 +242,5 @@ private
def
destroy_subscriptions
subscriptions
.
delete_all
end
end
models/content.rb
View file @
4aefab34
...
...
@@ -13,4 +13,15 @@ class Content
end
end
def
self
.
flagged
#return an array of flagged content
holder
=
[]
Content
.
where
(
:abuse_flaggers
.
ne
=>
[],
:abuse_flaggers
.
exists
=>
true
).
each
do
|
c
|
holder
<<
c
end
holder
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