Admin interface #6

Merged
ignisf merged 23 commits from admin-interface into master 2014-10-06 12:33:26 +03:00
12 changed files with 109 additions and 4 deletions
Showing only changes of commit 10eec9c080 - Show all commits

View File

@ -0,0 +1,32 @@
.record-table {
@extend .table;
td {
vertical-align: middle !important;
}
.actions {
@extend .pull-right;
@extend .btn-group;
white-space: nowrap;
a {
@extend .btn;
@extend .btn-default;
}
}
.toggle {
a {
@extend .btn;
}
a.checked {
@extend .btn-success;
}
a.unchecked {
@extend .btn-primary;
}
}
}

View File

@ -1,6 +1,6 @@
//= require_directory .
@import "bootstrap-sprockets";
@import "bootswatch/simplex/variables";
@import "bootstrap";
@import "bootswatch/simplex/bootswatch";
@import "navbar";
@import "record_table";

View File

@ -0,0 +1,20 @@
module Management
class UsersController < ManagementController
before_action :assign_user, only: [:toggle_admin]
def index
@users = User.all
end
def toggle_admin
@user.admin = !@user.admin
@user.save
end
private
def assign_user
@user = User.find params[:id]
end
end
end

View File

@ -21,7 +21,7 @@ html
.navbar-collapse.collapse
ul.nav.navbar-nav
li.active = link_to 'Home', root_path
li = link_to 'Users', root_path
li = link_to 'Users', management_users_path
div.container
== yield
= javascript_include_tag "management/application"

View File

@ -0,0 +1,17 @@
tr id="user-#{user.id}"
td = user.email
td = user.speaker_profile.try(:first_name) or '-'
td = user.speaker_profile.try(:last_name) or '-'
td
- if user.admin?
span.toggle
= link_to glyph(:check), toggle_admin_management_user_path(user), remote: true, method: :post, data: {confirm: t(:are_you_sure)}, class: 'checked'
- else
span.toggle
= link_to glyph(:unchecked), toggle_admin_management_user_path(user), remote: true, method: :post, data: {confirm: t(:are_you_sure)}, class: 'unchecked'
td
.actions
= link_to management_user_path(user), title: t(:edit)
= glyph(:share)
= link_to edit_management_user_path(user), title: t(:edit)
= glyph(:edit)

View File

@ -0,0 +1,14 @@
.row
.panel.panel-primary
.panel-heading
h3.panel-title = User.model_name.human(count: 2)
table.record-table
thead
tr
th = User.human_attribute_name(:email)
th = SpeakerProfile.human_attribute_name(:first_name)
th = SpeakerProfile.human_attribute_name(:last_name)
th = SpeakerProfile.human_attribute_name(:admin)
th
tbody
= render @users

View File

@ -0,0 +1 @@
$('#user-<%= @user.id %>').replaceWith('<%= j render @user %>');

View File

@ -0,0 +1,2 @@
bg:
are_you_sure: Сигурен ли си?

View File

@ -0,0 +1,2 @@
en:
are_you_sure: Are you sure?

View File

@ -4,8 +4,13 @@ Rails.application.routes.draw do
devise_for :users, controllers: {registrations: 'registrations', sessions: 'sessions'}
scope :management, module: :management do
namespace :management do
get '/', to: 'home#index'
resources :users do
member do
post 'toggle_admin'
end
end
end
root 'home#index'

View File

@ -0,0 +1,12 @@
require 'rails_helper'
RSpec.describe Management::UsersController, :type => :controller do
describe "GET index" do
it "returns http success" do
get :index
expect(response).to be_success
end
end
end