fixes #2417
This commit is contained in:
@@ -329,7 +329,7 @@ class Artist < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def other_names_match(string)
|
||||
if string =~ /\*/ && CurrentUser.user.is_builder?
|
||||
if string =~ /\*/ && CurrentUser.is_builder?
|
||||
where("other_names ILIKE ? ESCAPE E'\\\\'", string.to_escaped_for_sql_like)
|
||||
else
|
||||
where("other_names_index @@ to_tsquery('danbooru', E?)", Artist.normalize_name(string).to_escaped_for_tsquery)
|
||||
@@ -352,7 +352,7 @@ class Artist < ActiveRecord::Base
|
||||
|
||||
def any_name_matches(name)
|
||||
stripped_name = normalize_name(name).to_escaped_for_sql_like
|
||||
if name =~ /\*/ && CurrentUser.user.is_builder?
|
||||
if name =~ /\*/ && CurrentUser.is_builder?
|
||||
where("(name LIKE ? ESCAPE E'\\\\' OR other_names LIKE ? ESCAPE E'\\\\')", stripped_name, stripped_name)
|
||||
else
|
||||
name_for_tsquery = normalize_name(name).to_escaped_for_tsquery
|
||||
@@ -479,6 +479,6 @@ class Artist < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def visible?
|
||||
!is_banned? || CurrentUser.user.is_janitor?
|
||||
!is_banned? || CurrentUser.is_moderator?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,7 +61,7 @@ class BulkUpdateRequest < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def editable?(user)
|
||||
user_id == user.id || user.is_janitor?
|
||||
user_id == user.id || user.is_builder?
|
||||
end
|
||||
|
||||
def create_forum_topic
|
||||
|
||||
@@ -165,7 +165,7 @@ class Comment < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def editable_by?(user)
|
||||
creator_id == user.id || user.is_janitor?
|
||||
creator_id == user.id || user.is_moderator?
|
||||
end
|
||||
|
||||
def hidden_attributes
|
||||
|
||||
@@ -92,7 +92,7 @@ class ForumPost < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def validate_topic_is_unlocked
|
||||
return if CurrentUser.user.is_janitor?
|
||||
return if CurrentUser.user.is_moderator?
|
||||
return if topic.nil?
|
||||
|
||||
if topic.is_locked?
|
||||
@@ -110,7 +110,7 @@ class ForumPost < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def editable_by?(user)
|
||||
creator_id == user.id || user.is_janitor?
|
||||
creator_id == user.id || user.is_moderator?
|
||||
end
|
||||
|
||||
def update_topic_updated_at_on_create
|
||||
|
||||
@@ -119,7 +119,7 @@ class ForumTopic < ActiveRecord::Base
|
||||
include SubscriptionMethods
|
||||
|
||||
def editable_by?(user)
|
||||
creator_id == user.id || user.is_janitor?
|
||||
creator_id == user.id || user.is_moderator?
|
||||
end
|
||||
|
||||
def initialize_is_deleted
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
class JanitorTrial < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
before_create :initialize_original_level
|
||||
after_create :send_dmail
|
||||
after_create :promote_user
|
||||
validates_presence_of :user
|
||||
@@ -54,10 +53,6 @@ class JanitorTrial < ActiveRecord::Base
|
||||
self.creator_id = CurrentUser.id
|
||||
end
|
||||
|
||||
def initialize_original_level
|
||||
self.original_level = user.level
|
||||
end
|
||||
|
||||
def user_name
|
||||
user.try(:name)
|
||||
end
|
||||
@@ -67,13 +62,14 @@ class JanitorTrial < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def send_dmail
|
||||
body = "You have been selected as a test janitor. You can now approve pending posts and have access to the moderation interface. You should reacquaint yourself with the [[howto:upload]] guide to make sure you understand the site rules.\n\nOver the next several weeks your approvals will be monitored. If the majority of them are not quality uploads you will fail the trial period and be demoted back to your original level. You will also receive a negative user record indicating you previously attempted and failed a test janitor trial.\n\nThere is a minimum quota of 1 approval a month to indicate that you are being active. Remember, the goal isn't to approve as much as possible. It's to filter out borderline-quality art.\n\nIf you have any questions please respond to this message."
|
||||
body = "You have been selected as a test janitor. You can now approve pending posts and have access to the moderation interface. You should reacquaint yourself with the [[howto:upload]] guide to make sure you understand the site rules.\n\nOver the next several weeks your approvals will be monitored. If the majority of them are not quality uploads you will fail the trial period and lose your approval privileges. You will also receive a negative user record indicating you previously attempted and failed a test janitor trial.\n\nThere is a minimum quota of 1 approval a month to indicate that you are being active. Remember, the goal isn't to approve as much as possible. It's to filter out borderline-quality art.\n\nIf you have any questions please respond to this message."
|
||||
|
||||
Dmail.create_split(:title => "Test Janitor Trial Period", :body => body, :to_id => user_id)
|
||||
end
|
||||
|
||||
def promote_user
|
||||
user.promote_to!(User::Levels::JANITOR, :skip_dmail => true)
|
||||
user.can_approve_posts = true
|
||||
user.save
|
||||
end
|
||||
|
||||
def create_feedback
|
||||
@@ -88,8 +84,9 @@ class JanitorTrial < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def demote!
|
||||
user.can_approve_posts = false
|
||||
user.save
|
||||
update_attribute(:status, "inactive")
|
||||
user.update_column(:level, original_level)
|
||||
self.create_feedback
|
||||
end
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ class Pool < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def deletable_by?(user)
|
||||
user.is_janitor?
|
||||
user.is_moderator?
|
||||
end
|
||||
|
||||
def create_mod_action_for_delete
|
||||
|
||||
@@ -46,11 +46,11 @@ class PostFlag < ActiveRecord::Base
|
||||
q = q.reason_matches(params[:reason_matches])
|
||||
end
|
||||
|
||||
if params[:creator_id].present? && (CurrentUser.user.is_janitor? || params[:creator_id].to_i == CurrentUser.user.id)
|
||||
if params[:creator_id].present? && (CurrentUser.is_moderator? || params[:creator_id].to_i == CurrentUser.user.id)
|
||||
q = q.where("creator_id = ?", params[:creator_id].to_i)
|
||||
end
|
||||
|
||||
if params[:creator_name].present? && CurrentUser.user.is_janitor?
|
||||
if params[:creator_name].present? && CurrentUser.is_moderator?
|
||||
q = q.where("creator_id = (select _.id from users _ where lower(_.name) = ?)", params[:creator_name].mb_chars.downcase.strip.tr(" ", "_"))
|
||||
end
|
||||
|
||||
@@ -84,7 +84,7 @@ class PostFlag < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def validate_creator_is_not_limited
|
||||
if CurrentUser.is_janitor?
|
||||
if CurrentUser.can_approve_posts?
|
||||
# do nothing
|
||||
elsif creator.created_at > 1.week.ago
|
||||
errors[:creator] << "cannot flag within the first week of sign up"
|
||||
|
||||
@@ -2,7 +2,7 @@ class Tag < ActiveRecord::Base
|
||||
METATAGS = "-user|user|-approver|approver|commenter|comm|noter|noteupdater|artcomm|-pool|pool|ordpool|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"
|
||||
SUBQUERY_METATAGS = "commenter|comm|noter|noteupdater|artcomm"
|
||||
attr_accessible :category, :as => [:moderator, :janitor, :contributor, :gold, :member, :anonymous, :default, :builder, :admin]
|
||||
attr_accessible :is_locked, :as => [:moderator, :janitor, :admin]
|
||||
attr_accessible :is_locked, :as => [:moderator, :admin]
|
||||
has_one :wiki_page, :foreign_key => "title", :primary_key => "name"
|
||||
|
||||
module ApiMethods
|
||||
|
||||
@@ -224,7 +224,7 @@ class TagAlias < ActiveRecord::Base
|
||||
|
||||
def deletable_by?(user)
|
||||
return true if user.is_admin?
|
||||
return true if is_pending? && user.is_janitor?
|
||||
return true if is_pending? && user.can_approve_posts?
|
||||
return true if is_pending? && user.id == creator_id
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -207,7 +207,7 @@ class TagImplication < ActiveRecord::Base
|
||||
|
||||
def deletable_by?(user)
|
||||
return true if user.is_admin?
|
||||
return true if is_pending? && user.is_janitor?
|
||||
return true if is_pending? && user.is_builder?
|
||||
return true if is_pending? && user.id == creator_id
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -29,7 +29,8 @@ class User < ActiveRecord::Base
|
||||
:style_usernames => 0x0200,
|
||||
:enable_auto_complete => 0x0400,
|
||||
:show_deleted_children => 0x0800,
|
||||
:has_saved_searches => 0x1000
|
||||
:has_saved_searches => 0x1000,
|
||||
:can_approve_posts => 0x2000
|
||||
}
|
||||
|
||||
attr_accessor :password, :old_password
|
||||
|
||||
@@ -9,7 +9,7 @@ class WikiPage < ActiveRecord::Base
|
||||
belongs_to :updater, :class_name => "User"
|
||||
validates_uniqueness_of :title, :case_sensitive => false
|
||||
validates_presence_of :title
|
||||
validate :validate_locker_is_janitor
|
||||
validate :validate_locker_is_moderator
|
||||
validate :validate_not_locked
|
||||
attr_accessible :title, :body, :is_locked, :other_names
|
||||
has_one :tag, :foreign_key => "name", :primary_key => "title"
|
||||
@@ -112,15 +112,15 @@ class WikiPage < ActiveRecord::Base
|
||||
titled(title).select("title, id").first
|
||||
end
|
||||
|
||||
def validate_locker_is_janitor
|
||||
if is_locked_changed? && !CurrentUser.is_janitor?
|
||||
errors.add(:is_locked, "can be modified by janitors only")
|
||||
def validate_locker_is_moderator
|
||||
if is_locked_changed? && !CurrentUser.is_moderator?
|
||||
errors.add(:is_locked, "can be modified by moderators only")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def validate_not_locked
|
||||
if is_locked? && !CurrentUser.is_janitor?
|
||||
if is_locked? && !CurrentUser.is_moderator?
|
||||
errors.add(:is_locked, "and cannot be updated")
|
||||
return false
|
||||
end
|
||||
@@ -230,7 +230,7 @@ class WikiPage < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def visible?
|
||||
artist.blank? || !artist.is_banned? || CurrentUser.user.is_janitor?
|
||||
artist.blank? || !artist.is_banned? || CurrentUser.is_moderator?
|
||||
end
|
||||
|
||||
def other_names_array
|
||||
|
||||
@@ -40,7 +40,7 @@ class WikiPageVersion < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def visible?
|
||||
artist.blank? || !artist.is_banned? || CurrentUser.user.is_janitor?
|
||||
artist.blank? || !artist.is_banned? || CurrentUser.is_moderator?
|
||||
end
|
||||
|
||||
def other_names_array
|
||||
|
||||
Reference in New Issue
Block a user