diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index d6b120413..fd430587e 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,7 +1,7 @@ require_relative '../../logical/danbooru/paginator/elasticsearch_extensions' module Admin class UsersController < ApplicationController - before_action :moderator_only + before_action :admin_only respond_to :html, :json def alt_list diff --git a/app/controllers/artist_versions_controller.rb b/app/controllers/artist_versions_controller.rb index 75c361a6a..9715449e4 100644 --- a/app/controllers/artist_versions_controller.rb +++ b/app/controllers/artist_versions_controller.rb @@ -11,7 +11,7 @@ class ArtistVersionsController < ApplicationController def search_params permitted_params = %i[name updater_name updater_id artist_id is_active order] - permitted_params += %i[ip_addr] if CurrentUser.is_moderator? + permitted_params += %i[ip_addr] if CurrentUser.is_admin? permit_search_params permitted_params end end diff --git a/app/controllers/blips_controller.rb b/app/controllers/blips_controller.rb index 27438a822..6c57ee469 100644 --- a/app/controllers/blips_controller.rb +++ b/app/controllers/blips_controller.rb @@ -2,7 +2,8 @@ class BlipsController < ApplicationController class BlipTooOld < Exception ; end respond_to :html, :json before_action :member_only, only: [:create, :new, :update, :edit, :hide] - before_action :moderator_only, only: [:unhide, :destroy, :warning] + before_action :moderator_only, only: [:unhide, :warning] + before_action :admin_only, only: [:destroy] rescue_from BlipTooOld, with: :blip_too_old @@ -99,7 +100,7 @@ class BlipsController < ApplicationController def search_params permitted_params = %i[body_matches response_to creator_name creator_id order] - permitted_params += %i[ip_addr] if CurrentUser.is_moderator? + permitted_params += %i[ip_addr] if CurrentUser.is_admin? permit_search_params permitted_params end diff --git a/app/controllers/bulk_update_requests_controller.rb b/app/controllers/bulk_update_requests_controller.rb index 88e0ee72f..8aafa47ce 100644 --- a/app/controllers/bulk_update_requests_controller.rb +++ b/app/controllers/bulk_update_requests_controller.rb @@ -67,8 +67,7 @@ class BulkUpdateRequestsController < ApplicationController def bur_params(context) permitted_params = %i[script] permitted_params += %i[title reason forum_topic_id] if context == :create - permitted_params += %i[skip_forum] if CurrentUser.is_moderator? - permitted_params += %i[forum_topic_id forum_post_id] if context == :update && CurrentUser.is_admin? + permitted_params += %i[forum_topic_id forum_post_id skip_forum] if context == :update && CurrentUser.is_admin? params.require(:bulk_update_request).permit(permitted_params) end diff --git a/app/controllers/comment_votes_controller.rb b/app/controllers/comment_votes_controller.rb index 42f86b7e2..fc9dbd0b7 100644 --- a/app/controllers/comment_votes_controller.rb +++ b/app/controllers/comment_votes_controller.rb @@ -2,7 +2,8 @@ class CommentVotesController < ApplicationController respond_to :json respond_to :html, only: [:index] before_action :voter_only - before_action :admin_only, only: [:index, :lock, :delete] + before_action :moderator_only, only: [:index, :lock] + before_action :admin_only, only: [:delete] skip_before_action :api_check def create diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index ce72a9755..569c8c625 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,7 +1,8 @@ class CommentsController < ApplicationController respond_to :html, :json before_action :member_only, :except => [:index, :search, :show] - before_action :moderator_only, only: [:unhide, :destroy, :warning] + before_action :moderator_only, only: [:unhide, :warning] + before_action :admin_only, only: [:destroy] skip_before_action :api_check def index @@ -126,7 +127,8 @@ private def search_params permitted_params = %i[body_matches post_id post_tags_match creator_name creator_id poster_id is_sticky do_not_bump_post order] - permitted_params += %i[is_hidden ip_addr] if CurrentUser.is_moderator? + permitted_params += %i[is_hidden] if CurrentUser.is_moderator? + permitted_params += %i[ip_addr] if CurrentUser.is_admin? permit_search_params permitted_params end diff --git a/app/controllers/forum_posts_controller.rb b/app/controllers/forum_posts_controller.rb index a5b1e817b..45ce2162c 100644 --- a/app/controllers/forum_posts_controller.rb +++ b/app/controllers/forum_posts_controller.rb @@ -1,7 +1,8 @@ class ForumPostsController < ApplicationController respond_to :html, :json before_action :member_only, :except => [:index, :show, :search] - before_action :moderator_only, only: [:destroy, :unhide, :warning] + before_action :moderator_only, only: [:unhide, :warning] + before_action :admin_only, only: [:destroy] before_action :load_post, :only => [:edit, :show, :update, :destroy, :hide, :unhide, :warning] before_action :check_min_level, :only => [:edit, :show, :update, :destroy, :hide, :unhide] skip_before_action :api_check diff --git a/app/controllers/forum_topics_controller.rb b/app/controllers/forum_topics_controller.rb index 19f5dd69d..e8f3b995f 100644 --- a/app/controllers/forum_topics_controller.rb +++ b/app/controllers/forum_topics_controller.rb @@ -1,7 +1,8 @@ class ForumTopicsController < ApplicationController respond_to :html, :json before_action :member_only, :except => [:index, :show] - before_action :moderator_only, :only => [:new_merge, :create_merge, :unhide, :destroy] + before_action :moderator_only, :only => [:unhide] + before_action :admin_only, only: [:destroy, :new_merge, :create_merge] before_action :normalize_search, :only => :index before_action :load_topic, :only => [:edit, :show, :update, :destroy, :hide, :unhide, :new_merge, :create_merge, :subscribe, :unsubscribe] before_action :check_min_level, :only => [:show, :edit, :update, :new_merge, :create_merge, :destroy, :hide, :unhide, :subscribe, :unsubscribe] diff --git a/app/controllers/ip_bans_controller.rb b/app/controllers/ip_bans_controller.rb index 5767c6a76..66e41d75b 100644 --- a/app/controllers/ip_bans_controller.rb +++ b/app/controllers/ip_bans_controller.rb @@ -1,6 +1,6 @@ class IpBansController < ApplicationController respond_to :html, :json - before_action :moderator_only + before_action :admin_only def new @ip_ban = IpBan.new diff --git a/app/controllers/moderator/ip_addrs_controller.rb b/app/controllers/moderator/ip_addrs_controller.rb index 67633e80b..97cb44a66 100644 --- a/app/controllers/moderator/ip_addrs_controller.rb +++ b/app/controllers/moderator/ip_addrs_controller.rb @@ -1,6 +1,6 @@ module Moderator class IpAddrsController < ApplicationController - before_action :moderator_only + before_action :admin_only respond_to :html, :json def index diff --git a/app/controllers/moderator/tags_controller.rb b/app/controllers/moderator/tags_controller.rb index c131a8a91..1492ccaeb 100644 --- a/app/controllers/moderator/tags_controller.rb +++ b/app/controllers/moderator/tags_controller.rb @@ -1,6 +1,6 @@ module Moderator class TagsController < ApplicationController - before_action :moderator_only + before_action :admin_only def edit end diff --git a/app/controllers/note_versions_controller.rb b/app/controllers/note_versions_controller.rb index fd4f40eba..7d065e242 100644 --- a/app/controllers/note_versions_controller.rb +++ b/app/controllers/note_versions_controller.rb @@ -12,7 +12,7 @@ class NoteVersionsController < ApplicationController def search_params permitted_params = %i[updater_id post_id note_id is_active body_matches] - permitted_params += %i[ip_addr] if CurrentUser.is_moderator? + permitted_params += %i[ip_addr] if CurrentUser.is_admin? permit_search_params permitted_params end end diff --git a/app/controllers/pool_versions_controller.rb b/app/controllers/pool_versions_controller.rb index 7800e7ed3..df932e30b 100644 --- a/app/controllers/pool_versions_controller.rb +++ b/app/controllers/pool_versions_controller.rb @@ -25,7 +25,7 @@ class PoolVersionsController < ApplicationController def search_params permitted_params = %i[updater_id updater_name pool_id] - permitted_params += %i[ip_addr] if CurrentUser.is_moderator? + permitted_params += %i[ip_addr] if CurrentUser.is_admin? permit_search_params permitted_params end end diff --git a/app/controllers/post_favorites_controller.rb b/app/controllers/post_favorites_controller.rb index de88e4164..dbf01b0bd 100644 --- a/app/controllers/post_favorites_controller.rb +++ b/app/controllers/post_favorites_controller.rb @@ -5,7 +5,7 @@ class PostFavoritesController < ApplicationController def index @post = Post.find(params[:post_id]) query = User.includes(:user_status).joins(:favorites) - unless CurrentUser.is_admin? + unless CurrentUser.is_moderator? query = query.where("bit_prefs & :value != :value", {value: 2**User::BOOLEAN_ATTRIBUTES.find_index("enable_privacy_mode")}).or(query.where(favorites: {user_id: CurrentUser.id})) end query = query.where(favorites: {post_id: @post.id}) diff --git a/app/controllers/post_flags_controller.rb b/app/controllers/post_flags_controller.rb index 91a14483f..5e4584fd0 100644 --- a/app/controllers/post_flags_controller.rb +++ b/app/controllers/post_flags_controller.rb @@ -51,7 +51,7 @@ class PostFlagsController < ApplicationController def search_params # creator_id and creator_name are special cased in the model search function permitted_params = %i[reason_matches creator_id creator_name post_id post_tags_match is_resolved category] - permitted_params += %i[ip_addr] if CurrentUser.is_moderator? + permitted_params += %i[ip_addr] if CurrentUser.is_admin? permit_search_params permitted_params end diff --git a/app/controllers/post_replacements_controller.rb b/app/controllers/post_replacements_controller.rb index de8241394..3c871d304 100644 --- a/app/controllers/post_replacements_controller.rb +++ b/app/controllers/post_replacements_controller.rb @@ -2,7 +2,7 @@ class PostReplacementsController < ApplicationController respond_to :html, :json before_action :member_only, only: [:create, :new] before_action :janitor_only, only: [:approve, :reject, :promote, :toggle_penalize] - before_action :moderator_only, only: [:destroy] + before_action :admin_only, only: [:destroy] content_security_policy only: [:new] do |p| p.img_src :self, :data, :blob, "*" diff --git a/app/controllers/post_sets_controller.rb b/app/controllers/post_sets_controller.rb index 4d98bc311..0e4e9a97a 100644 --- a/app/controllers/post_sets_controller.rb +++ b/app/controllers/post_sets_controller.rb @@ -4,13 +4,13 @@ class PostSetsController < ApplicationController def index if !params[:post_id].blank? - if CurrentUser.is_admin? + if CurrentUser.is_moderator? @post_sets = PostSet.where_has_post(params[:post_id].to_i).paginate(params[:page], limit: 50) else @post_sets = PostSet.visible(CurrentUser.user).where_has_post(params[:post_id].to_i).paginate(params[:page], limit: 50) end elsif !params[:maintainer_id].blank? - if CurrentUser.is_admin? + if CurrentUser.is_moderator? @post_sets = PostSet.where_has_maintainer(params[:maintainer_id].to_i).paginate(params[:page], limit: 50) else @post_sets = PostSet.visible(CurrentUser.user).where_has_maintainer(CurrentUser.id).paginate(params[:page], limit: 50) @@ -86,7 +86,7 @@ class PostSetsController < ApplicationController def destroy @post_set = PostSet.find(params[:id]) check_settings_edit_access(@post_set) - if CurrentUser.is_admin? + if @post_set.creator != CurrentUser.user ModAction.log(:set_delete, {set_id: @post_set.id, user_id: @post_set.creator_id}) end @post_set.destroy @@ -151,7 +151,7 @@ class PostSetsController < ApplicationController def search_params permitted_params = %i[name shortname creator_id creator_name order] - permitted_params += %i[is_public] if CurrentUser.is_admin? + permitted_params += %i[is_public] if CurrentUser.is_moderator? permit_search_params permitted_params end end diff --git a/app/controllers/post_votes_controller.rb b/app/controllers/post_votes_controller.rb index 8e66ed511..a0067f56c 100644 --- a/app/controllers/post_votes_controller.rb +++ b/app/controllers/post_votes_controller.rb @@ -1,6 +1,7 @@ class PostVotesController < ApplicationController before_action :voter_only - before_action :admin_only, only: [:index, :lock, :delete] + before_action :moderator_only, only: [:index, :lock] + before_action :admin_only, only: [:delete] skip_before_action :api_check def create diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 452784c42..5fc47e761 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -173,7 +173,8 @@ class PostsController < ApplicationController ] permitted_params += %i[is_rating_locked] if CurrentUser.is_privileged? permitted_params += %i[is_note_locked bg_color] if CurrentUser.is_janitor? - permitted_params += %i[is_status_locked is_comment_disabled locked_tags hide_from_anonymous hide_from_search_engines] if CurrentUser.is_admin? + permitted_params += %i[is_status_locked is_comment_disabled locked_tags] if CurrentUser.is_moderator? + permitted_params += %i[hide_from_anonymous hide_from_search_engines] if CurrentUser.is_admin? params.require(:post).permit(permitted_params) end diff --git a/app/controllers/tag_alias_requests_controller.rb b/app/controllers/tag_alias_requests_controller.rb index dda760582..a6848e098 100644 --- a/app/controllers/tag_alias_requests_controller.rb +++ b/app/controllers/tag_alias_requests_controller.rb @@ -21,7 +21,7 @@ private def tar_params permitted = %i{antecedent_name consequent_name reason} - permitted += [:skip_forum] if CurrentUser.is_moderator? + permitted += [:skip_forum] if CurrentUser.is_admin? params.require(:tag_alias_request).permit(permitted) end end diff --git a/app/controllers/tag_aliases_controller.rb b/app/controllers/tag_aliases_controller.rb index 81123296a..e9f2db392 100644 --- a/app/controllers/tag_aliases_controller.rb +++ b/app/controllers/tag_aliases_controller.rb @@ -1,5 +1,5 @@ class TagAliasesController < ApplicationController - before_action :moderator_only, except: [:index, :show, :destroy] + before_action :admin_only, except: [:index, :show, :destroy] respond_to :html, :json, :js def show diff --git a/app/controllers/tag_implication_requests_controller.rb b/app/controllers/tag_implication_requests_controller.rb index 084618dd0..4f53ef2cd 100644 --- a/app/controllers/tag_implication_requests_controller.rb +++ b/app/controllers/tag_implication_requests_controller.rb @@ -21,7 +21,7 @@ private def tir_params permitted = %i{antecedent_name consequent_name reason} - permitted += [:skip_forum] if CurrentUser.is_moderator? + permitted += [:skip_forum] if CurrentUser.is_admin? params.require(:tag_implication_request).permit(permitted) end end diff --git a/app/controllers/tag_implications_controller.rb b/app/controllers/tag_implications_controller.rb index 72d38b700..8e1904971 100644 --- a/app/controllers/tag_implications_controller.rb +++ b/app/controllers/tag_implications_controller.rb @@ -1,5 +1,5 @@ class TagImplicationsController < ApplicationController - before_action :moderator_only, except: [:index, :show, :destroy] + before_action :admin_only, except: [:index, :show, :destroy] respond_to :html, :json, :js def show diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 81a4e2917..6f81e3792 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -1,7 +1,7 @@ class TicketsController < ApplicationController respond_to :html before_action :member_only, except: [:index] - before_action :admin_only, only: [:update, :edit, :destroy, :claim, :unclaim] + before_action :moderator_only, only: [:update, :edit, :destroy, :claim, :unclaim] def index @tickets = Ticket.search(search_params).paginate(params[:page], limit: params[:limit]) @@ -95,8 +95,8 @@ class TicketsController < ApplicationController def search_params current_search_params = params.fetch(:search, {}) permitted_params = %i[qtype status order] - permitted_params += %i[creator_id] if CurrentUser.is_admin? || (current_search_params[:creator_id].present? && current_search_params[:creator_id].to_i == CurrentUser.id) - permitted_params += %i[creator_name accused_name accused_id claimant_id reason] if CurrentUser.is_admin? + permitted_params += %i[creator_id] if CurrentUser.is_moderator? || (current_search_params[:creator_id].present? && current_search_params[:creator_id].to_i == CurrentUser.id) + permitted_params += %i[creator_name accused_name accused_id claimant_id reason] if CurrentUser.is_moderator? permit_search_params permitted_params end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 891444dff..c96bf21b9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -137,8 +137,7 @@ class UsersController < ApplicationController def search_params permitted_params = %i[name_matches level min_level max_level can_upload_free can_approve_posts order] - permitted_params += [:ip_addr] if CurrentUser.is_moderator? - permitted_params += [:email_matches] if CurrentUser.is_admin? + permitted_params += %i[ip_addr email_matches] if CurrentUser.is_admin? permit_search_params permitted_params end diff --git a/app/controllers/wiki_page_versions_controller.rb b/app/controllers/wiki_page_versions_controller.rb index 6c573c8f9..e4a28acef 100644 --- a/app/controllers/wiki_page_versions_controller.rb +++ b/app/controllers/wiki_page_versions_controller.rb @@ -25,7 +25,7 @@ class WikiPageVersionsController < ApplicationController def search_params permitted_params = %i[updater_id wiki_page_id title body is_locked is_deleted] - permitted_params += %i[ip_addr] if CurrentUser.is_moderator? + permitted_params += %i[ip_addr] if CurrentUser.is_admin? permit_search_params permitted_params end end diff --git a/app/controllers/wiki_pages_controller.rb b/app/controllers/wiki_pages_controller.rb index 3247161f3..f74df68c2 100644 --- a/app/controllers/wiki_pages_controller.rb +++ b/app/controllers/wiki_pages_controller.rb @@ -1,7 +1,7 @@ class WikiPagesController < ApplicationController respond_to :html, :json, :js before_action :member_only, :except => [:index, :search, :show, :show_or_new] - before_action :moderator_only, :only => [:destroy] + before_action :admin_only, :only => [:destroy] before_action :normalize_search_params, :only => [:index] def new diff --git a/app/helpers/bulk_update_requests_helper.rb b/app/helpers/bulk_update_requests_helper.rb index e7f425fb5..2058d07b4 100644 --- a/app/helpers/bulk_update_requests_helper.rb +++ b/app/helpers/bulk_update_requests_helper.rb @@ -1,6 +1,6 @@ module BulkUpdateRequestsHelper def approved?(command, antecedent, consequent) - return false unless CurrentUser.is_moderator? + return false unless CurrentUser.is_admin? case command when :create_alias @@ -25,7 +25,7 @@ module BulkUpdateRequestsHelper end def failed?(command, antecedent, consequent) - return false unless CurrentUser.is_moderator? + return false unless CurrentUser.is_admin? case command when :create_alias @@ -73,7 +73,7 @@ module BulkUpdateRequestsHelper end def script_with_line_breaks(bur, with_decorations:) - hash = Cache.hash "#{CurrentUser.is_moderator? ? "mod" : ""}#{with_decorations ? "color" : ""}#{bur.status}#{bur.script}" + hash = Cache.hash "#{CurrentUser.is_admin? ? "mod" : ""}#{with_decorations ? "color" : ""}#{bur.status}#{bur.script}" Cache.get(hash, 3600) do script_tokenized = AliasAndImplicationImporter.tokenize(bur.script) script_tags = collect_script_tags(script_tokenized) diff --git a/app/helpers/post_flags_helper.rb b/app/helpers/post_flags_helper.rb index 5d1e4ccb5..4f467a4f2 100644 --- a/app/helpers/post_flags_helper.rb +++ b/app/helpers/post_flags_helper.rb @@ -10,7 +10,7 @@ module PostFlagsHelper if CurrentUser.can_view_flagger_on_post?(flag) html << " - #{link_to_user(flag.creator)}" - if CurrentUser.is_moderator? + if CurrentUser.is_admin? html << " (#{link_to_ip(flag.creator_ip_addr)})" end end diff --git a/app/models/dmail.rb b/app/models/dmail.rb index da9aa2b4e..0c57feda5 100644 --- a/app/models/dmail.rb +++ b/app/models/dmail.rb @@ -167,7 +167,7 @@ class Dmail < ApplicationRecord # System user must be able to send dmails at a very high rate, do not rate limit the system user. return true if bypass_limits == true return true if from_id == User.system.id - return true if from.is_admin? + return true if from.is_moderator? allowed = CurrentUser.can_dmail_with_reason minute_allowed = CurrentUser.can_dmail_minute_with_reason if allowed != true || minute_allowed != true @@ -247,7 +247,8 @@ class Dmail < ApplicationRecord end def visible_to?(user) - return true if user.is_admin? && from_id == ::User.system.id - owner_id == user.id || (user.is_admin? && (to.is_admin? || from.is_admin? || Ticket.exists?(qtype: 'dmail', disp_id: id))) + return true if user.is_moderator? && (from_id == User.system.id || Ticket.exists?(qtype: "dmail", disp_id: id)) + return true if user.is_admin? && (to.is_admin? || from.is_admin?) + owner_id == user.id end end diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index 6b7a2c9e6..0972f01ff 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -164,7 +164,7 @@ class ForumPost < ApplicationRecord end def can_delete?(user) - user.is_moderator? + user.is_admin? end def update_topic_updated_at_on_create diff --git a/app/models/forum_topic.rb b/app/models/forum_topic.rb index 1fd8c3053..fdef2dc1b 100644 --- a/app/models/forum_topic.rb +++ b/app/models/forum_topic.rb @@ -151,7 +151,7 @@ class ForumTopic < ApplicationRecord end def can_delete?(user) - user.is_moderator? + user.is_admin? end def create_mod_action_for_delete diff --git a/app/models/post.rb b/app/models/post.rb index f4448bfd3..977232b75 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -814,7 +814,7 @@ class Post < ApplicationRecord self.is_rating_locked = ($1 != "-") if CurrentUser.is_janitor? when /^(-?)locked:status$/i - self.is_status_locked = ($1 != "-") if CurrentUser.is_admin? + self.is_status_locked = ($1 != "-") if CurrentUser.is_moderator? end end diff --git a/app/models/post_flag.rb b/app/models/post_flag.rb index 62b92a711..3bcf17a5b 100644 --- a/app/models/post_flag.rb +++ b/app/models/post_flag.rb @@ -172,7 +172,7 @@ class PostFlag < ApplicationRecord end def validate_post - errors.add(:post, "is locked and cannot be flagged") if post.is_status_locked? && !(creator.is_admin? || force_flag) + errors.add(:post, "is locked and cannot be flagged") if post.is_status_locked? && !(creator.is_moderator? || force_flag) errors.add(:post, "is deleted") if post.is_deleted? end diff --git a/app/models/post_set.rb b/app/models/post_set.rb index aed384a1f..1e6313ad9 100644 --- a/app/models/post_set.rb +++ b/app/models/post_set.rb @@ -48,7 +48,7 @@ class PostSet < ApplicationRecord def self.visible(user = CurrentUser.user) return where('is_public = true') if user.nil? - return all() if user.is_admin? + return all if user.is_moderator? where('is_public = true OR creator_id = ?', user.id) end @@ -145,7 +145,7 @@ class PostSet < ApplicationRecord module AccessMethods def can_view?(user) - is_public || is_owner?(user) || user.is_admin? + is_public || is_owner?(user) || user.is_moderator? end def can_edit_settings?(user) diff --git a/app/models/tag.rb b/app/models/tag.rb index 9fef4e891..5e8f78b29 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1139,11 +1139,10 @@ class Tag < ApplicationRecord end def category_editable_by?(user) - return false if user.nil? or !user.is_member? - return false if is_locked? && !user.is_moderator? - return false if TagCategory.mod_only_mapping[TagCategory.reverse_mapping[category]] && !user.is_moderator? - return true if post_count < Danbooru.config.tag_type_change_cutoff return true if user.is_moderator? + return false if is_locked? + return false if TagCategory.mod_only_mapping[TagCategory.reverse_mapping[category]] + return true if post_count < Danbooru.config.tag_type_change_cutoff false end diff --git a/app/models/tag_relationship.rb b/app/models/tag_relationship.rb index 6a2225bf3..4b8e4134b 100644 --- a/app/models/tag_relationship.rb +++ b/app/models/tag_relationship.rb @@ -73,15 +73,15 @@ class TagRelationship < ApplicationRecord end def approvable_by?(user) - is_pending? && user.is_moderator? + is_pending? && user.is_admin? end def deletable_by?(user) - user.is_moderator? || (is_pending? && creator.id == user.id) + user.is_admin? || (is_pending? && creator.id == user.id) end def editable_by?(user) - is_pending? && user.is_moderator? + is_pending? && user.is_admin? end module SearchMethods diff --git a/app/models/ticket.rb b/app/models/ticket.rb index 4dfd93196..3dd706822 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -81,7 +81,7 @@ class Ticket < ApplicationRecord end def can_see_details?(user) - user.is_admin? || (user.id == creator_id) + user.is_moderator? || (user.id == creator_id) end end @@ -139,7 +139,7 @@ class Ticket < ApplicationRecord end def can_see_details?(user) - user.is_admin? || user.id == creator_id + user.is_moderator? || user.id == creator_id end end end @@ -147,7 +147,7 @@ class Ticket < ApplicationRecord module APIMethods def hidden_attributes hidden = [] - hidden += %i[claimant_id] unless CurrentUser.is_admin? + hidden += %i[claimant_id] unless CurrentUser.is_moderator? hidden += %i[creator_id] unless can_see_reporter?(CurrentUser) hidden += %i[disp_id reason] unless can_see_details?(CurrentUser) super + hidden @@ -243,7 +243,7 @@ class Ticket < ApplicationRecord end def can_see_reporter?(user) - user.is_admin? || (user.id == creator_id) + user.is_moderator? || (user.id == creator_id) end def can_create_for?(user) diff --git a/app/models/user.rb b/app/models/user.rb index c05d241ac..fad2b0ed0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -896,7 +896,7 @@ class User < ApplicationRecord end def hide_favorites? - return false if CurrentUser.is_admin? + return false if CurrentUser.is_moderator? return true if is_blocked? enable_privacy_mode? && CurrentUser.user.id != id end diff --git a/app/views/artist_versions/_standard_listing.html.erb b/app/views/artist_versions/_standard_listing.html.erb index 65f56dbfe..a593d3334 100644 --- a/app/views/artist_versions/_standard_listing.html.erb +++ b/app/views/artist_versions/_standard_listing.html.erb @@ -48,7 +48,7 @@ <%= link_to "ยป", artist_versions_path(search: { updater_name: artist_version.updater_name }) %>

<%= compact_time(artist_version.updated_at) %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> (<%= link_to_ip artist_version.updater_ip_addr %>) <% end %>

diff --git a/app/views/blips/_search.html.erb b/app/views/blips/_search.html.erb index 6d5d2f550..ac08eb73b 100644 --- a/app/views/blips/_search.html.erb +++ b/app/views/blips/_search.html.erb @@ -2,7 +2,7 @@ <%= f.input :creator_name, label: "Blipper", autocomplete: "user" %> <%= f.input :body_matches, label: "Body" %> <%= f.input :response_to, label: "Parent Blip #" %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <%= f.input :ip_addr, label: "Ip Address" %> <% end %> <%= f.input :order, include_blank: false, collection: [%w(Created id_desc), %w(Updated updated_at_desc)] %> diff --git a/app/views/blips/partials/show/_blip.html.erb b/app/views/blips/partials/show/_blip.html.erb index 105f0eb58..a55d6cd20 100644 --- a/app/views/blips/partials/show/_blip.html.erb +++ b/app/views/blips/partials/show/_blip.html.erb @@ -45,7 +45,7 @@
  • <%= link_to "Unhide", unhide_blip_path(blip), data: {confirm: "Are you sure you want to unhide this blip?"}, method: :post %>
  • <% end %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %>
  • <%= link_to "Delete", blip_path(blip), data: {confirm: "Are you sure you want to delete this blip?"}, method: :delete %>
  • <% end %> @@ -60,12 +60,14 @@ <% if CurrentUser.is_moderator? %>
  • |
  • <%= link_to "Show Edits", edit_history_path(id: blip.id, type: 'Blip') %>
  • + <%= render "user_warnable/buttons", model: blip %> + <% end %> + <% if CurrentUser.is_admin? %> +
  • |
  • IP <%= link_to_ip blip.creator_ip_addr %>
  • -
  • |
  • - <%= render "user_warnable/buttons", model: blip %> <% end %> diff --git a/app/views/bulk_update_requests/_form.html.erb b/app/views/bulk_update_requests/_form.html.erb index f5c42b17f..17703ad37 100644 --- a/app/views/bulk_update_requests/_form.html.erb +++ b/app/views/bulk_update_requests/_form.html.erb @@ -26,7 +26,7 @@ <%= f.input :reason, as: :dtext, limit: Danbooru.config.forum_post_max_size %> <% end %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %>
    - diff --git a/app/views/comments/partials/index/_list.html.erb b/app/views/comments/partials/index/_list.html.erb index 19e69bea9..c05a2442f 100644 --- a/app/views/comments/partials/index/_list.html.erb +++ b/app/views/comments/partials/index/_list.html.erb @@ -2,7 +2,7 @@ <% if post.is_comment_disabled %> Comment section has been disabled. <% end %> - <% if !post.is_comment_disabled || CurrentUser.is_admin? %> + <% if !post.is_comment_disabled || CurrentUser.is_moderator? %>
    <% if post.comments.hidden(CurrentUser.user).count > 0 || (params[:controller] == "comments" && post.comments.count > 6) %> diff --git a/app/views/comments/partials/show/_comment.html.erb b/app/views/comments/partials/show/_comment.html.erb index e1e83f494..b7de42849 100644 --- a/app/views/comments/partials/show/_comment.html.erb +++ b/app/views/comments/partials/show/_comment.html.erb @@ -43,12 +43,12 @@
  • <%= tag.a "Unhide", href: '#', class: 'comment-unhide-link' %>
  • <% end %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %>
  • <%= tag.a "Delete", href: '#', class: 'comment-delete-link' %>
  • <% end %>
  • |
  • <%= comment_vote_block(comment, @comment_votes[comment.id]) %> - <% if CurrentUser.is_admin? %> + <% if CurrentUser.is_moderator? %>
  • <%= link_to "(List)", controller: 'comment_votes', search: { comment_id: comment.id } %>
  • <% end %> <% if CurrentUser.is_member? && !comment.is_sticky %> @@ -58,12 +58,14 @@ <% if CurrentUser.is_moderator? %>
  • |
  • <%= link_to "Show Edits", edit_history_path(id: comment.id, type: 'Comment') %>
  • + <%= render "user_warnable/buttons", model: comment %> + <% end %> + <% if CurrentUser.is_admin? %> +
  • |
  • IP <%= link_to_ip comment.creator_ip_addr %>
  • -
  • |
  • - <%= render "user_warnable/buttons", model: comment %> <% end %> <% if comment.editable_by?(CurrentUser.user) %> diff --git a/app/views/dmails/show.html.erb b/app/views/dmails/show.html.erb index f5e424b1e..9d97dc013 100644 --- a/app/views/dmails/show.html.erb +++ b/app/views/dmails/show.html.erb @@ -8,7 +8,7 @@
  • Sender: <%= link_to_user @dmail.from %>
  • Recipient: <%= link_to_user @dmail.to %>
  • Date: <%= compact_time(@dmail.created_at) %>
  • - <% if CurrentUser.user.is_moderator? %> + <% if CurrentUser.is_admin? %>
  • Sender IP: <%= link_to_ip @dmail.creator_ip_addr %>
  • <% end %> diff --git a/app/views/edit_histories/index.html.erb b/app/views/edit_histories/index.html.erb index 3a9e96596..19ad92c0c 100644 --- a/app/views/edit_histories/index.html.erb +++ b/app/views/edit_histories/index.html.erb @@ -8,7 +8,9 @@ Type Date - IP Address + <% if CurrentUser.is_admin? %> + IP Address + <% end %> Editor Body Subject @@ -21,7 +23,9 @@ <%= link_to "Show", action: "show", id: edit.versionable_id, type: edit.versionable_type %> <%= edit.versionable_type %> <%= edit.updated_at.strftime("%b %d, %Y %I:%M %p") %> - <%= link_to_ip edit.ip_addr %> + <% if CurrentUser.is_admin? %> + <%= link_to_ip edit.ip_addr %> + <% end %> <%= link_to_user edit.user %> <%= edit.body[0..30] %> <%= edit.subject&[0..30] %> diff --git a/app/views/edit_histories/show.html.erb b/app/views/edit_histories/show.html.erb index b1f20b94f..32bea49f9 100644 --- a/app/views/edit_histories/show.html.erb +++ b/app/views/edit_histories/show.html.erb @@ -8,7 +8,9 @@
    <%= link_to_user edit.user %>
    "><%= edit.created_at.strftime("%b %d, %Y %I:%M %p") %> -
    <%= link_to_ip edit.ip_addr %>
    + <% if CurrentUser.is_admin? %> +
    <%= link_to_ip edit.ip_addr %>
    + <% end %>
    diff --git a/app/views/forum_posts/_forum_post.html.erb b/app/views/forum_posts/_forum_post.html.erb index fc073b8e3..7af95bacc 100644 --- a/app/views/forum_posts/_forum_post.html.erb +++ b/app/views/forum_posts/_forum_post.html.erb @@ -60,23 +60,23 @@
  • <%= link_to "Edit", edit_forum_post_path(forum_post.id), :id => "edit_forum_post_link_#{forum_post.id}", :class => "edit_forum_post_link" %>
  • <% end %> <% end %> + <% if params[:controller] == "forum_posts" %> +
  • <%= link_to "Parent", forum_topic_path(forum_post.topic, :page => forum_post.forum_topic_page, :anchor => "forum_post_#{forum_post.id}") %>
  • + <% end %> <% if CurrentUser.is_member? %>
  • <%= link_to "Report", new_ticket_path(disp_id: forum_post.id, qtype: 'forum') %>
  • <% end %> <% if CurrentUser.is_moderator? %>
  • |
  • <%= link_to "Show Edits", edit_history_path(id: forum_post.id, type: 'ForumPost') %>
  • + <%= render "user_warnable/buttons", model: forum_post %> + <% end %> + <% if CurrentUser.is_admin? %> +
  • |
  • IP <%= link_to_ip forum_post.creator_ip_addr %>
  • -
  • |
  • - <%= render "user_warnable/buttons", model: forum_post %> - -
  • |
  • - <% end %> - <% if params[:controller] == "forum_posts" %> -
  • <%= link_to "Parent", forum_topic_path(forum_post.topic, :page => forum_post.forum_topic_page, :anchor => "forum_post_#{forum_post.id}") %>
  • <% end %> <% if forum_post.votable? %>
      diff --git a/app/views/maintenance/user/dmail_filters/edit.html.erb b/app/views/maintenance/user/dmail_filters/edit.html.erb index d8e6063aa..1c7b28d6d 100644 --- a/app/views/maintenance/user/dmail_filters/edit.html.erb +++ b/app/views/maintenance/user/dmail_filters/edit.html.erb @@ -9,7 +9,7 @@
    • Sender: <%= link_to_user @dmail.from %>
    • Recipient: <%= link_to_user @dmail.to %>
    • Date: <%= compact_time(@dmail.created_at) %>
    • - <% if CurrentUser.user.is_moderator? %> + <% if CurrentUser.user.is_admin? %>
    • Sender IP: <%= link_to_ip @dmail.creator_ip_addr %>
    • <% end %>
    diff --git a/app/views/news_updates/index.html.erb b/app/views/news_updates/index.html.erb index 36996ea45..4f6ddab58 100644 --- a/app/views/news_updates/index.html.erb +++ b/app/views/news_updates/index.html.erb @@ -8,7 +8,7 @@ Creator Date Message - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <% end %> @@ -19,7 +19,7 @@ <%= link_to_user news_update.creator %> <%= compact_time news_update.updated_at %>
    <%= format_text news_update.message %>
    - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <%= link_to "Edit", edit_news_update_path(news_update) %> | <%= link_to "Delete", news_update_path(news_update), :method => :delete %> <% end %> diff --git a/app/views/note_versions/_revert_listing.html.erb b/app/views/note_versions/_revert_listing.html.erb index 25425ed5b..9a3de5928 100644 --- a/app/views/note_versions/_revert_listing.html.erb +++ b/app/views/note_versions/_revert_listing.html.erb @@ -7,7 +7,7 @@ Note Body Position - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> IP Address <% end %> Edited By @@ -43,7 +43,7 @@ <%= note_version_position_diff(note_version) %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <%= link_to_ip note_version.updater_ip_addr %> diff --git a/app/views/note_versions/_standard_listing.html.erb b/app/views/note_versions/_standard_listing.html.erb index 64399f0cc..4fa488ccc 100644 --- a/app/views/note_versions/_standard_listing.html.erb +++ b/app/views/note_versions/_standard_listing.html.erb @@ -7,7 +7,7 @@ Note Body Position - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> IP Address <% end %> Edited By @@ -36,7 +36,7 @@ <%= note_version_position_diff(note_version) %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <%= link_to_ip note_version.updater_ip_addr %> diff --git a/app/views/pool_versions/_revert_listing.html.erb b/app/views/pool_versions/_revert_listing.html.erb index 0c2a7b95a..a4002a929 100644 --- a/app/views/pool_versions/_revert_listing.html.erb +++ b/app/views/pool_versions/_revert_listing.html.erb @@ -7,7 +7,7 @@ Changes Desc Chg Updater - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> IP Address <% end %> Date @@ -28,7 +28,7 @@ <%= link_to_user pool_version.updater %> <% end %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <%= link_to_ip pool_version.updater_ip_addr %> diff --git a/app/views/pool_versions/_standard_listing.html.erb b/app/views/pool_versions/_standard_listing.html.erb index 8831ccf25..9f768a5f9 100644 --- a/app/views/pool_versions/_standard_listing.html.erb +++ b/app/views/pool_versions/_standard_listing.html.erb @@ -7,7 +7,7 @@ Changes Desc Chg Updater - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> IP Address <% end %> Date @@ -25,7 +25,7 @@ <%= link_to_user pool_version.updater %> <% end %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <%= link_to_ip pool_version.updater_ip_addr %> diff --git a/app/views/post_replacements/index.html.erb b/app/views/post_replacements/index.html.erb index bc2319aea..b796ebcad 100644 --- a/app/views/post_replacements/index.html.erb +++ b/app/views/post_replacements/index.html.erb @@ -118,7 +118,7 @@ <%= link_to "Reset To", "#approve", class: "replacement-approve-action", data: { replacement_id: post_replacement.id, penalize: false} %>
    <% end %> <% end %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <%= link_to "Destroy", post_replacement_path(post_replacement), method: :DELETE, 'data-confirm': 'Are you sure you want to destroy this replacement?' %> <% end %> diff --git a/app/views/post_sets/_search.html.erb b/app/views/post_sets/_search.html.erb index ca97c7cde..475f43e7a 100644 --- a/app/views/post_sets/_search.html.erb +++ b/app/views/post_sets/_search.html.erb @@ -2,7 +2,7 @@ <%= f.input :name, label: "Name" %> <%= f.input :shortname, label: "Short Name" %> <%= f.input :creator_name, label: "Username", autocomplete: "users" %> - <% if CurrentUser.is_admin? %> + <% if CurrentUser.is_moderator? %> <%= f.input :is_public, label: "Public?", collection: [["Yes", true], ["No", false]], include_blank: true %> <% end %> <%= f.input :order, collection: [%w[Name name], ['Short Name', 'shortname'], ['Post Count', 'post_count'], %w[Created created_at], %w[Updated updated_at]], include_blank: false %> diff --git a/app/views/post_versions/_listing.html.erb b/app/views/post_versions/_listing.html.erb index 8be89fdeb..3b7745cab 100644 --- a/app/views/post_versions/_listing.html.erb +++ b/app/views/post_versions/_listing.html.erb @@ -27,7 +27,7 @@ <% if post_version.updater %> <%= link_to_user(post_version.updater) %> <% end %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> (<%= link_to_ip(post_version.updater_ip_addr) %>) <% end %> <%= time_ago_in_words_tagged(post_version.updated_at, compact: true) %> diff --git a/app/views/posts/partials/show/_edit.html.erb b/app/views/posts/partials/show/_edit.html.erb index 17eff08e1..9475f4702 100644 --- a/app/views/posts/partials/show/_edit.html.erb +++ b/app/views/posts/partials/show/_edit.html.erb @@ -26,7 +26,7 @@
    - <%= f.input :locked_tags, label: "Locked Tags", autocomplete: "tag-edit", input_html: { value: (post.locked_tags || ""), spellcheck: false, size: "60x2", disabled: !CurrentUser.is_admin? } %> + <%= f.input :locked_tags, label: "Locked Tags", autocomplete: "tag-edit", input_html: { value: (post.locked_tags || ""), spellcheck: false, size: "60x2", disabled: !CurrentUser.is_moderator? } %>
    <% if post.is_rating_locked? %> @@ -54,7 +54,7 @@ <%= f.input :is_note_locked, label: "Notes" %> <% end %> <%= f.input :is_rating_locked, label: "Rating" %> - <% if CurrentUser.is_admin? %> + <% if CurrentUser.is_moderator? %> <%= f.input :is_status_locked, label: "Status" %> <% end %> diff --git a/app/views/posts/partials/show/_information.html.erb b/app/views/posts/partials/show/_information.html.erb index 03277b786..275e72c49 100644 --- a/app/views/posts/partials/show/_information.html.erb +++ b/app/views/posts/partials/show/_information.html.erb @@ -7,7 +7,7 @@
  • Rating: <%= pretty_html_rating(post) %>
  • Score: <%= post_vote_block(post, post.own_vote) %> - <% if CurrentUser.is_admin? %><%= link_to "(votes)", controller: :post_votes, search: { post_id: post.id} %><% end %> + <% if CurrentUser.is_moderator? %><%= link_to "(votes)", controller: :post_votes, search: { post_id: post.id} %><% end %>
  • Posted: <%= link_to time_ago_in_words_tagged(post.created_at), posts_path(:tags => "date:#{post.created_at.to_date}"), :rel => "nofollow" %> diff --git a/app/views/static/site_map.html.erb b/app/views/static/site_map.html.erb index 85b927261..da63efccd 100644 --- a/app/views/static/site_map.html.erb +++ b/app/views/static/site_map.html.erb @@ -117,8 +117,6 @@
  • <%= link_to("Post Report Reasons", post_report_reasons_path) %>
  • <%= link_to("Alias & Implication Import", new_admin_alias_and_implication_import_path) %>
  • <%= link_to("Danger Zone", admin_danger_zone_index_path) %>
  • - <% end %> - <% if CurrentUser.is_moderator? %>
  • <%= link_to("IP Bans", ip_bans_path) %>
  • <% end %>
  • <%= link_to("Upload Whitelist", upload_whitelists_path) %>
  • diff --git a/app/views/tag_alias_requests/new.html.erb b/app/views/tag_alias_requests/new.html.erb index 03441b98a..aa9c36ea1 100644 --- a/app/views/tag_alias_requests/new.html.erb +++ b/app/views/tag_alias_requests/new.html.erb @@ -11,7 +11,7 @@ <%= f.input :antecedent_name, label: "From", autocomplete: "tag" %> <%= f.input :consequent_name, label: "To", autocomplete: "tag" %> <%= f.input :reason, as: :dtext, limit: Danbooru.config.forum_post_max_size %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <%= f.input :skip_forum, as: :boolean, label: "Skip forum topic creation" %> <% end %> <%= f.button :submit, "Submit" %> diff --git a/app/views/tag_aliases/index.html.erb b/app/views/tag_aliases/index.html.erb index 3b4d0faa5..236fa3426 100644 --- a/app/views/tag_aliases/index.html.erb +++ b/app/views/tag_aliases/index.html.erb @@ -2,7 +2,7 @@
    <%= render "tag_relationships/search", url: tag_aliases_path %> <%= render "tag_relationships/listing", tag_relations: @tag_aliases %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <%= render "tag_relationships/add_form", type: :tag_alias_request, path: tag_alias_request_path %> <% end %> diff --git a/app/views/tag_implication_requests/new.html.erb b/app/views/tag_implication_requests/new.html.erb index edb8d4a2e..584b48526 100644 --- a/app/views/tag_implication_requests/new.html.erb +++ b/app/views/tag_implication_requests/new.html.erb @@ -11,7 +11,7 @@ <%= f.input :antecedent_name, label: "From", autocomplete: "tag" %> <%= f.input :consequent_name, label: "To", autocomplete: "tag" %> <%= f.input :reason, as: :dtext, limit: Danbooru.config.forum_post_max_size %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <%= f.input :skip_forum, as: :boolean, label: "Skip forum topic creation" %> <% end %> <%= f.button :submit, "Submit" %> diff --git a/app/views/tag_implications/index.html.erb b/app/views/tag_implications/index.html.erb index d01134f5a..1187e55e7 100644 --- a/app/views/tag_implications/index.html.erb +++ b/app/views/tag_implications/index.html.erb @@ -2,7 +2,7 @@
    <%= render "tag_relationships/search", url: tag_implications_path %> <%= render "tag_relationships/listing", tag_relations: @tag_implications %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <%= render "tag_relationships/add_form", type: :tag_implication_request, path: tag_implication_request_path %> <% end %> diff --git a/app/views/tickets/_footer.html.erb b/app/views/tickets/_footer.html.erb index c3fc4dfc6..fe80eab73 100644 --- a/app/views/tickets/_footer.html.erb +++ b/app/views/tickets/_footer.html.erb @@ -3,7 +3,7 @@ <% unless current_user.anon? %>
  • <%= link_to "Mine", action: "index", user_id: current_user.id %>
  • <% end %> - <% if current_user.is_admin? %> + <% if current_user.is_moderator? %>
  • <%= link_to "Claimed", action: "index", claim_id: current_user.id %>
  • <% end %>
  • <%= link_to "Help", controller: "help" %>
  • diff --git a/app/views/tickets/_search.html.erb b/app/views/tickets/_search.html.erb index d9e9f7cf1..6bbef8c72 100644 --- a/app/views/tickets/_search.html.erb +++ b/app/views/tickets/_search.html.erb @@ -1,5 +1,5 @@ <%= form_search path: tickets_path do |f| %> - <% if CurrentUser.is_admin? %> + <% if CurrentUser.is_moderator? %> <%= f.input :creator_name, label: "Reporter", autocomplete: "user" %> <%= f.input :creator_id, label: "Reporter ID" %> <%= f.input :accused_name, label: "Accused", autocomplete: "user" %> diff --git a/app/views/tickets/_secondary_links.html.erb b/app/views/tickets/_secondary_links.html.erb index 5b3075de2..bdb3a3aaf 100644 --- a/app/views/tickets/_secondary_links.html.erb +++ b/app/views/tickets/_secondary_links.html.erb @@ -4,7 +4,7 @@ <% unless CurrentUser.is_anonymous? %> <%= subnav_link_to 'Mine', tickets_path(search: {creator_id: CurrentUser.id}) %> <% end %> - <% if CurrentUser.is_admin? %> + <% if CurrentUser.is_moderator? %> <%= subnav_link_to 'Claimed', tickets_path(search: {claimant_id: CurrentUser.id}) %> <% end %> diff --git a/app/views/tickets/index.html.erb b/app/views/tickets/index.html.erb index e69f7c16a..260610f76 100644 --- a/app/views/tickets/index.html.erb +++ b/app/views/tickets/index.html.erb @@ -7,7 +7,7 @@ ID - <% if CurrentUser.is_admin? %> + <% if CurrentUser.is_moderator? %> Reporter Claimed By <% end %> @@ -23,7 +23,7 @@ <% @tickets.each do |ticket| %> <%= link_to ticket.id, ticket_path(ticket) %> - <% if CurrentUser.is_admin? %> + <% if CurrentUser.is_moderator? %> <%= link_to_user ticket.creator %> <% if ticket.claimant.nil? %> diff --git a/app/views/tickets/show.html.erb b/app/views/tickets/show.html.erb index f450e3f63..8bdbe0e32 100644 --- a/app/views/tickets/show.html.erb +++ b/app/views/tickets/show.html.erb @@ -21,7 +21,7 @@ Updated "><%= time_ago_in_words(@ticket.updated_at) %> ago - <% if CurrentUser.is_admin? %> + <% if CurrentUser.is_moderator? %> Claimed By <% if @ticket.claimant.nil? %> @@ -42,6 +42,9 @@ IP <%= link_to_ip(@ticket.creator_ip_addr) %> + <% end %> + + <% if CurrentUser.is_moderator? %> Open Duplicates
      @@ -77,7 +80,7 @@
    - <% if CurrentUser.is_admin? %> + <% if CurrentUser.is_moderator? %> <%= custom_form_for(@ticket) do |f| %>
    diff --git a/app/views/uploads/new.html.erb b/app/views/uploads/new.html.erb index 97c793f0c..29c01aa27 100644 --- a/app/views/uploads/new.html.erb +++ b/app/views/uploads/new.html.erb @@ -38,7 +38,7 @@ safeSite: <%= CurrentUser.safe_mode?.to_json %>, uploadTags: <%= CurrentUser.presenter.favorite_tags_with_types.to_json.html_safe %>, recentTags: <%= CurrentUser.presenter.recent_tags_with_types.to_json.html_safe %>, - allowLockedTags: <%= CurrentUser.is_admin?.to_json %>, + allowLockedTags: <%= CurrentUser.is_moderator?.to_json %>, allowRatingLock: <%= CurrentUser.is_privileged?.to_json %>, allowUploadAsPending: <%= CurrentUser.can_upload_free?.to_json %>, descrLimit: <%= Danbooru.config.post_descr_max_size %>, diff --git a/app/views/user_votes/_common_index.html.erb b/app/views/user_votes/_common_index.html.erb index 60427d7f5..bdef6c341 100644 --- a/app/views/user_votes/_common_index.html.erb +++ b/app/views/user_votes/_common_index.html.erb @@ -21,11 +21,15 @@ - + <% if CurrentUser.is_admin? %> + + <% end %> - + <% if CurrentUser.is_admin? %> + + <% end %> @@ -35,7 +39,9 @@ - - + <% if CurrentUser.is_admin? %> + + <% end %> <% end %> diff --git a/app/views/users/_secondary_links.html.erb b/app/views/users/_secondary_links.html.erb index dfa1ecc87..ae37483cb 100644 --- a/app/views/users/_secondary_links.html.erb +++ b/app/views/users/_secondary_links.html.erb @@ -19,10 +19,12 @@ <%= subnav_link_to "Report/Commend", new_ticket_path(disp_id: @user.id, qtype: 'user') %> <% end %> - <% if CurrentUser.user.is_moderator? %> + <% if CurrentUser.is_admin? %> <%= subnav_link_to "Reset Password", request_password_reset_admin_user_path(@user) %> <%= subnav_link_to "Edit Blacklist", edit_blacklist_admin_user_path(@user) %> <%= subnav_link_to "Edit User", edit_admin_user_path(@user) %> + <% end %> + <% if CurrentUser.is_moderator? %> <% if @user.is_banned? %> <%= subnav_link_to "Unban", ban_path(@user.recent_ban) %> <% else %> diff --git a/app/views/users/_statistics.html.erb b/app/views/users/_statistics.html.erb index 76f66ae43..16799c3bb 100644 --- a/app/views/users/_statistics.html.erb +++ b/app/views/users/_statistics.html.erb @@ -85,9 +85,6 @@ <% if CurrentUser.is_admin? %> Email<%= user.email %> - <% end %> - - <% if CurrentUser.is_moderator? %> Last IP<%= link_to_ip(user.last_ip_addr) %> <% end %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index c9ccd7e64..6d76b503f 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -10,7 +10,7 @@ - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <% end %> @@ -33,7 +33,7 @@ - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <% end %> diff --git a/app/views/wiki_page_versions/_global_listing.html.erb b/app/views/wiki_page_versions/_global_listing.html.erb index 9d9399958..f0d566c8b 100644 --- a/app/views/wiki_page_versions/_global_listing.html.erb +++ b/app/views/wiki_page_versions/_global_listing.html.erb @@ -4,7 +4,7 @@ - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <% end %> @@ -21,7 +21,7 @@ <% end %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> diff --git a/app/views/wiki_page_versions/_page_listing.html.erb b/app/views/wiki_page_versions/_page_listing.html.erb index 670a2a37d..99cc32d72 100644 --- a/app/views/wiki_page_versions/_page_listing.html.erb +++ b/app/views/wiki_page_versions/_page_listing.html.erb @@ -9,7 +9,7 @@ - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> <% end %> @@ -36,7 +36,7 @@ <% end %> - <% if CurrentUser.is_moderator? %> + <% if CurrentUser.is_admin? %> diff --git a/app/views/wiki_pages/_secondary_links.html.erb b/app/views/wiki_pages/_secondary_links.html.erb index ee0fd6d85..bfe03d4a3 100644 --- a/app/views/wiki_pages/_secondary_links.html.erb +++ b/app/views/wiki_pages/_secondary_links.html.erb @@ -33,7 +33,7 @@ <%= subnav_link_to "Edit", edit_wiki_page_path(@wiki_page), "data-shortcut": "e" %> <% end %> - <% if CurrentUser.is_moderator? && !@wiki_page.is_deleted? %> + <% if CurrentUser.is_admin? && !@wiki_page.is_deleted? %> <%= subnav_link_to "Delete", wiki_page_path(@wiki_page), :method => :delete, :"data-confirm" => "Are you sure you want to delete this wiki page?" %> <% end %> diff --git a/test/functional/admin/users_controller_test.rb b/test/functional/admin/users_controller_test.rb index b166e9538..750392bab 100644 --- a/test/functional/admin/users_controller_test.rb +++ b/test/functional/admin/users_controller_test.rb @@ -3,44 +3,30 @@ require 'test_helper' class Admin::UsersControllerTest < ActionDispatch::IntegrationTest context "Admin::UsersController" do setup do - @mod = create(:moderator_user) @user = create(:user) @admin = create(:admin_user) end context "#edit" do should "render" do - get_auth edit_admin_user_path(@user), @mod + get_auth edit_admin_user_path(@user), @admin assert_response :success end end context "#update" do context "on a basic user" do + should "fail for moderators" do + put_auth admin_user_path(@user), create(:moderator_user), params: { user: { level: "30" } } + assert_response :forbidden + end + should "succeed" do - put_auth admin_user_path(@user), @mod, params: { user: { level: "30" } } + put_auth admin_user_path(@user), @admin, params: { user: { level: "30" } } assert_redirected_to(user_path(@user)) @user.reload assert_equal(30, @user.level) end - - context "promoted to an admin" do - should "fail" do - put_auth admin_user_path(@user), @mod, params: { user: { level: "50" } } - assert_response(403) - @user.reload - assert_equal(20, @user.level) - end - end - end - - context "on an admin user" do - should "fail" do - put_auth admin_user_path(@admin), @mod, params: {:user => {:level => "30"}} - assert_response(403) - @admin.reload - assert_equal(50, @admin.level) - end end context "on an user with a blank email" do @@ -50,14 +36,14 @@ class Admin::UsersControllerTest < ActionDispatch::IntegrationTest end should "succeed" do - put_auth admin_user_path(@user), @mod, params: { user: { level: "20", email: "" } } + put_auth admin_user_path(@user), @admin, params: { user: { level: "20", email: "" } } assert_redirected_to(user_path(@user)) @user.reload assert_equal(20, @user.level) end should "prevent invalid emails" do - put_auth admin_user_path(@user), @mod, params: { user: { level: "10", email: "invalid" } } + put_auth admin_user_path(@user), @admin, params: { user: { level: "10", email: "invalid" } } @user.reload assert_equal("", @user.email) end diff --git a/test/functional/comments_controller_test.rb b/test/functional/comments_controller_test.rb index 76e052c25..5724dbdcc 100644 --- a/test/functional/comments_controller_test.rb +++ b/test/functional/comments_controller_test.rb @@ -70,6 +70,7 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest context "when stickying a comment" do should "succeed if updater is a moderator" do + @comment = create(:comment, creator: @mod) put_auth comment_path(@comment.id), @mod, params: {comment: {is_sticky: true}} assert_equal(true, @comment.reload.is_sticky) assert_redirected_to @comment.post @@ -154,7 +155,7 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest context "destroy action" do should "destroy the comment" do - delete_auth comment_path(@comment.id), @mod + delete_auth comment_path(@comment.id), create(:admin_user) assert_equal(0, Comment.where(id: @comment.id).count) end end diff --git a/test/functional/forum_posts_controller_test.rb b/test/functional/forum_posts_controller_test.rb index 1a0125160..e4d49b9f4 100644 --- a/test/functional/forum_posts_controller_test.rb +++ b/test/functional/forum_posts_controller_test.rb @@ -115,8 +115,9 @@ class ForumPostsControllerTest < ActionDispatch::IntegrationTest context "destroy action" do should "destroy the posts" do - delete_auth forum_post_path(@forum_post), @mod - get_auth forum_post_path(@forum_post), @mod + @admin = create(:admin_user) + delete_auth forum_post_path(@forum_post), @admin + get_auth forum_post_path(@forum_post), @admin assert_response :not_found end end diff --git a/test/functional/forum_topics_controller_test.rb b/test/functional/forum_topics_controller_test.rb index 2b4ffe9f2..7e8a01c6e 100644 --- a/test/functional/forum_topics_controller_test.rb +++ b/test/functional/forum_topics_controller_test.rb @@ -112,7 +112,7 @@ class ForumTopicsControllerTest < ActionDispatch::IntegrationTest end should "destroy the topic and any associated posts" do - delete_auth forum_topic_path(@forum_topic), @mod + delete_auth forum_topic_path(@forum_topic), create(:admin_user) assert_response :no_content end end diff --git a/test/functional/moderator/ip_addrs_controller_test.rb b/test/functional/moderator/ip_addrs_controller_test.rb index 682c45321..fda2eb871 100644 --- a/test/functional/moderator/ip_addrs_controller_test.rb +++ b/test/functional/moderator/ip_addrs_controller_test.rb @@ -4,13 +4,18 @@ module Moderator class IpAddrsControllerTest < ActionDispatch::IntegrationTest context "The ip addrs controller" do setup do - @user = create(:moderator_user, created_at: 1.month.ago) + @user = create(:admin_user, created_at: 1.month.ago) as(@user) do create(:comment) end end + should "fail for moderators" do + get_auth moderator_ip_addrs_path, create(:moderator_user), params: { search: { ip_addr: "127.0.0.1" } } + assert_response :forbidden + end + should "find by ip addr" do get_auth moderator_ip_addrs_path, @user, params: { search: { ip_addr: "127.0.0.1" } } assert_response :success diff --git a/test/functional/moderator/tags_controller_test.rb b/test/functional/moderator/tags_controller_test.rb index 3569a32aa..6ea03d780 100644 --- a/test/functional/moderator/tags_controller_test.rb +++ b/test/functional/moderator/tags_controller_test.rb @@ -4,7 +4,7 @@ module Moderator class TagsControllerTest < ActionDispatch::IntegrationTest context "The tags controller" do setup do - @user = create(:moderator_user) + @user = create(:admin_user) as(@user) do @post = create(:post) end diff --git a/test/functional/wiki_pages_controller_test.rb b/test/functional/wiki_pages_controller_test.rb index fc38c2d25..0c6885b24 100644 --- a/test/functional/wiki_pages_controller_test.rb +++ b/test/functional/wiki_pages_controller_test.rb @@ -146,11 +146,10 @@ class WikiPagesControllerTest < ActionDispatch::IntegrationTest as(@user) do @wiki_page = create(:wiki_page) end - @mod = create(:mod_user) end should "destroy a wiki_page" do - delete_auth wiki_page_path(@wiki_page), @mod + delete_auth wiki_page_path(@wiki_page), create(:admin_user) assert_not(WikiPage.exists?(@wiki_page.id)) end end
    <%= type.model_type.capitalize %> <%= type.model_type.capitalize %> Creator VoterEmailEmailSigned Up Vote CreatedIPIP
    <%= link_to vote.send("#{type.model_type}_id"), vote.send(type.model_type) %> <%= mod_link_to_user vote.send(type.model_type).send(type.model_creator_column), :negative %> <%= mod_link_to_user vote.user, :negative %><%= vote.user.email %> + <% if CurrentUser.is_admin? %> + <%= vote.user.email %> + <% end %> "><%= time_ago_in_words(vote.user.created_at) %> ago <% if vote.is_positive? %>Up @@ -44,7 +50,9 @@ <% end %> "><%= time_ago_in_words(vote.created_at) %> ago <%= link_to_ip vote.user_ip_addr %><%= link_to_ip vote.user_ip_addr %>
    Name Posts DeletedEmail Last IP <%= link_to user.post_upload_count, posts_path(:tags => "user:#{user.name}") %> <%= user.post_deleted_count %><%= user.email %> <%= link_to_ip(user.last_ip_addr) %>
    Title WikiIP AddressLast edited <%= link_to "wiki", wiki_page_path(wiki_page_version.wiki_page_id) %> <%= link_to_ip wiki_page_version.updater_ip_addr %> Title ViewIP AddressLast edited <%= link_to "view version", wiki_page_version_path(wiki_page_version) %> <%= link_to_ip wiki_page_version.updater_ip_addr %>