fixes #3007: Eliminate Janitor role

This commit is contained in:
r888888888
2017-05-01 14:38:16 -07:00
parent 99ed0cc437
commit 48e9856f37
22 changed files with 17 additions and 144 deletions

View File

@@ -6,10 +6,6 @@ a.user-moderator.with-style {
color: orange;
}
a.user-janitor.with-style {
color: green;
}
a.user-contributor.with-style {
color: purple;
}

View File

@@ -5,7 +5,6 @@ module Admin::UsersHelper
["Gold", User::Levels::GOLD],
["Platinum", User::Levels::PLATINUM],
["Builder", User::Levels::BUILDER],
["Janitor", User::Levels::JANITOR],
["Moderator", User::Levels::MODERATOR],
["Admin", User::Levels::ADMIN]
]

View File

@@ -6,7 +6,6 @@ module Moderator
["Member", 20],
["Gold", 30],
["Platinum", 31],
["Janitor", 35],
["Moderator", 40],
["Admin", 50]
]

View File

@@ -257,7 +257,7 @@ class AnonymousUser
false
end
%w(member banned gold builder platinum janitor moderator admin).each do |name|
%w(member banned gold builder platinum moderator admin).each do |name|
define_method("is_#{name}?") do
false
end

View File

@@ -17,8 +17,8 @@ class Artist < ActiveRecord::Base
has_one :wiki_page, :foreign_key => "title", :primary_key => "name"
has_one :tag_alias, :foreign_key => "antecedent_name", :primary_key => "name"
has_one :tag, :foreign_key => "name", :primary_key => "name"
attr_accessible :body, :notes, :name, :url_string, :other_names, :other_names_comma, :group_name, :notes, :as => [:member, :gold, :builder, :platinum, :janitor, :moderator, :default, :admin]
attr_accessible :is_active, :as => [:builder, :janitor, :moderator, :default, :admin]
attr_accessible :body, :notes, :name, :url_string, :other_names, :other_names_comma, :group_name, :notes, :as => [:member, :gold, :builder, :platinum, :moderator, :default, :admin]
attr_accessible :is_active, :as => [:builder, :moderator, :default, :admin]
attr_accessible :is_banned, :as => :admin
scope :active, lambda { where(is_active: true) }

View File

@@ -18,7 +18,7 @@ class Comment < ActiveRecord::Base
after_update(:if => lambda {|rec| rec.is_deleted? && rec.is_deleted_changed? && CurrentUser.id != rec.creator_id}) do |rec|
ModAction.log("comment ##{rec.id} deleted by #{CurrentUser.name}")
end
attr_accessible :body, :post_id, :do_not_bump_post, :is_deleted, :as => [:member, :gold, :platinum, :builder, :janitor, :moderator, :admin]
attr_accessible :body, :post_id, :do_not_bump_post, :is_deleted, :as => [:member, :gold, :platinum, :builder, :moderator, :admin]
attr_accessible :is_sticky, :as => [:moderator, :admin]
mentionable(
:message_field => :body,

View File

@@ -1,6 +1,6 @@
class DmailFilter < ActiveRecord::Base
belongs_to :user
attr_accessible :words, :as => [:moderator, :janitor, :gold, :platinum, :member, :anonymous, :default, :builder, :admin]
attr_accessible :words, :as => [:moderator, :gold, :platinum, :member, :anonymous, :default, :builder, :admin]
validates_presence_of :user
before_validation :initialize_user

View File

@@ -11,7 +11,7 @@ class FavoriteGroup < ActiveRecord::Base
validate :creator_can_create_favorite_groups, :on => :create
validate :validate_number_of_posts
before_save :update_post_count
attr_accessible :name, :post_ids, :post_id_array, :as => [:member, :gold, :platinum, :builder, :janitor, :moderator, :admin, :default]
attr_accessible :name, :post_ids, :post_id_array, :as => [:member, :gold, :platinum, :builder, :moderator, :admin, :default]
module SearchMethods
def for_creator(user_id)

View File

@@ -1,7 +1,7 @@
class ForumPost < ActiveRecord::Base
include Mentionable
attr_accessible :body, :topic_id, :as => [:member, :builder, :janitor, :gold, :platinum, :admin, :moderator, :default]
attr_accessible :body, :topic_id, :as => [:member, :builder, :gold, :platinum, :admin, :moderator, :default]
attr_accessible :is_locked, :is_sticky, :is_deleted, :as => [:admin, :moderator]
attr_readonly :topic_id
belongs_to :creator, :class_name => "User"

View File

@@ -11,7 +11,7 @@ class ForumTopic < ActiveRecord::Base
Admin: User::Levels::ADMIN,
}
attr_accessible :title, :original_post_attributes, :category_id, :as => [:member, :builder, :gold, :platinum, :janitor, :moderator, :admin, :default]
attr_accessible :title, :original_post_attributes, :category_id, :as => [:member, :builder, :gold, :platinum, :moderator, :admin, :default]
attr_accessible :is_sticky, :is_locked, :is_deleted, :min_level, :as => [:admin, :moderator]
belongs_to :creator, :class_name => "User"
belongs_to :updater, :class_name => "User"

View File

@@ -20,7 +20,7 @@ class Pool < ActiveRecord::Base
after_save :create_version
after_create :synchronize!
before_destroy :create_mod_action_for_destroy
attr_accessible :name, :description, :post_ids, :post_id_array, :post_count, :is_active, :category, :as => [:member, :gold, :platinum, :janitor, :moderator, :admin, :default]
attr_accessible :name, :description, :post_ids, :post_id_array, :post_count, :is_active, :category, :as => [:member, :gold, :platinum, :moderator, :admin, :default]
attr_accessible :is_deleted, :as => [:moderator, :admin]
module SearchMethods

View File

@@ -54,8 +54,8 @@ class Post < ActiveRecord::Base
has_many :versions, lambda {order("post_versions.updated_at ASC")}, :class_name => "PostArchive", :dependent => :destroy
end
attr_accessible :source, :rating, :tag_string, :old_tag_string, :old_parent_id, :old_source, :old_rating, :parent_id, :has_embedded_notes, :as => [:member, :builder, :gold, :platinum, :janitor, :moderator, :admin, :default]
attr_accessible :is_rating_locked, :is_note_locked, :as => [:builder, :janitor, :moderator, :admin]
attr_accessible :source, :rating, :tag_string, :old_tag_string, :old_parent_id, :old_source, :old_rating, :parent_id, :has_embedded_notes, :as => [:member, :builder, :gold, :platinum, :moderator, :admin, :default]
attr_accessible :is_rating_locked, :is_note_locked, :as => [:builder, :moderator, :admin]
attr_accessible :is_status_locked, :as => [:admin]
attr_accessor :old_tag_string, :old_parent_id, :old_source, :old_rating, :has_constraints, :disable_versioning, :view_count

View File

@@ -2,7 +2,7 @@ class Tag < ActiveRecord::Base
COSINE_SIMILARITY_RELATED_TAG_THRESHOLD = 1000
METATAGS = "-user|user|-approver|approver|commenter|comm|noter|noteupdater|artcomm|-pool|pool|ordpool|-favgroup|favgroup|-fav|fav|ordfav|sub|md5|-rating|rating|-locked|locked|width|height|mpixels|ratio|score|favcount|filesize|source|-source|id|-id|date|age|order|limit|-status|status|tagcount|gentags|arttags|chartags|copytags|parent|-parent|child|pixiv_id|pixiv|search|upvote|downvote|filetype|-filetype"
SUBQUERY_METATAGS = "commenter|comm|noter|noteupdater|artcomm"
attr_accessible :category, :as => [:moderator, :janitor, :gold, :platinum, :member, :anonymous, :default, :builder, :admin]
attr_accessible :category, :as => [:moderator, :gold, :platinum, :member, :anonymous, :default, :builder, :admin]
attr_accessible :is_locked, :as => [:moderator, :admin]
has_one :wiki_page, :foreign_key => "title", :primary_key => "name"
has_one :antecedent_alias, lambda {active}, :class_name => "TagAlias", :foreign_key => "antecedent_name", :primary_key => "name"

View File

@@ -11,7 +11,6 @@ class User < ActiveRecord::Base
GOLD = 30
PLATINUM = 31
BUILDER = 32
JANITOR = 35
MODERATOR = 40
ADMIN = 50
end
@@ -52,7 +51,7 @@ class User < ActiveRecord::Base
has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs"
attr_accessor :password, :old_password
attr_accessible :dmail_filter_attributes, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :disable_categorized_saved_searches, :disable_tagged_filenames, :enable_recent_searches, :as => [:moderator, :janitor, :gold, :platinum, :member, :anonymous, :default, :builder, :admin]
attr_accessible :dmail_filter_attributes, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :disable_categorized_saved_searches, :disable_tagged_filenames, :enable_recent_searches, :as => [:moderator, :gold, :platinum, :member, :anonymous, :default, :builder, :admin]
attr_accessible :level, :as => :admin
validates :name, user_name: true, on: :create
@@ -313,7 +312,6 @@ class User < ActiveRecord::Base
"Gold" => Levels::GOLD,
"Platinum" => Levels::PLATINUM,
"Builder" => Levels::BUILDER,
"Janitor" => Levels::JANITOR,
"Moderator" => Levels::MODERATOR,
"Admin" => Levels::ADMIN
}
@@ -336,9 +334,6 @@ class User < ActiveRecord::Base
when Levels::PLATINUM
"Platinum"
when Levels::JANITOR
"Janitor"
when Levels::MODERATOR
"Moderator"
@@ -408,10 +403,6 @@ class User < ActiveRecord::Base
level >= Levels::PLATINUM
end
def is_janitor?
level >= Levels::JANITOR
end
def is_moderator?
level >= Levels::MODERATOR
end

View File

@@ -7,7 +7,7 @@
<% else %>
<%= render "listing", :post_versions => @post_versions %>
<% if params[:lr] && CurrentUser.is_janitor? %>
<% if params[:lr] && CurrentUser.is_moderator? %>
<p><%= link_to "Revert this user's changes", new_user_revert_path(:user_id => params[:lr]) %></p>
<% end %>

View File

@@ -1,35 +0,0 @@
<!doctype html>
<html>
<body>
<h1>Moderator Report For <%= Date.today %></h1>
<div style="margin-bottom: 2em;">
<table width="100%">
<thead>
<tr>
<th width="15%" style="text-align: left;">Name</th>
<th width="10%" style="text-align: left;">Level</th>
<th width="10%" style="text-align: right;" title="Number of posts approved in past day">Appr 1</th>
<th width="10%" style="text-align: right;" title="Number of posts approved in past seven days">Appr 7</th>
<th width="10%" style="text-align: right;" title="Number of posts approved in past fourteen days">Appr 14</th>
<th width="10%" style="text-align: right;" title="Number of comments posted in past seven days">Comm</th>
<th width="35%" style="text-align: right;" title="Number of forum posts posted in past seven days">Forum</th>
</tr>
</thead>
<tbody>
<% User.find(:all, :conditions => ["level >= ?", CONFIG["user_levels"]["Test Janitor"]], :order => "level, name").each do |user| %>
<tr>
<td><%= link_to user.name, user_path(user, :host => Danbooru.config.hostname, :only_path => false) %></td>
<td><%= user.pretty_level %></td>
<td style="text-align: right;"><%= Post.count(:conditions => ["created_at >= ? AND approver_id = ?", 1.days.ago, user.id]) %>/<%= Post.count(:conditions => ["created_at >= ? AND (approver_id IS NOT NULL OR status = 'pending')", 1.days.ago]) %></td>
<td style="text-align: right;"><%= Post.count(:conditions => ["created_at >= ? AND approver_id = ?", 7.days.ago, user.id]) %>/<%= Post.count(:conditions => ["created_at >= ? AND (approver_id IS NOT NULL OR status = 'pending')", 7.days.ago]) %></td>
<td style="text-align: right;"><%= Post.count(:conditions => ["created_at >= ? AND approver_id = ?", 14.days.ago, user.id]) %>/<%= Post.count(:conditions => ["created_at >= ? AND (approver_id IS NOT NULL OR status = 'pending')", 14.days.ago]) %></td>
<td style="text-align: right;"><%= Comment.count(:conditions => ["created_at >= ? AND user_id = ?", 7.days.ago, user.id]) %></td>
<td style="text-align: right;"><%= ForumPost.count(:conditions => ["created_at >= ? AND creator_id = ?", 7.days.ago, user.id]) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</body>
</html>

View File

@@ -6,7 +6,7 @@
<ul>
<% @super_voters.each do |super_voter| %>
<li><%= link_to_if CurrentUser.user.is_janitor?, super_voter.user.name, posts_path(tags: "upvote:#{super_voter.user.name}") %></li>
<li><%= link_to_if CurrentUser.user.is_moderator?, super_voter.user.name, posts_path(tags: "upvote:#{super_voter.user.name}") %></li>
<% end %>
</ul>
</div>