Skip to content
Snippets Groups Projects
Commit 44edc493 authored by pabois's avatar pabois
Browse files

abilities

parent 8b973811
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,6 @@ class Ability
def teacher
can :manage, University::Person, user_id: @user.id
# can :read, University::Person, university_id: @user.university_id
cannot :create, University::Person
can :read, Education::Program, university_id: @user.university_id
can :read, University::Role, university_id: @user.university_id
......@@ -41,6 +40,12 @@ class Ability
end
def program_manager
can :manage, University::Person, university_id: @user.university_id
can :manage, Education::Program, university_id: @user.university_id
can :manage, University::Role, university_id: @user.university_id
can :manage, University::Person::Involvement, university_id: @user.university_id
can :read, Communication::Website, university_id: @user.university_id
can :manage, Communication::Website::Post, university_id: @user.university_id
end
......
......@@ -6,33 +6,41 @@
[
{
title: Communication::Website.model_name.human,
path: admin_communication_website_path(id: @website)
path: admin_communication_website_path(id: @website),
ability: can?(:read, @website)
},
{
title: Communication::Website::Post.model_name.human(count: 2),
path: admin_communication_website_posts_path(website_id: @website)
path: admin_communication_website_posts_path(website_id: @website),
ability: can?(:read, Communication::Website::Post)
},
{
title: Communication::Website::Home.model_name.human,
path: admin_communication_website_home_path(website_id: @website)
path: admin_communication_website_home_path(website_id: @website),
ability: can?(:read, Communication::Website::Home)
},
{
title: Communication::Website::Page.model_name.human(count: 2),
path: admin_communication_website_pages_path(website_id: @website)
path: admin_communication_website_pages_path(website_id: @website),
ability: can?(:read, Communication::Website::Page)
},
{
title: Communication::Website::Category.model_name.human(count: 2),
path: admin_communication_website_categories_path(website_id: @website)
path: admin_communication_website_categories_path(website_id: @website),
ability: can?(:read, Communication::Website::Category)
},
{
title: t('communication.authors', count: 2),
path: admin_communication_website_authors_path(website_id: @website)
path: admin_communication_website_authors_path(website_id: @website),
ability: can?(:read, University::Person)
},
{
title: Communication::Website::Menu.model_name.human(count: 2),
path: admin_communication_website_menus_path(website_id: @website)
path: admin_communication_website_menus_path(website_id: @website),
ability: can?(:read, Communication::Website::Category)
},
].each do |object|
next unless object[:ability]
active = object[:path].in? request.path
%>
<a class="list-group-item list-group-item-action<%= ' active' if active %>" href="<%= object[:path] %>">
......
......@@ -11,14 +11,18 @@
<% end %>
<%= render 'admin/communication/websites/sidebar' do %>
<%= render 'admin/communication/websites/show/posts' %>
<%= render 'admin/communication/websites/show/posts' if can? :read, Communication::Website::Post %>
<div class="row">
<div class="col-md-8">
<%= render 'admin/communication/websites/show/pages' %>
</div>
<div class="col-md-4">
<%= render 'admin/communication/websites/show/home' %>
</div>
<% if can? :read, Communication::Website::Page %>
<div class="col-md-8">
<%= render 'admin/communication/websites/show/pages' %>
</div>
<% end %>
<% if can? :read, Communication::Website::Home %>
<div class="col-md-4">
<%= render 'admin/communication/websites/show/home' %>
</div>
<% end %>
</div>
<% end %>
......@@ -30,15 +34,17 @@
<% end %>
<% content_for :action_bar_right do %>
<% if @website.imported? %>
<%= link_to t('communication.website.imported.show'),
import_admin_communication_website_path,
class: button_classes %>
<% else %>
<%= link_to t('communication.website.imported.launch'),
import_admin_communication_website_path,
method: :post,
class: button_classes %>
<% if can? :read, Communication::Website::Imported::Website %>
<% if @website.imported? %>
<%= link_to t('communication.website.imported.show'),
import_admin_communication_website_path,
class: button_classes %>
<% else %>
<%= link_to t('communication.website.imported.launch'),
import_admin_communication_website_path,
method: :post,
class: button_classes %>
<% end %>
<% end %>
<%= edit_link @website %>
<% end %>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment