Files
danbooru/app/policies/forum_topic_policy.rb
evazion 5adeedcf01 forum: add "..." menu to forum posts, like comments have.
Adds the ability to copy forum post IDs, like with comments.

Fixes #4768: Display DText shortlink for forum posts/topics.
2022-01-13 12:49:20 -06:00

47 lines
847 B
Ruby

# frozen_string_literal: true
class ForumTopicPolicy < ApplicationPolicy
def index?
true
end
def show?
user.level >= record.min_level
end
def update?
unbanned? && show? && (user.is_moderator? || (record.creator_id == user.id && !record.is_locked?))
end
def destroy?
unbanned? && show? && user.is_moderator?
end
def undelete?
unbanned? && show? && user.is_moderator?
end
def mark_all_as_read?
!user.is_anonymous?
end
def reply?
show? && (user.is_moderator? || !record.is_locked?)
end
def moderate?
user.is_moderator?
end
def permitted_attributes
[
:title, :category_id, { original_post_attributes: [:id, :body] },
([:is_sticky, :is_locked, :min_level] if moderate?),
].compact.flatten
end
def html_data_attributes
super + [:is_read?]
end
end