Enable frozen string literals.
Make all string literals immutable by default.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApiKeyPolicy < ApplicationPolicy
|
||||
def new?
|
||||
!user.is_anonymous?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationPolicy
|
||||
attr_reader :user, :record
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ArtistCommentaryPolicy < ApplicationPolicy
|
||||
def create_or_update?
|
||||
unbanned?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ArtistPolicy < ApplicationPolicy
|
||||
def ban?
|
||||
user.is_admin? && !record.is_banned?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ArtistVersionPolicy < ApplicationPolicy
|
||||
def can_view_banned?
|
||||
policy(Artist).can_view_banned?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class BanPolicy < ApplicationPolicy
|
||||
def bannable?
|
||||
user.is_moderator? && (record.user.blank? || (record.user.level < user.level))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class BulkUpdateRequestPolicy < ApplicationPolicy
|
||||
def create?
|
||||
unbanned? && (record.forum_topic.blank? || policy(record.forum_topic).reply?)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CommentPolicy < ApplicationPolicy
|
||||
def create?
|
||||
unbanned?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CommentVotePolicy < ApplicationPolicy
|
||||
def create?
|
||||
unbanned? && !record.comment.is_deleted?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DelayedJobPolicy < ApplicationPolicy
|
||||
def update?
|
||||
user.is_admin?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DmailPolicy < ApplicationPolicy
|
||||
def create?
|
||||
unbanned?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EmailAddressPolicy < ApplicationPolicy
|
||||
def index?
|
||||
user.is_moderator?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FavoriteGroupPolicy < ApplicationPolicy
|
||||
def show?
|
||||
record.creator_id == user.id || record.is_public
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FavoritePolicy < ApplicationPolicy
|
||||
def create?
|
||||
unbanned? && user.is_member?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ForumPostPolicy < ApplicationPolicy
|
||||
def index?
|
||||
true
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ForumPostVotePolicy < ApplicationPolicy
|
||||
def create?
|
||||
unbanned? && policy(record.forum_post).votable?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ForumTopicPolicy < ApplicationPolicy
|
||||
def index?
|
||||
true
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IpAddressPolicy < ApplicationPolicy
|
||||
def index?
|
||||
user.is_moderator?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IpBanPolicy < ApplicationPolicy
|
||||
def create?
|
||||
user.is_moderator?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IpGeolocationPolicy < ApplicationPolicy
|
||||
def index?
|
||||
user.is_moderator?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MediaAssetPolicy < ApplicationPolicy
|
||||
def index?
|
||||
true
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MediaMetadataPolicy < ApplicationPolicy
|
||||
def index?
|
||||
true
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ModActionPolicy < ApplicationPolicy
|
||||
def api_attributes
|
||||
super + [:category_id]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ModerationReportPolicy < ApplicationPolicy
|
||||
def index?
|
||||
!user.is_anonymous?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ModqueuePolicy < ApplicationPolicy
|
||||
def index?
|
||||
user.is_approver?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class NewsUpdatePolicy < ApplicationPolicy
|
||||
def index?
|
||||
user.is_admin?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class NilClassPolicy < ApplicationPolicy
|
||||
def index?
|
||||
false
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class NotePolicy < ApplicationPolicy
|
||||
def revert?
|
||||
update?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PasswordPolicy < ApplicationPolicy
|
||||
def update?
|
||||
record.id == user.id || user.is_owner?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PoolPolicy < ApplicationPolicy
|
||||
def gallery?
|
||||
index?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostAppealPolicy < ApplicationPolicy
|
||||
def edit?
|
||||
update?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostApprovalPolicy < ApplicationPolicy
|
||||
def create?
|
||||
user.is_approver?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostDisapprovalPolicy < ApplicationPolicy
|
||||
def create?
|
||||
user.is_approver?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostFlagPolicy < ApplicationPolicy
|
||||
def edit?
|
||||
update?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostPolicy < ApplicationPolicy
|
||||
def show_seq?
|
||||
true
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostReplacementPolicy < ApplicationPolicy
|
||||
def create?
|
||||
user.is_moderator?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostVersionPolicy < ApplicationPolicy
|
||||
def undo?
|
||||
unbanned? && record.version > 1 && record.post.present? && policy(record.post).visible?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PostVotePolicy < ApplicationPolicy
|
||||
def create?
|
||||
unbanned? && user.is_member?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RateLimitPolicy < ApplicationPolicy
|
||||
def index?
|
||||
true
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SavedSearchPolicy < ApplicationPolicy
|
||||
def index?
|
||||
!user.is_anonymous?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TagAliasPolicy < ApplicationPolicy
|
||||
def destroy?
|
||||
user.is_admin?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TagImplicationPolicy < ApplicationPolicy
|
||||
def destroy?
|
||||
user.is_admin?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TagPolicy < ApplicationPolicy
|
||||
def can_change_category?
|
||||
user.is_admin? ||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UploadPolicy < ApplicationPolicy
|
||||
def show?
|
||||
record.is_completed? || user.is_admin? || record.uploader_id == user.id
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserEventPolicy < ApplicationPolicy
|
||||
def index?
|
||||
user.is_moderator?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserFeedbackPolicy < ApplicationPolicy
|
||||
def create?
|
||||
unbanned? && user.is_gold? && record.user_id != user.id
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserNameChangeRequestPolicy < ApplicationPolicy
|
||||
def index?
|
||||
!user.is_anonymous?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserPolicy < ApplicationPolicy
|
||||
def create?
|
||||
true
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserSessionPolicy < ApplicationPolicy
|
||||
def index?
|
||||
user.is_admin?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UserUpgradePolicy < ApplicationPolicy
|
||||
def create?
|
||||
!user.is_anonymous?
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WikiPagePolicy < ApplicationPolicy
|
||||
def update?
|
||||
unbanned? && (can_edit_locked? || !record.is_locked?)
|
||||
|
||||
Reference in New Issue
Block a user