Files
danbooru/app/policies/upload_policy.rb
evazion a7dc05ce63 Enable frozen string literals.
Make all string literals immutable by default.
2021-12-14 21:33:27 -06:00

36 lines
726 B
Ruby

# frozen_string_literal: true
class UploadPolicy < ApplicationPolicy
def show?
record.is_completed? || user.is_admin? || record.uploader_id == user.id
end
def batch?
unbanned?
end
def image_proxy?
unbanned?
end
def preprocess?
unbanned?
end
def can_view_tags?
user.is_admin? || record.uploader_id == user.id
end
def permitted_attributes
%i[file source tag_string rating status parent_id artist_commentary_title
artist_commentary_desc referer_url
md5_confirmation as_pending translated_commentary_title translated_commentary_desc]
end
def api_attributes
attributes = super
attributes -= [:tag_string] unless can_view_tags?
attributes
end
end