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