From 5a153221c50af4870337b3dd9728a76df6814cec Mon Sep 17 00:00:00 2001
From: r888888888
Date: Thu, 6 Nov 2014 17:45:44 -0800
Subject: [PATCH 1/2] approve name change requests by default
---
app/controllers/user_name_change_requests_controller.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/controllers/user_name_change_requests_controller.rb b/app/controllers/user_name_change_requests_controller.rb
index 2f62cf54e..9c2eaaf61 100644
--- a/app/controllers/user_name_change_requests_controller.rb
+++ b/app/controllers/user_name_change_requests_controller.rb
@@ -18,7 +18,8 @@ class UserNameChangeRequestsController < ApplicationController
if @change_request.errors.any?
render :action => "new"
else
- redirect_to user_name_change_request_path(@change_request), :notice => "Your request has been submitted and is pending admin review"
+ @change_request.approve!
+ redirect_to user_name_change_request_path(@change_request), :notice => "Your name has been changed"
end
end
From 7195c0b5fd0c7462617a8b3fcf315ab95495b804 Mon Sep 17 00:00:00 2001
From: r888888888
Date: Wed, 24 Sep 2014 14:03:42 -0700
Subject: [PATCH 2/2] admin dashboard
---
.../specific/admin_dashboards.css.scss | 5 ++
.../admin/dashboards_controller.rb | 9 ++++
app/logical/admin_dashboard.rb | 17 +++++++
app/views/admin/dashboards/_aliases.html.erb | 0
app/views/admin/dashboards/show.html.erb | 29 +++++++++++
.../bulk_update_requests/_listing.html.erb | 30 +++++++++++
app/views/bulk_update_requests/index.html.erb | 31 +----------
app/views/forum_topics/_listing.html.erb | 38 ++++++++++++++
app/views/forum_topics/index.html.erb | 39 +-------------
app/views/static/site_map.html.erb | 1 +
app/views/tag_aliases/_listing.html.erb | 46 +++++++++++++++++
app/views/tag_aliases/index.html.erb | 51 ++-----------------
app/views/tag_implications/_listing.html.erb | 40 +++++++++++++++
app/views/tag_implications/index.html.erb | 41 +--------------
config/routes.rb | 1 +
15 files changed, 222 insertions(+), 156 deletions(-)
create mode 100644 app/assets/stylesheets/specific/admin_dashboards.css.scss
create mode 100644 app/controllers/admin/dashboards_controller.rb
create mode 100644 app/logical/admin_dashboard.rb
create mode 100644 app/views/admin/dashboards/_aliases.html.erb
create mode 100644 app/views/admin/dashboards/show.html.erb
create mode 100644 app/views/bulk_update_requests/_listing.html.erb
create mode 100644 app/views/forum_topics/_listing.html.erb
create mode 100644 app/views/tag_aliases/_listing.html.erb
create mode 100644 app/views/tag_implications/_listing.html.erb
diff --git a/app/assets/stylesheets/specific/admin_dashboards.css.scss b/app/assets/stylesheets/specific/admin_dashboards.css.scss
new file mode 100644
index 000000000..aa59f308d
--- /dev/null
+++ b/app/assets/stylesheets/specific/admin_dashboards.css.scss
@@ -0,0 +1,5 @@
+#c-admin-dashboards {
+ .section {
+ margin-bottom: 2em;
+ }
+}
\ No newline at end of file
diff --git a/app/controllers/admin/dashboards_controller.rb b/app/controllers/admin/dashboards_controller.rb
new file mode 100644
index 000000000..83076fdd7
--- /dev/null
+++ b/app/controllers/admin/dashboards_controller.rb
@@ -0,0 +1,9 @@
+module Admin
+ class DashboardsController < ApplicationController
+ before_filter :admin_only
+
+ def show
+ @dashboard = AdminDashboard.new
+ end
+ end
+end
diff --git a/app/logical/admin_dashboard.rb b/app/logical/admin_dashboard.rb
new file mode 100644
index 000000000..8d4635e0d
--- /dev/null
+++ b/app/logical/admin_dashboard.rb
@@ -0,0 +1,17 @@
+class AdminDashboard
+ def tag_aliases
+ TagAlias.where(status: "pending").order("id desc")
+ end
+
+ def tag_implications
+ TagImplication.where(status: "pending").order("id desc")
+ end
+
+ def update_requests
+ BulkUpdateRequest.where(status: "pending").order("id desc")
+ end
+
+ def forum_topics
+ ForumTopic.where(category_id: 1).order("id desc").limit(20)
+ end
+end
diff --git a/app/views/admin/dashboards/_aliases.html.erb b/app/views/admin/dashboards/_aliases.html.erb
new file mode 100644
index 000000000..e69de29bb
diff --git a/app/views/admin/dashboards/show.html.erb b/app/views/admin/dashboards/show.html.erb
new file mode 100644
index 000000000..e45999905
--- /dev/null
+++ b/app/views/admin/dashboards/show.html.erb
@@ -0,0 +1,29 @@
+
+
+
Admin Dashboard
+
+
+
Aliases
+ <%= render "tag_aliases/listing", :tag_aliases => @dashboard.tag_aliases %>
+
+
+
+
Implications
+ <%= render "tag_implications/listing", :tag_implications => @dashboard.tag_implications %>
+
+
+
+
Bulk Update Requests
+ <%= render "bulk_update_requests/listing", :bulk_update_requests => @dashboard.update_requests %>
+
+
+
+
Forum Topics
+ <%= render "forum_topics/listing", :forum_topics => @dashboard.forum_topics %>
+
+
+
+
+<% content_for(:page_title) do %>
+ Admin Dashboard - <%= Danbooru.config.app_name %>
+<% end %>
diff --git a/app/views/bulk_update_requests/_listing.html.erb b/app/views/bulk_update_requests/_listing.html.erb
new file mode 100644
index 000000000..168664f9d
--- /dev/null
+++ b/app/views/bulk_update_requests/_listing.html.erb
@@ -0,0 +1,30 @@
+
+
+
+ | Creator |
+ Forum |
+ Script |
+ Status |
+ |
+
+
+
+ <% bulk_update_requests.each do |request| %>
+
+ | <%= link_to_user(request.user) %> |
+ <%= link_to(request.forum_topic_id, forum_topic_path(request.forum_topic_id)) %> |
+ <%= script_with_line_breaks(request.script) %> |
+ <%= request.status %> |
+
+ <% if CurrentUser.is_moderator? && request.status == "pending" %>
+ <%= link_to "Approve", approve_bulk_update_request_path(request), :method => :post %> |
+ <% end %>
+ <% if request.editable?(CurrentUser.user) %>
+ <%= link_to "Delete", bulk_update_request_path(request), :method => :delete, :data => {:confirm => "Are you sure you want to delete this bulk update request?"} %> |
+ <%= link_to "Edit", edit_bulk_update_request_path(request) %>
+ <% end %>
+ |
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/bulk_update_requests/index.html.erb b/app/views/bulk_update_requests/index.html.erb
index a8ecfe89d..209f4ab24 100644
--- a/app/views/bulk_update_requests/index.html.erb
+++ b/app/views/bulk_update_requests/index.html.erb
@@ -2,36 +2,7 @@
Bulk Update Requests
-
-
-
- | Creator |
- Forum |
- Script |
- Status |
- |
-
-
-
- <% @bulk_update_requests.each do |request| %>
-
- | <%= link_to_user(request.user) %> |
- <%= link_to(request.forum_topic_id, forum_topic_path(request.forum_topic_id)) %> |
- <%= script_with_line_breaks(request.script) %> |
- <%= request.status %> |
-
- <% if CurrentUser.is_moderator? && request.status == "pending" %>
- <%= link_to "Approve", approve_bulk_update_request_path(request), :method => :post %> |
- <% end %>
- <% if request.editable?(CurrentUser.user) %>
- <%= link_to "Delete", bulk_update_request_path(request), :method => :delete, :data => {:confirm => "Are you sure you want to delete this bulk update request?"} %> |
- <%= link_to "Edit", edit_bulk_update_request_path(request) %>
- <% end %>
- |
-
- <% end %>
-
-
+ <%= render "listing", :bulk_update_requests => @bulk_update_requests %>
<%= numbered_paginator(@bulk_update_requests) %>
diff --git a/app/views/forum_topics/_listing.html.erb b/app/views/forum_topics/_listing.html.erb
new file mode 100644
index 000000000..241213112
--- /dev/null
+++ b/app/views/forum_topics/_listing.html.erb
@@ -0,0 +1,38 @@
+
+
+
+ | Title |
+ Creator |
+ Updated by |
+ Updated at |
+
+
+
+ <% forum_topics.each do |topic| %>
+
+ |
+ <% if topic.is_sticky? %>
+ Sticky:
+ <% end %>
+
+ <% unless topic.read_by?(CurrentUser.user) %>
+ NEW
+ <% end %>
+
+ <%= link_to topic.title, forum_topic_path(topic) %>
+
+ <% if topic.response_count > Danbooru.config.posts_per_page %>
+ <%= link_to "page #{topic.last_page}", forum_topic_path(topic, :page => topic.last_page), :class => "last-page" %>
+ <% end %>
+
+ <% if topic.is_locked? %>
+ (locked)
+ <% end %>
+ |
+ <%= link_to_user topic.creator %> |
+ <%= link_to_user topic.updater %> |
+ <%= compact_time topic.updated_at %> |
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/forum_topics/index.html.erb b/app/views/forum_topics/index.html.erb
index 2674ea267..ab3e1a34a 100644
--- a/app/views/forum_topics/index.html.erb
+++ b/app/views/forum_topics/index.html.erb
@@ -7,44 +7,7 @@
<%= link_to "All", forum_topics_path %>, <%= ForumTopic::CATEGORIES.map {|id, name| link_to_unless_current(name, forum_topics_path(:search => {:category_id => id}))}.join(", ").html_safe %>
-
-
-
- | Title |
- Creator |
- Updated by |
- Updated at |
-
-
-
- <% @forum_topics.each do |topic| %>
-
- |
- <% if topic.is_sticky? %>
- Sticky:
- <% end %>
-
- <% unless topic.read_by?(CurrentUser.user) %>
- NEW
- <% end %>
-
- <%= link_to topic.title, forum_topic_path(topic) %>
-
- <% if topic.response_count > Danbooru.config.posts_per_page %>
- <%= link_to "page #{topic.last_page}", forum_topic_path(topic, :page => topic.last_page), :class => "last-page" %>
- <% end %>
-
- <% if topic.is_locked? %>
- (locked)
- <% end %>
- |
- <%= link_to_user topic.creator %> |
- <%= link_to_user topic.updater %> |
- <%= compact_time topic.updated_at %> |
-
- <% end %>
-
-
+ <%= render "listing", :forum_topics => @forum_topics %>
<%= numbered_paginator(@forum_topics) %>
diff --git a/app/views/static/site_map.html.erb b/app/views/static/site_map.html.erb
index 67727a4a2..88abc2b5c 100644
--- a/app/views/static/site_map.html.erb
+++ b/app/views/static/site_map.html.erb
@@ -113,6 +113,7 @@
<%= link_to("IP Bans", ip_bans_path) %>
<%= link_to("News Updates", news_updates_path) %>
<%= link_to("Alias & Implication Import", new_admin_alias_and_implication_import_path) %>
+ <%= link_to("Admin Dashboard", admin_dashboard_path) %>
<% end %>
<% if Danbooru.config.is_user_advertiser?(CurrentUser.user) %>
diff --git a/app/views/tag_aliases/_listing.html.erb b/app/views/tag_aliases/_listing.html.erb
new file mode 100644
index 000000000..92ce141cc
--- /dev/null
+++ b/app/views/tag_aliases/_listing.html.erb
@@ -0,0 +1,46 @@
+
+
+
+ | From |
+ To |
+ Reference |
+ Status |
+ |
+
+
+
+ <% tag_aliases.each do |tag_alias| %>
+
+ | <%= link_to tag_alias.antecedent_name, posts_path(:tags => tag_alias.antecedent_name) %> <%= tag_alias.antecedent_tag.post_count rescue 0 %> |
+ <%= link_to tag_alias.consequent_name, posts_path(:tags => tag_alias.consequent_name) %> <%= tag_alias.consequent_tag.post_count rescue 0 %> |
+
+ <% if tag_alias.forum_topic_id %>
+ <%= link_to tag_alias.forum_topic_id, forum_topic_path(tag_alias.forum_topic_id) %>
+ <% end %>
+ |
+
+ <%= tag_alias.status %>
+ |
+
+ <%= link_to "Show", tag_alias_path(tag_alias) %>
+
+ <% if tag_alias.editable_by?(CurrentUser.user) %>
+ | <%= link_to "Edit", edit_tag_alias_path(tag_alias) %>
+ <% end %>
+
+ <% if tag_alias.is_pending? && tag_alias.editable_by?(CurrentUser.user) %>
+ | <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this alias?"} %>
+ <% end %>
+
+ <% if CurrentUser.is_admin? && tag_alias.is_pending? %>
+ | <%= link_to "Approve", approve_tag_alias_path(tag_alias), :remote => true, :method => :post %>
+ <% end %>
+
+ <% if CurrentUser.is_janitor? %>
+ | <%= link_to "Fix", tag_alias_correction_path(:tag_alias_id => tag_alias.id) %>
+ <% end %>
+ |
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/tag_aliases/index.html.erb b/app/views/tag_aliases/index.html.erb
index 549c55a1a..da6341b75 100644
--- a/app/views/tag_aliases/index.html.erb
+++ b/app/views/tag_aliases/index.html.erb
@@ -7,58 +7,13 @@
<% end %>
-
-
-
- | From |
- To |
- Reference |
- Status |
- |
-
-
-
- <% @tag_aliases.each do |tag_alias| %>
-
- | <%= link_to tag_alias.antecedent_name, posts_path(:tags => tag_alias.antecedent_name) %> <%= tag_alias.antecedent_tag.post_count rescue 0 %> |
- <%= link_to tag_alias.consequent_name, posts_path(:tags => tag_alias.consequent_name) %> <%= tag_alias.consequent_tag.post_count rescue 0 %> |
-
- <% if tag_alias.forum_topic_id %>
- <%= link_to tag_alias.forum_topic_id, forum_topic_path(tag_alias.forum_topic_id) %>
- <% end %>
- |
-
- <%= tag_alias.status %>
- |
-
- <%= link_to "Show", tag_alias_path(tag_alias) %>
+ <%= render "listing", :tag_aliases => @tag_aliases %>
- <% if tag_alias.editable_by?(CurrentUser.user) %>
- | <%= link_to "Edit", edit_tag_alias_path(tag_alias) %>
- <% end %>
-
- <% if tag_alias.is_pending? && tag_alias.editable_by?(CurrentUser.user) %>
- | <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this alias?"} %>
- <% end %>
-
- <% if CurrentUser.is_admin? && tag_alias.is_pending? %>
- | <%= link_to "Approve", approve_tag_alias_path(tag_alias), :remote => true, :method => :post %>
- <% end %>
-
- <% if CurrentUser.is_janitor? %>
- | <%= link_to "Fix", tag_alias_correction_path(:tag_alias_id => tag_alias.id) %>
- <% end %>
- |
-
- <% end %>
-
-
-
- <%= numbered_paginator(@tag_aliases) %>
+ <%= numbered_paginator(@tag_aliases) if @tag_aliases.respond_to?(:current_page) %>
-<%= render "secondary_links" %>
+<%= render "tag_aliases/secondary_links" %>
<% content_for(:page_title) do %>
Tag Aliases - <%= Danbooru.config.app_name %>
diff --git a/app/views/tag_implications/_listing.html.erb b/app/views/tag_implications/_listing.html.erb
new file mode 100644
index 000000000..8f0a194c2
--- /dev/null
+++ b/app/views/tag_implications/_listing.html.erb
@@ -0,0 +1,40 @@
+
+
+
+ | From |
+ To |
+ Reference |
+ Status |
+ |
+
+
+
+ <% tag_implications.each do |tag_implication| %>
+
+ | <%= link_to tag_implication.antecedent_name, posts_path(:tags => tag_implication.antecedent_name) %> <%= tag_implication.antecedent_tag.post_count rescue 0 %> |
+ <%= link_to tag_implication.consequent_name, posts_path(:tags => tag_implication.consequent_name) %> <%= tag_implication.consequent_tag.post_count rescue 0 %> |
+
+ <% if tag_implication.forum_topic_id %>
+ <%= link_to tag_implication.forum_topic_id, forum_topic_path(tag_implication.forum_topic_id) %>
+ <% end %>
+ |
+ <%= tag_implication.status %> |
+
+ <%= link_to "Show", tag_implication_path(tag_implication) %>
+
+ <% if tag_implication.is_pending? && tag_implication.editable_by?(CurrentUser.user) %>
+ | <%= link_to "Edit", edit_tag_implication_path(tag_implication) %>
+ <% end %>
+
+ <% if tag_implication.deletable_by?(CurrentUser.user) %>
+ | <%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this implication?"} %>
+ <% end %>
+
+ <% if CurrentUser.user.is_admin? && tag_implication.is_pending? %>
+ | <%= link_to "Approve", approve_tag_implication_path(tag_implication), :remote => true, :method => :post %>
+ <% end %>
+ |
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/tag_implications/index.html.erb b/app/views/tag_implications/index.html.erb
index a1b5fde24..ab0e1d0fe 100644
--- a/app/views/tag_implications/index.html.erb
+++ b/app/views/tag_implications/index.html.erb
@@ -7,46 +7,7 @@
<% end %>
-
-
-
- | From |
- To |
- Reference |
- Status |
- |
-
-
-
- <% @tag_implications.each do |tag_implication| %>
-
- | <%= link_to tag_implication.antecedent_name, posts_path(:tags => tag_implication.antecedent_name) %> <%= tag_implication.antecedent_tag.post_count rescue 0 %> |
- <%= link_to tag_implication.consequent_name, posts_path(:tags => tag_implication.consequent_name) %> <%= tag_implication.consequent_tag.post_count rescue 0 %> |
-
- <% if tag_implication.forum_topic_id %>
- <%= link_to tag_implication.forum_topic_id, forum_topic_path(tag_implication.forum_topic_id) %>
- <% end %>
- |
- <%= tag_implication.status %> |
-
- <%= link_to "Show", tag_implication_path(tag_implication) %>
-
- <% if tag_implication.is_pending? && tag_implication.editable_by?(CurrentUser.user) %>
- | <%= link_to "Edit", edit_tag_implication_path(tag_implication) %>
- <% end %>
-
- <% if tag_implication.deletable_by?(CurrentUser.user) %>
- | <%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :data => {:confirm => "Are you sure you want to delete this implication?"} %>
- <% end %>
-
- <% if CurrentUser.user.is_admin? && tag_implication.is_pending? %>
- | <%= link_to "Approve", approve_tag_implication_path(tag_implication), :remote => true, :method => :post %>
- <% end %>
- |
-
- <% end %>
-
-
+ <%= render "listing", :tag_implications => @tag_implications %>
<%= numbered_paginator(@tag_implications) %>
diff --git a/config/routes.rb b/config/routes.rb
index fc44b092f..a5378c559 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,6 +2,7 @@ Rails.application.routes.draw do
namespace :admin do
resources :users, :only => [:edit, :update]
resource :alias_and_implication_import, :only => [:new, :create]
+ resource :dashboard, :only => [:show]
end
namespace :mobile do
resources :posts, :only => [:index, :show]