Files
danbooru/app/policies/wiki_page_policy.rb
evazion 937653e519 models: move html_data_attributes to policies.
Move html_data_attributes definitions from models to policies. Which
attributes are permitted as data-* attributes is a view level concern
and should be defined on the policy level, not the model level. Models
should be agnostic about how they're used in views.
2020-08-17 22:33:18 -05:00

26 lines
471 B
Ruby

class WikiPagePolicy < ApplicationPolicy
def update?
unbanned? && (can_edit_locked? || !record.is_locked?)
end
def revert?
update?
end
def can_edit_locked?
user.is_builder?
end
def permitted_attributes
[:title, :body, :other_names, :other_names_string, :is_deleted, (:is_locked if can_edit_locked?)].compact
end
def api_attributes
super + [:category_name]
end
def html_data_attributes
super + [:category_name]
end
end