diff --git a/app/controllers/admin/communication/websites_controller.rb b/app/controllers/admin/communication/websites_controller.rb index a4bdc69707a4f41ab87e12fe47f0c20d10ae64fc..030e0633e8b9701b6dcd5da8287e1080d74e4539 100644 --- a/app/controllers/admin/communication/websites_controller.rb +++ b/app/controllers/admin/communication/websites_controller.rb @@ -13,8 +13,8 @@ class Admin::Communication::WebsitesController < Admin::Communication::Applicati end def show - @pages = @website.pages.published.recent - @posts = @website.posts.published.recent + @pages = @website.pages.accessible_by(current_ability).published.recent + @posts = @website.posts.accessible_by(current_ability).published.recent breadcrumb end diff --git a/app/views/admin/communication/websites/posts/index.html.erb b/app/views/admin/communication/websites/posts/index.html.erb index 3f6fc4ecc002f40a406488769fa5cdf39f4771c9..811f99a9b7ba9a4a8260e3a0a72f589b4b928e0d 100644 --- a/app/views/admin/communication/websites/posts/index.html.erb +++ b/app/views/admin/communication/websites/posts/index.html.erb @@ -32,25 +32,28 @@ <% end %> </div> <div class="row"> - <div class="col-md-6"> - <div class="card"> - <div class="card-header"> - <div class="float-end"> - <%= create_link Communication::Website::Category %> + <% if can?(:create, Communication::Website::Category) || (@root_categories.any? && can?(:edit, @root_categories.first)) %> + <div class="col-md-6"> + <div class="card"> + <div class="card-header"> + <div class="float-end"> + <%= create_link Communication::Website::Category %> + </div> + <h2 class="card-title"> + <%= Communication::Website::Category.model_name.human(count: 2) %> + </h2> + </div> + <div class="card-body"> + <ul class="list-unstyled treeview treeview--sortable js-treeview js-treeview-sortable js-treeview-sortable-container" + data-id="" + data-sort-url="<%= reorder_admin_communication_website_categories_path %>"> + <%= render 'admin/communication/websites/categories/treebranch', categories: @root_categories %> + </ul> </div> - <h2 class="card-title"> - <%= Communication::Website::Category.model_name.human(count: 2) %> - </h2> - </div> - <div class="card-body"> - <ul class="list-unstyled treeview treeview--sortable js-treeview js-treeview-sortable js-treeview-sortable-container" - data-id="" - data-sort-url="<%= reorder_admin_communication_website_categories_path %>"> - <%= render 'admin/communication/websites/categories/treebranch', categories: @root_categories %> - </ul> </div> </div> - </div> + <% end %> + <% if @authors.any? %> <div class="col-md-6"> <div class="card"> <div class="card-header"> @@ -64,6 +67,7 @@ <% end %> </div> </div> + <% end %> </div> <% end %> diff --git a/app/views/admin/communication/websites/show/_pages.html.erb b/app/views/admin/communication/websites/show/_pages.html.erb index 17fbbd2070b3ffa625d6fc21e8ac114d578e3991..e66b6df5f2d0819841863a5c30a3c615c0e0d58f 100644 --- a/app/views/admin/communication/websites/show/_pages.html.erb +++ b/app/views/admin/communication/websites/show/_pages.html.erb @@ -10,7 +10,7 @@ <%= t('communication.website.last_pages') %> <small> - - <%= t('communication.website.see_all', number: @website.pages.count) %> + <%= t('communication.website.see_all', number: @website.pages.accessible_by(current_ability).count) %> </small> <% end %> </h2> diff --git a/app/views/admin/communication/websites/show/_posts.html.erb b/app/views/admin/communication/websites/show/_posts.html.erb index 9f91cbbdc8c8cbd4a81185fbbf3d30c20c697b50..186639df5c50374b68e5d37548f49a848c959084 100644 --- a/app/views/admin/communication/websites/show/_posts.html.erb +++ b/app/views/admin/communication/websites/show/_posts.html.erb @@ -13,7 +13,7 @@ <%= t('communication.website.last_posts') %> <small> - - <%= t('communication.website.see_all', number: @website.posts.count) %> + <%= t('communication.website.see_all', number: @website.posts.accessible_by(current_ability).count) %> </small> <% end %> </h2>