2022-06-10 12:03:33 +02:00
|
|
|
class PostPolicy < ApplicationPolicy
|
2022-06-22 10:17:42 +02:00
|
|
|
def permitted_attributes_for_create
|
|
|
|
|
[:title, :description, :board_id]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def permitted_attributes_for_update
|
2023-01-18 21:11:27 +01:00
|
|
|
if user.moderator?
|
2024-07-12 20:38:46 +02:00
|
|
|
[:title, :description, :board_id, :post_status_id, :approval_status]
|
2022-06-22 10:17:42 +02:00
|
|
|
else
|
|
|
|
|
[:title, :description]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2022-06-10 12:03:33 +02:00
|
|
|
def update?
|
2023-01-18 21:11:27 +01:00
|
|
|
user == record.user or user.moderator?
|
2022-06-10 12:03:33 +02:00
|
|
|
end
|
2022-06-22 10:17:42 +02:00
|
|
|
|
|
|
|
|
def destroy?
|
2023-01-18 21:11:27 +01:00
|
|
|
user == record.user or user.moderator?
|
2022-06-22 10:17:42 +02:00
|
|
|
end
|
2022-06-10 12:03:33 +02:00
|
|
|
end
|