adds admin layout and access links [#163]
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
class Admin::DashboardController < Admin::BaseController
|
class Admin::DashboardController < Admin::BaseController
|
||||||
|
layout 'admin'
|
||||||
|
|
||||||
def index
|
def index
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
class Moderation::DashboardController < Moderation::BaseController
|
class Moderation::DashboardController < Moderation::BaseController
|
||||||
|
layout 'admin'
|
||||||
|
|
||||||
def index
|
def index
|
||||||
end
|
end
|
||||||
|
|||||||
7
app/helpers/admin_helper.rb
Normal file
7
app/helpers/admin_helper.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
module AdminHelper
|
||||||
|
|
||||||
|
def namespace
|
||||||
|
controller.class.parent.name.downcase
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
3
app/views/admin/shared/_menu.html.erb
Normal file
3
app/views/admin/shared/_menu.html.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<div id="admin_menu">
|
||||||
|
Admin links
|
||||||
|
</div>
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
<section class="top-bar-section">
|
<section class="top-bar-section">
|
||||||
<%= render 'devise/menu/login_items' %>
|
<%= render 'devise/menu/login_items' %>
|
||||||
|
<%= render 'shared/admin_login_items' %>
|
||||||
</section>
|
</section>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
33
app/views/layouts/admin.html.erb
Normal file
33
app/views/layouts/admin.html.erb
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="es">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
||||||
|
<title><%= content_for?(:title) ? yield(:title) : "Admin" %></title>
|
||||||
|
<%= stylesheet_link_tag "application" %>
|
||||||
|
<%= javascript_include_tag "vendor/modernizr" %>
|
||||||
|
<%= javascript_include_tag "application", 'data-turbolinks-track' => true %>
|
||||||
|
<%= csrf_meta_tags %>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<%= render 'layouts/header' %>
|
||||||
|
|
||||||
|
<% if notice %>
|
||||||
|
<p class="alert-box success"><%= notice %></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if alert %>
|
||||||
|
<p class="alert-box"><%= alert %></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="left" style="padding:50px;">
|
||||||
|
<%= render "/#{namespace}/shared/menu" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= yield %>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
3
app/views/moderation/shared/_menu.html.erb
Normal file
3
app/views/moderation/shared/_menu.html.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<div id="moderation_menu">
|
||||||
|
Moderation links
|
||||||
|
</div>
|
||||||
15
app/views/shared/_admin_login_items.html.erb
Normal file
15
app/views/shared/_admin_login_items.html.erb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<ul class="right">
|
||||||
|
<% if current_user %>
|
||||||
|
<% if current_user.administrator? %>
|
||||||
|
<li>
|
||||||
|
<%= link_to t("layouts.header.administration"), admin_root_path %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if current_user.moderator? %>
|
||||||
|
<li>
|
||||||
|
<%= link_to t("layouts.header.moderation"), moderation_root_path %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
@@ -12,6 +12,8 @@ en:
|
|||||||
see_all_debates: See all debates
|
see_all_debates: See all debates
|
||||||
my_account_link: My account
|
my_account_link: My account
|
||||||
language: Site language
|
language: Site language
|
||||||
|
administration: Administration
|
||||||
|
moderation: Moderation
|
||||||
footer:
|
footer:
|
||||||
copyright: "Ayuntamiento de Madrid, 2015. All rights reserved"
|
copyright: "Ayuntamiento de Madrid, 2015. All rights reserved"
|
||||||
debates:
|
debates:
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ es:
|
|||||||
see_all_debates: Ver todos los debates
|
see_all_debates: Ver todos los debates
|
||||||
my_account_link: Mi cuenta
|
my_account_link: Mi cuenta
|
||||||
language: Idioma de la página
|
language: Idioma de la página
|
||||||
|
administration: Admininstar
|
||||||
|
moderation: Moderar
|
||||||
footer:
|
footer:
|
||||||
copyright: "Ayuntamiento de Madrid, %{year}. Todos los derechos reservados"
|
copyright: "Ayuntamiento de Madrid, %{year}. Todos los derechos reservados"
|
||||||
debates:
|
debates:
|
||||||
|
|||||||
@@ -31,4 +31,50 @@ feature 'Admin' do
|
|||||||
expect(page).to_not have_content "not authorized"
|
expect(page).to_not have_content "not authorized"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Admin access links" do
|
||||||
|
create(:administrator, user: user)
|
||||||
|
|
||||||
|
login_as(user)
|
||||||
|
visit root_path
|
||||||
|
|
||||||
|
expect(page).to have_link('Administration')
|
||||||
|
expect(page).to_not have_link('Moderator')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Moderation access links" do
|
||||||
|
create(:moderator, user: user)
|
||||||
|
|
||||||
|
login_as(user)
|
||||||
|
visit root_path
|
||||||
|
|
||||||
|
expect(page).to have_link('Moderation')
|
||||||
|
expect(page).to_not have_link('Administration')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Admin dashboard' do
|
||||||
|
create(:administrator, user: user)
|
||||||
|
|
||||||
|
login_as(user)
|
||||||
|
visit root_path
|
||||||
|
|
||||||
|
click_link 'Administration'
|
||||||
|
|
||||||
|
expect(current_path).to eq(admin_root_path)
|
||||||
|
expect(page).to have_css('#admin_menu')
|
||||||
|
expect(page).to_not have_css('#moderation_menu')
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Moderation dashboard' do
|
||||||
|
create(:moderator, user: user)
|
||||||
|
|
||||||
|
login_as(user)
|
||||||
|
visit root_path
|
||||||
|
|
||||||
|
click_link 'Moderation'
|
||||||
|
|
||||||
|
expect(current_path).to eq(moderation_root_path)
|
||||||
|
expect(page).to have_css('#moderation_menu')
|
||||||
|
expect(page).to_not have_css('#admin_menu')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user