Convert various moderator? tests to use cancancan permissions checks

This commit is contained in:
Andy Allan 2019-10-23 11:26:16 +02:00
parent 60ecfde65c
commit fb709531ba
6 changed files with 13 additions and 9 deletions

View file

@ -12,9 +12,13 @@
<%= @redaction.description.to_html %>
</div>
<% if current_user and current_user.moderator? %>
<% if can?(:edit, Redaction) || can?(:destroy, Redaction) %>
<div class="buttons">
<%= button_to t(".edit"), edit_redaction_path(@redaction), :method => :get %></td>
<%= button_to t(".destroy"), @redaction, :method => "delete", :remote => true, :data => { :confirm => t(".confirm") } %>
<% if can?(:edit, Redaction) %>
<%= button_to t(".edit"), edit_redaction_path(@redaction), :method => :get %></td>
<% end %>
<% if can?(:destroy, Redaction) %>
<%= button_to t(".destroy"), @redaction, :method => "delete", :remote => true, :data => { :confirm => t(".confirm") } %>
<% end %>
</div>
<% end %>

View file

@ -4,7 +4,7 @@
<% end %>
<% unless @user_blocks.empty? %>
<%= render :partial => "blocks", :locals => { :show_revoke_link => (current_user && current_user.moderator?), :show_user_name => true, :show_creator_name => false } %>
<%= render :partial => "blocks", :locals => { :show_revoke_link => can?(:revoke, UserBlock), :show_user_name => true, :show_creator_name => false } %>
<% else %>
<p><%= t ".empty", :name => h(@user.display_name) %></p>
<% end %>

View file

@ -3,7 +3,7 @@
<h1><%= raw(t(".heading", :name => link_to(h(@user.display_name), user_path(@user)))) %></h1>
<% end %>
<% unless @user_blocks.empty? %>
<%= render :partial => "blocks", :locals => { :show_revoke_link => (current_user && current_user.moderator?), :show_user_name => false, :show_creator_name => true } %>
<%= render :partial => "blocks", :locals => { :show_revoke_link => can?(:revoke, UserBlock), :show_user_name => false, :show_creator_name => true } %>
<% else %>
<p><%= t ".empty", :name => h(@user.display_name) %></p>
<% end %>

View file

@ -4,7 +4,7 @@
<% end %>
<% unless @user_blocks.empty? %>
<%= render :partial => "blocks", :locals => { :show_revoke_link => (current_user && current_user.moderator?), :show_user_name => true, :show_creator_name => true } %>
<%= render :partial => "blocks", :locals => { :show_revoke_link => can?(:revoke, UserBlock), :show_user_name => true, :show_creator_name => true } %>
<% else %>
<p><%= t ".empty" %></p>
<% end %>

View file

@ -13,7 +13,7 @@
<% if current_user and current_user.id == @user_block.creator_id %>
<li><%= link_to t(".edit"), edit_user_block_path(@user_block) %></li>
<% end %>
<% if current_user and current_user.moderator? %>
<% if can?(:revoke, UserBlock) %>
<li><%= link_to(t(".revoke"), :controller => "user_blocks", :action => "revoke", :id => @user_block.id) %></li>
<% end %>
<% end %>

View file

@ -35,7 +35,7 @@
</li>
<% end %>
<% if current_user and current_user.moderator? and current_user.blocks_created.exists? %>
<% if can?(:create, UserBlock) and current_user.blocks_created.exists? %>
<li>
<%= link_to t(".blocks by me"), :controller => "user_blocks", :action => "blocks_by", :display_name => current_user.display_name %>
<span class='count-number'><%= number_with_delimiter(current_user.blocks_created.active.size) %></span>
@ -96,7 +96,7 @@
</li>
<% end %>
<% if current_user and current_user.moderator? %>
<% if can?(:create, UserBlock) %>
<li>
<%= link_to t(".create_block"), :controller => "user_blocks", :action => "new", :display_name => @user.display_name %>
</li>