Skip to content

Commit 3f22c8f

Browse files
committed
Merge pull request browsermedia#683 from jamesprior/master
browsermedia#665 do not show remove button for sections that cannot be removed from ...
2 parents 77898c3 + a2b0ce3 commit 3f22c8f

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

app/models/cms/section_node.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def page?
7878
def link?
7979
node_type == 'Cms::Link'
8080
end
81+
82+
def deletable?
83+
!self.root? && (!section? || node.deletable?)
84+
end
8185

8286
# @param [Section] section
8387
# @param [Integer] position

app/views/cms/section_nodes/_row_buttons.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
<!--<li><%= link_to("Hide", "#", class: 'add-link') unless section_node.root? %></li>-->
88
<li><%= link_to 'Remove', engine_aware_path(section_node.node),
99
class: 'add-link http_delete confirm_with_title',
10-
title: "Are you sure you want to remove #{section_node.node.name}?" unless section_node.root? %></li>
10+
title: "Are you sure you want to remove #{section_node.node.name}?" if section_node.deletable? %></li>
1111
</ul>

lib/cms/acts/cms_user.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ def cms_access?
100100
# Return a list of the sections associated with this user that can be viewed.
101101
# Overridden from user so that able_to_view? will work correctly.
102102
def viewable_sections
103-
@viewable_sections ||= Cms::Section.find(:all, :include => :groups, :conditions => ["#{Cms::Group.table_name}.id in (?)", cms_groups.collect(&:id)])
103+
@viewable_sections ||= Cms::Section.includes(:groups).where(["#{Cms::Group.table_name}.id in (?)", cms_groups.collect(&:id)])
104104
end
105105

106106
def permissions
107-
@permissions ||= Cms::Permission.find(:all, :include => :groups, :conditions => ["#{Cms::Group.table_name}.id in (?)", cms_groups.collect(&:id)])
107+
@permissions ||= Cms::Permission.includes(:groups).where(["#{Cms::Group.table_name}.id in (?)", cms_groups.collect(&:id)])
108108
end
109109

110110
def able_to_edit?(section)

0 commit comments

Comments
 (0)