2023-02-02 22:44:40 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module SidebarGuardian
|
2023-02-21 16:55:44 -05:00
|
|
|
def can_create_public_sidebar_section?
|
2023-05-22 19:53:32 -04:00
|
|
|
@user.admin?
|
2023-02-21 16:55:44 -05:00
|
|
|
end
|
|
|
|
|
2023-02-02 22:44:40 -05:00
|
|
|
def can_edit_sidebar_section?(sidebar_section)
|
2023-05-22 19:53:32 -04:00
|
|
|
return @user.admin? if sidebar_section.public?
|
|
|
|
return @user.admin? if sidebar_section.section_type
|
2023-02-02 22:44:40 -05:00
|
|
|
is_my_own?(sidebar_section)
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_delete_sidebar_section?(sidebar_section)
|
2023-05-22 20:54:55 -04:00
|
|
|
return false if sidebar_section.section_type.present?
|
2023-05-22 19:53:32 -04:00
|
|
|
return @user.admin? if sidebar_section.public?
|
2023-02-02 22:44:40 -05:00
|
|
|
is_my_own?(sidebar_section)
|
|
|
|
end
|
|
|
|
end
|