diff --git a/app/controllers/moderator/dashboards_controller.rb b/app/controllers/moderator/dashboards_controller.rb
index a066376da..37e41a7a8 100644
--- a/app/controllers/moderator/dashboards_controller.rb
+++ b/app/controllers/moderator/dashboards_controller.rb
@@ -1,9 +1,10 @@
module Moderator
class DashboardsController < ApplicationController
before_filter :janitor_only
+ helper :post_flags, :post_appeals
def show
- @dashboard = ModeratorDashboard.new(params[:min_date] || 2.days.ago.to_date, params[:max_level] || 20)
+ @dashboard = Moderator::Dashboard::Report.new(params[:min_date] || 2.days.ago.to_date, params[:max_level] || 20)
end
end
end
diff --git a/app/controllers/moderator/invitations_controller.rb b/app/controllers/moderator/invitations_controller.rb
new file mode 100644
index 000000000..296041b32
--- /dev/null
+++ b/app/controllers/moderator/invitations_controller.rb
@@ -0,0 +1,9 @@
+module Moderator
+ class InvitationsController < ApplicationController
+ def new
+ end
+
+ def create
+ end
+ end
+end
diff --git a/app/controllers/moderator/ip_addrs_controller.rb b/app/controllers/moderator/ip_addrs_controller.rb
new file mode 100644
index 000000000..ed6c25035
--- /dev/null
+++ b/app/controllers/moderator/ip_addrs_controller.rb
@@ -0,0 +1,9 @@
+module Moderator
+ class IpAddrsController < ApplicationController
+ def index
+ end
+
+ def search
+ end
+ end
+end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e9002a45e..7c3581e30 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -33,6 +33,23 @@ module ApplicationHelper
end
end
+ def mod_link_to_user(user, positive_or_negative)
+ html = ""
+ html << link_to(user.name, user_path(user))
+
+ if positive_or_negative == :positive
+ html << " [" + link_to("+", new_user_feedback_path(:user_record => {:category => "positive"})) + "]"
+
+ unless user.is_privileged?
+ html << " [" + link_to("invite", moderator_invitations_path(:invitation => {:name => user.name, :level => User::Levels::CONTRIBUTOR})) + "]"
+ end
+ else
+ html << " [" + link_to("–", new_user_feedback_path(:user_record => {:category => "negative", :user_id => user.id})) + "]"
+ end
+
+ html
+ end
+
protected
def nav_link_match(controller, url)
url =~ case controller
diff --git a/app/logical/moderator/dashboard/queries/artist.rb b/app/logical/moderator/dashboard/queries/artist.rb
new file mode 100644
index 000000000..6b8d5761f
--- /dev/null
+++ b/app/logical/moderator/dashboard/queries/artist.rb
@@ -0,0 +1,30 @@
+module Moderator
+ module Dashboard
+ module Queries
+ class Artist
+ attr_reader :user, :count
+
+ def self.all(min_date, max_level)
+ sql = <<-EOS
+ SELECT artist_versions.updater_id AS user_id, count(*)
+ FROM artist_versions
+ JOIN users ON users.id = artist_versions.updater_id
+ WHERE
+ artist_versions.created_at > ?
+ AND users.level <= ?
+ GROUP BY artist_versions.updater_id
+ ORDER BY count(*) DESC
+ LIMIT 10
+ EOS
+
+ ActiveRecord::Base.select_all_sql(sql, min_date, max_level).map {|x| new(x)}
+ end
+
+ def initialize(hash)
+ @user = ::User.find(hash["updater_id"])
+ @count = hash["count"]
+ end
+ end
+ end
+ end
+end
diff --git a/app/logical/moderator/dashboard/queries/comment.rb b/app/logical/moderator/dashboard/queries/comment.rb
index 197b6f997..e3ef06ff7 100644
--- a/app/logical/moderator/dashboard/queries/comment.rb
+++ b/app/logical/moderator/dashboard/queries/comment.rb
@@ -4,8 +4,27 @@ module Moderator
class Comment
attr_reader :comment, :count
+ def self.all(min_date, max_level)
+ sql = <<-EOS
+ SELECT comment_votes.comment_id, count(*)
+ FROM comment_votes
+ JOIN comments ON comments.id = comment_id
+ JOIN users ON users.id = comments.creator_id
+ WHERE
+ comment_votes.created_at > ?
+ AND comments.score < 0
+ AND users.level <= ?
+ GROUP BY comment_votes.comment_id
+ HAVING count(*) >= 3
+ ORDER BY count(*) DESC
+ LIMIT 10
+ EOS
+
+ ActiveRecord::Base.select_all_sql(sql, min_date, max_level).map {|x| new(x)}
+ end
+
def initialize(hash)
- @comment = Comment.find(hash["comment_id"])
+ @comment = ::Comment.find(hash["comment_id"])
@count = hash["count"]
end
end
diff --git a/app/logical/moderator/dashboard/queries/mod_action.rb b/app/logical/moderator/dashboard/queries/mod_action.rb
new file mode 100644
index 000000000..42917834a
--- /dev/null
+++ b/app/logical/moderator/dashboard/queries/mod_action.rb
@@ -0,0 +1,11 @@
+module Moderator
+ module Dashboard
+ module Queries
+ class ModAction
+ def self.all
+ ::ModAction.order("id desc").limit(10)
+ end
+ end
+ end
+ end
+end
diff --git a/app/logical/moderator/dashboard/queries/note.rb b/app/logical/moderator/dashboard/queries/note.rb
new file mode 100644
index 000000000..59b1825e8
--- /dev/null
+++ b/app/logical/moderator/dashboard/queries/note.rb
@@ -0,0 +1,30 @@
+module Moderator
+ module Dashboard
+ module Queries
+ class Note
+ attr_reader :user, :count
+
+ def self.all(min_date, max_level)
+ sql = <<-EOS
+ SELECT note_versions.updater_id, count(*)
+ FROM note_versions
+ JOIN users ON users.id = note_versions.updater_id
+ WHERE
+ note_versions.created_at > ?
+ AND users.level <= ?
+ GROUP BY note_versions.updater_id
+ ORDER BY count(*) DESC
+ LIMIT 10
+ EOS
+
+ ActiveRecord::Base.select_all_sql(sql, min_date, max_level).map {|x| new(x)}
+ end
+
+ def initialize(hash)
+ @user = ::User.find(hash["updater_id"])
+ @count = hash["count"]
+ end
+ end
+ end
+ end
+end
diff --git a/app/logical/moderator/dashboard/queries/post.rb b/app/logical/moderator/dashboard/queries/post.rb
deleted file mode 100644
index 09e8818db..000000000
--- a/app/logical/moderator/dashboard/queries/post.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-module Moderator
- module Dashboard
- module Queries
- class Post
- attr_reader :post, :count
-
- def initialize(hash)
- @post = Post.find(hash["post_id"])
- @count = hash["count"]
- end
- end
- end
- end
-end
diff --git a/app/logical/moderator/dashboard/queries/post_appeal.rb b/app/logical/moderator/dashboard/queries/post_appeal.rb
index a870f0b5d..0a0b9ca9a 100644
--- a/app/logical/moderator/dashboard/queries/post_appeal.rb
+++ b/app/logical/moderator/dashboard/queries/post_appeal.rb
@@ -2,7 +2,7 @@ module Moderator
module Dashboard
module Queries
class PostAppeal
- attr_reader :post, :reason
+ attr_reader :post, :count
def self.all(min_date)
sql = <<-EOS
@@ -11,7 +11,8 @@ module Moderator
JOIN posts ON posts.id = post_appeals.post_id
WHERE
post_appeals.created_at > ?
- and posts.status <> ?
+ and posts.is_deleted = true
+ and posts.is_pending = false
GROUP BY post_appeals.post_id
ORDER BY count(*) DESC
LIMIT 10
@@ -21,8 +22,8 @@ module Moderator
end
def initialize(hash)
- @post = Post.find(hash["post_id"])
- @reason = hash["reason"]
+ @post = ::Post.find(hash["post_id"])
+ @count = hash["count"]
end
end
end
diff --git a/app/logical/moderator/dashboard/queries/post_flag.rb b/app/logical/moderator/dashboard/queries/post_flag.rb
index 01374ab1b..3334f4989 100644
--- a/app/logical/moderator/dashboard/queries/post_flag.rb
+++ b/app/logical/moderator/dashboard/queries/post_flag.rb
@@ -12,7 +12,8 @@ module Moderator
WHERE
post_flags.created_at > ?
AND post_flags.reason <> ?
- AND posts.status <> 'deleted'
+ AND posts.is_deleted = false
+ and posts.is_pending = false
GROUP BY post_flags.post_id
ORDER BY count(*) DESC
LIMIT 10
diff --git a/app/logical/moderator/dashboard/queries/tag.rb b/app/logical/moderator/dashboard/queries/tag.rb
new file mode 100644
index 000000000..a529132d0
--- /dev/null
+++ b/app/logical/moderator/dashboard/queries/tag.rb
@@ -0,0 +1,32 @@
+module Moderator
+ module Dashboard
+ module Queries
+ class Tag
+ attr_reader :user, :count
+
+ def self.all(min_date, max_level)
+ sql = <<-EOS
+ SELECT post_versions.updater_id, count(*)
+ FROM post_versions
+ JOIN users ON users.id = post_versions.updater_id
+ WHERE
+ post_versions.created_at > ?
+ AND users.level <= ?
+ GROUP BY post_versions.updater_id
+ ORDER BY count(*) DESC
+ LIMIT 10
+ EOS
+
+ ActiveRecord::Base.without_timeout do
+ ActiveRecord::Base.select_all_sql(sql, min_date, max_level).map {|x| new(x)}
+ end
+ end
+
+ def initialize(hash)
+ @user = ::User.find(hash["updater_id"])
+ @count = hash["count"]
+ end
+ end
+ end
+ end
+end
diff --git a/app/logical/moderator/dashboard/queries/upload.rb b/app/logical/moderator/dashboard/queries/upload.rb
index 2e9751bae..b6a3206ce 100644
--- a/app/logical/moderator/dashboard/queries/upload.rb
+++ b/app/logical/moderator/dashboard/queries/upload.rb
@@ -2,10 +2,27 @@ module Moderator
module Dashboard
module Queries
class Upload
- def self.all(min_date)
- ActiveRecord::Base.without_timeout do
- @upload_activity = ActiveRecord::Base.select_all_sql("select posts.uploader_string, count(*) from posts join users on posts.user_id = users.id where posts.created_at > ? and users.level <= ? group by posts.user_id order by count(*) desc limit 10", min_date, max_level).map {|x| UserActivity.new(x)}
- end
+ attr_reader :user, :count
+
+ def self.all(min_date, max_level)
+ sql = <<-EOS
+ select uploader_id, count(*)
+ from posts
+ join users on uploader_id = users.id
+ where
+ posts.created_at > ?
+ and level <= ?
+ group by posts.uploader_id
+ order by count(*) desc
+ limit 10
+ EOS
+
+ ActiveRecord::Base.select_all_sql(sql, min_date, max_level).map {|x| new(x)}
+ end
+
+ def initialize(hash)
+ @user = ::User.find(hash["uploader_id"])
+ @count = hash["count"]
end
end
end
diff --git a/app/logical/moderator/dashboard/queries/user.rb b/app/logical/moderator/dashboard/queries/user.rb
deleted file mode 100644
index 0ef2031cf..000000000
--- a/app/logical/moderator/dashboard/queries/user.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-module Moderator
- module Dashboard
- module Queries
- class User
- attr_reader :user, :count
-
- def initialize(hash)
- @user = User.find(hash["user_id"])
- @count = hash["count"]
- end
- end
- end
- end
-end
\ No newline at end of file
diff --git a/app/logical/moderator/dashboard/queries/user_feedback.rb b/app/logical/moderator/dashboard/queries/user_feedback.rb
new file mode 100644
index 000000000..989f0a2a3
--- /dev/null
+++ b/app/logical/moderator/dashboard/queries/user_feedback.rb
@@ -0,0 +1,11 @@
+module Moderator
+ module Dashboard
+ module Queries
+ class UserFeedback
+ def self.all
+ ::UserFeedback.order("id desc").limit(10)
+ end
+ end
+ end
+ end
+end
diff --git a/app/logical/moderator/dashboard/queries/wiki_page.rb b/app/logical/moderator/dashboard/queries/wiki_page.rb
new file mode 100644
index 000000000..016e566f6
--- /dev/null
+++ b/app/logical/moderator/dashboard/queries/wiki_page.rb
@@ -0,0 +1,30 @@
+module Moderator
+ module Dashboard
+ module Queries
+ class WikiPage
+ attr_reader :user, :count
+
+ def self.all(min_date, max_level)
+ sql = <<-EOS
+ SELECT wiki_page_versions.updater_id, count(*)
+ FROM wiki_page_versions
+ JOIN users ON users.id = wiki_page_versions.updater_id
+ WHERE
+ wiki_page_versions.created_at > ?
+ AND users.level <= ?
+ GROUP BY wiki_page_versions.updater_id
+ ORDER BY count(*) DESC
+ LIMIT 10
+ EOS
+
+ ActiveRecord::Base.select_all_sql(sql, min_date, max_level).map {|x| new(x)}
+ end
+
+ def initialize(hash)
+ @user = ::User.find(hash["updater_id"])
+ @count = hash["count"]
+ end
+ end
+ end
+ end
+end
diff --git a/app/logical/moderator/report.rb b/app/logical/moderator/report.rb
index 92bfb5f42..bc4095550 100644
--- a/app/logical/moderator/report.rb
+++ b/app/logical/moderator/report.rb
@@ -1,6 +1,52 @@
module Moderator
module Dashboard
class Report
+ attr_reader :min_date, :max_level
+
+ def initialize(min_date, max_level)
+ @min_date = min_date
+ @max_level = max_level
+ end
+
+ def artists
+ Queries::Artist.all(min_date, max_level)
+ end
+
+ def comments
+ Queries::Comment.all(min_date, max_level)
+ end
+
+ def mod_actions
+ Queries::ModAction.all
+ end
+
+ def notes
+ Queries::Note.all(min_date, max_level)
+ end
+
+ def appeals
+ Queries::PostAppeal.all(min_date)
+ end
+
+ def flags
+ Queries::PostFlag.all(min_date)
+ end
+
+ def tags
+ Queries::Tag.all(min_date, max_level)
+ end
+
+ def posts
+ Queries::Upload.all(min_date, max_level)
+ end
+
+ def user_feedbacks
+ Queries::UserFeedback.all
+ end
+
+ def wiki_pages
+ Queries::WikiPage.all(min_date, max_level)
+ end
end
end
end
diff --git a/app/logical/moderator_dashboard.rb b/app/logical/moderator_dashboard.rb
deleted file mode 100644
index 3286bf47d..000000000
--- a/app/logical/moderator_dashboard.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-class ModeratorDashboard
- attr_reader :min_date, :max_level
-
- def initialize(min_date, max_level)
- @min_date = min_date
- @max_level = max_level
- end
-
- def upload_activity
-
-
- @upload_activity
- end
-
- def comment_activity(positive = false)
- if positive
- ActiveRecord::Base.select_all_sql("SELECT comment_votes.comment_id, count(*) FROM comment_votes JOIN comments ON comments.id = comment_votes.comment_id JOIN users ON users.id = comments.user_id WHERE comment_votes.created_at > ? AND comments.score > 0 AND users.level <= ? GROUP BY comment_votes.comment_id HAVING count(*) >= 3 ORDER BY count(*) DESC LIMIT 10", min_date, max_level).map {|x| CommentActivity.new(x)}
- else
- ActiveRecord::Base.select_all_sql("SELECT comment_votes.comment_id, count(*) FROM comment_votes JOIN comments ON comments.id = comment_votes.comment_id JOIN users ON users.id = comments.user_id WHERE comment_votes.created_at > ? AND comments.score < 0 AND users.level <= ? GROUP BY comment_votes.comment_id HAVING count(*) >= 3 ORDER BY count(*) DESC LIMIT 10", min_date, max_level).map {|x| CommentActivity.new(x)}
- end
- end
-
- def post_activity(positive = false)
- ActiveRecord::Base.without_timeout do
- if positive
- @post_activity = ActiveRecord::Base.select_all_sql("SELECT post_votes.post_id, count(*) FROM post_votes JOIN posts ON posts.id = post_votes.post_id JOIN users ON users.id = posts.user_id WHERE post_votes.created_at > ? AND posts.score > 0 AND users.level <= ? GROUP BY post_votes.post_id HAVING count(*) >= 3 ORDER BY count(*) DESC LIMIT 10", min_date, max_level).map {|x| PostActivity.new(x)}
- else
- @post_activity = ActiveRecord::Base.select_all_sql("SELECT post_votes.post_id, count(*) FROM post_votes JOIN posts ON posts.id = post_votes.post_id JOIN users ON users.id = posts.user_id WHERE post_votes.created_at > ? AND posts.score < 0 AND users.level <= ? AND posts.status <> 'deleted' GROUP BY post_votes.post_id HAVING count(*) >= 3 ORDER BY count(*) DESC LIMIT 10", min_date, max_level).map {|x| PostActivity.new(x)}
- end
- end
-
- @post_activity
- end
-
- def tag_activity
- ActiveRecord::Base.without_timeout do
- @tag_activity = ActiveRecord::Base.select_all_sql("SELECT post_tag_histories.user_id, count(*) FROM post_tag_histories JOIN users ON users.id = post_tag_histories.user_id WHERE post_tag_histories.created_at > ? AND users.level <= ? GROUP BY post_tag_histories.user_id ORDER BY count(*) DESC LIMIT 10", min_date, max_level).map {|x| UserActivity.new(x)}
- end
-
- @tag_activity
- end
-
- def note_activity
- ActiveRecord::Base.select_all_sql("SELECT note_versions.user_id, count(*) FROM note_versions JOIN users ON users.id = note_versions.user_id WHERE note_versions.created_at > ? AND users.level <= ? GROUP BY note_versions.user_id ORDER BY count(*) DESC LIMIT 10", min_date, max_level).map {|x| UserActivity.new(x)}
- end
-
- def wiki_page_activity
- ActiveRecord::Base.select_all_sql("SELECT wiki_page_versions.user_id, count(*) FROM wiki_page_versions JOIN users ON users.id = wiki_page_versions.user_id WHERE wiki_page_versions.created_at > ? AND users.level <= ? GROUP BY wiki_page_versions.user_id ORDER BY count(*) DESC LIMIT 10", min_date, max_level).map {|x| UserActivity.new(x)}
- end
-
- def artist_activity
- ActiveRecord::Base.select_all_sql("SELECT artist_versions.updater_id AS user_id, count(*) FROM artist_versions JOIN users ON users.id = artist_versions.updater_id WHERE artist_versions.created_at > ? AND users.level <= ? GROUP BY artist_versions.updater_id ORDER BY count(*) DESC LIMIT 10", min_date, max_level).map {|x| UserActivity.new(x)}
- end
-end
diff --git a/app/models/mod_action.rb b/app/models/mod_action.rb
new file mode 100644
index 000000000..e5c1428b9
--- /dev/null
+++ b/app/models/mod_action.rb
@@ -0,0 +1,3 @@
+class ModAction < ActiveRecord::Base
+ belongs_to :creator, :class_name => "User"
+end
diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb
index 9b202fd16..d903323f6 100644
--- a/app/views/layouts/default.html.erb
+++ b/app/views/layouts/default.html.erb
@@ -42,8 +42,9 @@
<%= nav_link_to("Pools", pools_path) %>
<%= nav_link_to("Wiki", wiki_pages_path(:title => "help:home")) %>
<%= nav_link_to("Forum", forum_topics_path, :class => (CurrentUser.user.has_forum_been_updated? ? "forum-updated" : nil)) %>
- <% if CurrentUser.is_moderator? %>
+ <% if CurrentUser.is_janitor? %>
<%= nav_link_to("Dashboard", moderator_dashboard_path) %>
+ <%= nav_link_to("Queue", moderator_post_dashboard_path) %>
<% end %>
<%= nav_link_to("»".html_safe, site_map_path) %>
diff --git a/app/views/moderator/dashboards/_activity_appeal.html.erb b/app/views/moderator/dashboards/_activity_appeal.html.erb
new file mode 100644
index 000000000..282acf61f
--- /dev/null
+++ b/app/views/moderator/dashboards/_activity_appeal.html.erb
@@ -0,0 +1,25 @@
+
+ Appeals
+
+
+ Post
+ User
+ Flags
+ Appeals
+ Score
+
+
+
+ <% @dashboard.appeals.each do |appeal| %>
+
+ <%= link_to image_tag(appeal.post.preview_file_url), post_path(appeal.post) %>
+ <%= mod_link_to_user appeal.post.uploader, :negative %>
+ <%= post_flag_reasons(appeal.post) %>
+ <%= post_appeal_reasons(appeal.post) %>
+ <%= appeal.post.score %>
+
+ <% end %>
+
+
+
+<%= link_to "View all appeals", post_appeals_path %>
diff --git a/app/views/moderator/dashboards/_activity_artist.html.erb b/app/views/moderator/dashboards/_activity_artist.html.erb
new file mode 100644
index 000000000..0925d5ca7
--- /dev/null
+++ b/app/views/moderator/dashboards/_activity_artist.html.erb
@@ -0,0 +1,17 @@
+
+ Artist Updates
+
+
+ User
+ Count
+
+
+
+ <% @dashboard.artists.each do |activity| %>
+
+ <%= mod_link_to_user(activity.user, :positive) %>
+ <%= link_to activity.count, artist_versions_path(:search => {:updater_id_eq => activity.user.id}) %>
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/moderator/dashboards/_activity_comment.html.erb b/app/views/moderator/dashboards/_activity_comment.html.erb
new file mode 100644
index 000000000..47d592dc0
--- /dev/null
+++ b/app/views/moderator/dashboards/_activity_comment.html.erb
@@ -0,0 +1,21 @@
+
+ Comment Activity
+
+
+ Comment
+ User
+ Votes
+ Score
+
+
+
+ <% @dashboard.comments.each do |activity| %>
+
+ <%= link_to activity.comment.body, post_path(activity.comment.post_id) %>
+ <%= mod_link_to_user(activity.comment.creator, :negative) %>
+ <%= activity.count %>
+ <%= activity.comment.score %>
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/moderator/dashboards/_activity_mod_action.html.erb b/app/views/moderator/dashboards/_activity_mod_action.html.erb
new file mode 100644
index 000000000..02a096488
--- /dev/null
+++ b/app/views/moderator/dashboards/_activity_mod_action.html.erb
@@ -0,0 +1,19 @@
+
+ Mod Actions
+
+
+ Moderator
+ Description
+
+
+
+ <% @dashboard.mod_actions.each do |mod_action| %>
+
+ <%= link_to mod_action.creator.name, user_path(mod_action.creator) %>
+ <%= format_text(mod_action.description) %>
+
+ <% end %>
+
+
+
+<%= link_to "View all actions", mod_actions_path %>
\ No newline at end of file
diff --git a/app/views/moderator/dashboards/_activity_note.html.erb b/app/views/moderator/dashboards/_activity_note.html.erb
new file mode 100644
index 000000000..ffcf7c392
--- /dev/null
+++ b/app/views/moderator/dashboards/_activity_note.html.erb
@@ -0,0 +1,17 @@
+
+ Note Updates
+
+
+ User
+ Count
+
+
+
+ <% @dashboard.notes.each do |activity| %>
+
+ <%= mod_link_to_user(activity.user, :positive) %>
+ <%= link_to activity.count, note_versions_path(:search => {:updater_id_eq => activity.user.id}) %>
+
+ <% end %>
+
+
diff --git a/app/views/moderator/dashboards/_activity_tag.html.erb b/app/views/moderator/dashboards/_activity_tag.html.erb
new file mode 100644
index 000000000..3b30f8f65
--- /dev/null
+++ b/app/views/moderator/dashboards/_activity_tag.html.erb
@@ -0,0 +1,17 @@
+
+ Tag Updates
+
+
+ User
+ Count
+
+
+
+ <% @dashboard.tags.each do |activity| %>
+
+ <%= mod_link_to_user(activity.user, :positive) %>
+ <%= link_to activity.count, post_versions_path(:search => {:updater_id_eq => activity.user.id}) %>
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/moderator/dashboards/_activity_upload.html.erb b/app/views/moderator/dashboards/_activity_upload.html.erb
new file mode 100644
index 000000000..48cdc779b
--- /dev/null
+++ b/app/views/moderator/dashboards/_activity_upload.html.erb
@@ -0,0 +1,17 @@
+
+ Uploads
+
+
+ User
+ Count
+
+
+
+ <% @dashboard.posts.each do |activity| %>
+
+ <%= mod_link_to_user(activity.user, :positive) %>
+ <%= link_to activity.count, posts_path(:tags => "user:#{activity.user.name}") %>
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/moderator/dashboards/_activity_user_feedback.html.erb b/app/views/moderator/dashboards/_activity_user_feedback.html.erb
new file mode 100644
index 000000000..b13a6c6e6
--- /dev/null
+++ b/app/views/moderator/dashboards/_activity_user_feedback.html.erb
@@ -0,0 +1,19 @@
+
+ User Feedback
+
+
+ User
+ Message
+ Date
+
+
+
+ <% @dashboard.user_feedbacks.each do |record| %>
+
+ <%= link_to(record.user.name, user_path(record.user)) %>
+ <%= format_text(record.body) %>
+ <%= time_ago_in_words(record.created_at) %> ago
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/moderator/dashboards/_activity_wiki_page.html.erb b/app/views/moderator/dashboards/_activity_wiki_page.html.erb
new file mode 100644
index 000000000..968c18e52
--- /dev/null
+++ b/app/views/moderator/dashboards/_activity_wiki_page.html.erb
@@ -0,0 +1,17 @@
+
+ Wiki Page Updates
+
+
+ User
+ Count
+
+
+
+ <% @dashboard.wiki_pages.each do |activity| %>
+
+ <%= mod_link_to_user(activity.user, :positive) %>
+ <%= link_to activity.count, wiki_page_versions_path(:search => {:updater_id_eq => activity.user.id}) %>
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/moderator/dashboards/_search.html.erb b/app/views/moderator/dashboards/_search.html.erb
new file mode 100644
index 000000000..5afb07120
--- /dev/null
+++ b/app/views/moderator/dashboards/_search.html.erb
@@ -0,0 +1,7 @@
+
+ <%= render "search_ip_addr" %>
+
+
+
+ <%= render "search_activity" %>
+
diff --git a/app/views/moderator/dashboards/_search_activity.html.erb b/app/views/moderator/dashboards/_search_activity.html.erb
new file mode 100644
index 000000000..5cc65d056
--- /dev/null
+++ b/app/views/moderator/dashboards/_search_activity.html.erb
@@ -0,0 +1,9 @@
+<% form_tag(moderator_dashboard_path, :method => :get) do %>
+ Minimum Date
+ <%= text_field_tag :min_date, @dashboard.min_date %>
+
+ Max Level
+ <%= user_level_select_tag(:max_level) %>
+
+ <%= submit_tag "Search" %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/moderator/dashboards/_search_ip_addr.html.erb b/app/views/moderator/dashboards/_search_ip_addr.html.erb
new file mode 100644
index 000000000..265eb4558
--- /dev/null
+++ b/app/views/moderator/dashboards/_search_ip_addr.html.erb
@@ -0,0 +1,11 @@
+<% form_tag(moderator_ip_addrs_path, :method => :get) do %>
+ Search IPs
+ <%= text_field_tag "search[ip_addr_eq]", params[:ip_addrs] %>
+ <%= submit_tag "Search" %>
+<% end %>
+
+<% form_tag(moderator_ip_addrs_path, :method => :get) do %>
+ Search User IDs
+ <%= text_field_tag "search[user_id_eq]", params[:user_ids] %>
+ <%= submit_tag "Search" %>
+<% end %>
diff --git a/app/views/moderator/dashboards/show.html.erb b/app/views/moderator/dashboards/show.html.erb
index ec8a8872a..fcd369868 100644
--- a/app/views/moderator/dashboards/show.html.erb
+++ b/app/views/moderator/dashboards/show.html.erb
@@ -1,222 +1,22 @@
-
-
Moderator Dashboard
-
-
- <% form_tag(moderator_ip_addrs_path, :method => :get) do %>
- Search IPs
- <%= text_field_tag "search[ip_addr_eq]", params[:ip_addrs] %>
- <%= submit_tag "Search" %>
- <% end %>
-
- <% form_tag(moderator_ip_addrs_path, :method => :get) do %>
- Search User IDs
- <%= text_field_tag "search[user_id_eq]", params[:user_ids] %>
- <%= submit_tag "Search" %>
- <% end %>
-
-
-
- <% form_tag(moderator_dashboard_path, :method => :get) do %>
- Minimum Date
- <%= text_field_tag :min_date, @dashboard.min_date %>
-
- Max Level
- <%= user_level_select_tag(:max_level) %>
-
- <%= submit_tag "Search" %>
- <% end %>
-
-
-
-
-
-
- Appealed Posts
-
-
- Post
- User
- Flags
- Appeals
- Score
-
-
-
-
- <%= link_to "View all posts", :controller => "post_appeal", :action => "index" %>
-
-
-
- <% @dashboard.appealed_posts.each do |appeal| %>
-
- <%= link_to image_tag(appeal.post.preview_url), :controller => "post", :action => "show", :id => appeal.post.id %>
- <%= admin_link_to_user appeal.post.user, :negative %>
- <%= post_flag_summary(appeal.post) %>
- <%= post_appeal_summary(appeal.post) %>
- <%= appeal.post.score %>
-
- <% end %>
-
-
+
+
+
Moderator Dashboard
-
- User Records
-
-
- User
- Message
- Date
-
-
-
- <% UserRecord.recent(@dashboard.min_date).all(:order => "id desc").each do |record| %>
-
- <%= link_to(record.user.name, :controller => "user", :action => "show", :id => record.user_id) %>
- <%= format_text(record.body) %>
- <%= time_ago_in_words(record.created_at) %> ago
-
- <% end %>
-
-
-
-
-
- Mod Actions
-
-
- Moderator
- Description
-
-
-
-
- <%= link_to "View all actions", :controller => "mod_action", :action => "index" %>
-
-
-
- <% ModAction.all(:order => "id desc", :limit => 10).each do |mod_action| %>
-
- <%= link_to mod_action.user.name, :controller => "user", :action => "show", :id => mod_action.user_id %>
- <%= format_text(mod_action.description) %>
-
- <% end %>
-
-
+ <%= render "search" %>
+
+
+ <%= render "activity_upload" %>
+ <%= render "activity_note" %>
+ <%= render "activity_tag" %>
+ <%= render "activity_wiki_page" %>
+ <%= render "activity_artist" %>
+ <%= render "activity_comment" %>
+
+
+
+ <%= render "activity_appeal" %>
+ <%= render "activity_user_feedback" %>
+ <%= render "activity_mod_action" %>
+
-
\ No newline at end of file
+
diff --git a/config/initializers/active_record_extensions.rb b/config/initializers/active_record_extensions.rb
index 34500b6b7..480bdc69d 100644
--- a/config/initializers/active_record_extensions.rb
+++ b/config/initializers/active_record_extensions.rb
@@ -5,17 +5,17 @@ module Danbooru
module ClassMethods
def without_timeout
- connection.execute("SET STATEMENT_TIMEOUT = 0")
+ connection.execute("SET STATEMENT_TIMEOUT = 0") unless Rails.env == "test"
yield
ensure
- connection.execute("SET STATEMENT_TIMEOUT = 10000")
+ connection.execute("SET STATEMENT_TIMEOUT = 5000") unless Rails.env == "test"
end
def with_timeout(n)
- connection.execute("SET STATEMENT_TIMEOUT = #{n}")
+ connection.execute("SET STATEMENT_TIMEOUT = #{n}") unless Rails.env == "test"
yield
ensure
- connection.execute("SET STATEMENT_TIMEOUT = 10000")
+ connection.execute("SET STATEMENT_TIMEOUT = 5000") unless Rails.env == "test"
end
end
diff --git a/config/routes.rb b/config/routes.rb
index fc1bf6bd8..dc72b45af 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -20,6 +20,12 @@ Danbooru::Application.routes.draw do
end
end
end
+ resources :invitations, :only => [:new, :create, :index, :show]
+ resources :ip_addrs, :only => [:index, :search] do
+ collection do
+ get :search
+ end
+ end
end
resources :advertisements do
resources :hits, :controller => "advertisement_hits", :only => [:create]
@@ -57,6 +63,7 @@ Danbooru::Application.routes.draw do
end
resources :jobs
resources :ip_bans
+ resources :mod_actions
resources :notes do
collection do
get :search
diff --git a/db/development_structure.sql b/db/development_structure.sql
index 075f9dbbe..91fbfe239 100644
--- a/db/development_structure.sql
+++ b/db/development_structure.sql
@@ -1818,6 +1818,38 @@ CREATE SEQUENCE janitor_trials_id_seq
ALTER SEQUENCE janitor_trials_id_seq OWNED BY janitor_trials.id;
+--
+-- Name: mod_actions; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE mod_actions (
+ id integer NOT NULL,
+ creator_id integer NOT NULL,
+ description text NOT NULL,
+ created_at timestamp without time zone,
+ updated_at timestamp without time zone
+);
+
+
+--
+-- Name: mod_actions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE mod_actions_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MAXVALUE
+ NO MINVALUE
+ CACHE 1;
+
+
+--
+-- Name: mod_actions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE mod_actions_id_seq OWNED BY mod_actions.id;
+
+
--
-- Name: note_versions; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@@ -2678,6 +2710,13 @@ ALTER TABLE ip_bans ALTER COLUMN id SET DEFAULT nextval('ip_bans_id_seq'::regcla
ALTER TABLE janitor_trials ALTER COLUMN id SET DEFAULT nextval('janitor_trials_id_seq'::regclass);
+--
+-- Name: id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE mod_actions ALTER COLUMN id SET DEFAULT nextval('mod_actions_id_seq'::regclass);
+
+
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
@@ -2938,6 +2977,14 @@ ALTER TABLE ONLY janitor_trials
ADD CONSTRAINT janitor_trials_pkey PRIMARY KEY (id);
+--
+-- Name: mod_actions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY mod_actions
+ ADD CONSTRAINT mod_actions_pkey PRIMARY KEY (id);
+
+
--
-- Name: note_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@@ -5171,4 +5218,6 @@ INSERT INTO schema_migrations (version) VALUES ('20110328215701');
INSERT INTO schema_migrations (version) VALUES ('20110607194023');
-INSERT INTO schema_migrations (version) VALUES ('20110717010705');
\ No newline at end of file
+INSERT INTO schema_migrations (version) VALUES ('20110717010705');
+
+INSERT INTO schema_migrations (version) VALUES ('20110722211855');
\ No newline at end of file
diff --git a/db/migrate/20110722211855_create_mod_actions.rb b/db/migrate/20110722211855_create_mod_actions.rb
new file mode 100644
index 000000000..40564cb79
--- /dev/null
+++ b/db/migrate/20110722211855_create_mod_actions.rb
@@ -0,0 +1,9 @@
+class CreateModActions < ActiveRecord::Migration
+ def change
+ create_table :mod_actions do |t|
+ t.column :creator_id, :integer, :null => false
+ t.column :description, :text, :null => false
+ t.timestamps
+ end
+ end
+end
diff --git a/test/factories/mod_action.rb b/test/factories/mod_action.rb
new file mode 100644
index 000000000..a92bd012c
--- /dev/null
+++ b/test/factories/mod_action.rb
@@ -0,0 +1,4 @@
+Factory.define(:mod_action) do |f|
+ f.creator {|x| x.association(:user)}
+ f.description "1234"
+end
diff --git a/test/fixtures/user_password_reset_nonces.yml b/test/fixtures/user_password_reset_nonces.yml
deleted file mode 100644
index 5394fa384..000000000
--- a/test/fixtures/user_password_reset_nonces.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-# Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html
-
-# This model initially had no columns defined. If you add columns to the
-# model remove the '{}' from the fixture names and add the columns immediately
-# below each fixture, per the syntax in the comments below
-#
-one: {}
-# column: value
-#
-two: {}
-# column: value
diff --git a/test/functional/moderator/dashboards_controller_test.rb b/test/functional/moderator/dashboards_controller_test.rb
new file mode 100644
index 000000000..199fcd526
--- /dev/null
+++ b/test/functional/moderator/dashboards_controller_test.rb
@@ -0,0 +1,133 @@
+require 'test_helper'
+
+module Moderator
+ class DashboardsControllerTest < ActionController::TestCase
+ context "The moderator dashboards controller" do
+ setup do
+ @admin = Factory.create(:admin_user)
+ CurrentUser.user = @admin
+ CurrentUser.ip_addr = "127.0.0.1"
+ end
+
+ context "show action" do
+ context "for mod actions" do
+ setup do
+ @mod_action = Factory.create(:mod_action)
+ end
+
+ should "render" do
+ assert_equal(1, ModAction.count)
+ get :show, {}, {:user_id => @admin.id}
+ assert_response :success
+ end
+ end
+
+ context "for user feedbacks" do
+ setup do
+ @feedback = Factory.create(:user_feedback)
+ end
+
+ should "render" do
+ assert_equal(1, UserFeedback.count)
+ get :show, {}, {:user_id => @admin.id}
+ assert_response :success
+ end
+ end
+
+ context "for wiki pages" do
+ setup do
+ @wiki_page = Factory.create(:wiki_page)
+ end
+
+ should "render" do
+ assert_equal(1, WikiPageVersion.count)
+ get :show, {}, {:user_id => @admin.id}
+ assert_response :success
+ end
+ end
+
+ context "for tags and uploads" do
+ setup do
+ @post = Factory.create(:post)
+ end
+
+ should "render" do
+ assert_equal(1, PostVersion.count)
+ get :show, {}, {:user_id => @admin.id}
+ assert_response :success
+ end
+ end
+
+ context "for notes"do
+ setup do
+ @post = Factory.create(:post)
+ @note = Factory.create(:note, :post_id => @post.id)
+ end
+
+ should "render" do
+ assert_equal(1, NoteVersion.count)
+ get :show, {}, {:user_id => @admin.id}
+ assert_response :success
+ end
+ end
+
+ context "for comments" do
+ setup do
+ @users = (0..5).map {Factory.create(:user)}
+
+ CurrentUser.scoped(@users[0], "1.2.3.4") do
+ @comment = Factory.create(:comment)
+ end
+
+ @users.each do |user|
+ CurrentUser.scoped(user, "1.2.3.4") do
+ @comment.vote!(-1)
+ end
+ end
+ end
+
+ should "render" do
+ get :show, {}, {:user_id => @admin.id}
+ assert_response :success
+ end
+ end
+
+ context "for artists" do
+ setup do
+ @artist = Factory.create(:artist)
+ end
+
+ should "render" do
+ get :show, {}, {:user_id => @admin.id}
+ assert_equal(1, ArtistVersion.count)
+ assert_response :success
+ end
+ end
+
+ context "for flags" do
+ setup do
+ @post = Factory.create(:post)
+ @post.flag!("blah")
+ end
+
+ should "render" do
+ get :show, {}, {:user_id => @admin.id}
+ assert_response :success
+ end
+ end
+
+ context "for appeals" do
+ setup do
+ @post = Factory.create(:post, :is_deleted => true)
+ @post.appeal!("blah")
+ end
+
+ should "render" do
+ get :show, {}, {:user_id => @admin.id}
+ assert_response :success
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/test/unit/mod_action_test.rb b/test/unit/mod_action_test.rb
new file mode 100644
index 000000000..cce196538
--- /dev/null
+++ b/test/unit/mod_action_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class ModActionTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end