2023-02-03 14:44:40 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module SidebarGuardian
|
2023-02-22 08:55:44 +11:00
|
|
|
def can_create_public_sidebar_section?
|
2023-05-23 09:53:32 +10:00
|
|
|
@user.admin?
|
2023-02-22 08:55:44 +11:00
|
|
|
end
|
|
|
|
|
2023-02-03 14:44:40 +11:00
|
|
|
def can_edit_sidebar_section?(sidebar_section)
|
2023-05-23 09:53:32 +10:00
|
|
|
return @user.admin? if sidebar_section.public?
|
|
|
|
return @user.admin? if sidebar_section.section_type
|
2023-02-03 14:44:40 +11:00
|
|
|
is_my_own?(sidebar_section)
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_delete_sidebar_section?(sidebar_section)
|
2023-05-23 10:54:55 +10:00
|
|
|
return false if sidebar_section.section_type.present?
|
2023-05-23 09:53:32 +10:00
|
|
|
return @user.admin? if sidebar_section.public?
|
2023-02-03 14:44:40 +11:00
|
|
|
is_my_own?(sidebar_section)
|
|
|
|
end
|
|
|
|
end
|