Skip to content
Snippets Groups Projects
Commit 6644a5bb authored by Thomas Schneider's avatar Thomas Schneider
Browse files

Add UsersController#show and GroupsController

parent 5956e063
Branches
No related tags found
No related merge requests found
class GroupsController < ApplicationController
end
......@@ -4,4 +4,8 @@ class UsersController < ApplicationController
def index
@users = User.find :all, '*'
end
def show
@u = User.find :first, params[:id]
end
end
......@@ -2,7 +2,7 @@
%html
%head
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
%title Usermanager
%title UserManager
= csrf_meta_tags
= csp_meta_tag
= stylesheet_link_tag 'application', media: 'all'
......
%h1 User list
.btn-group
%a.btn.btn-primary{role: 'button', href: new_user_path} Create user
%table.table.table-striped#dttb
%caption List of users
%thead
%tr
%th User ID
%th First Name
%th Last Name
%th Primary Group
%th Given name
%th Surame
%th Primary group
%th Groups
%th Status
%tbody
- @users.each do |u|
%tr
%td= u.cn
%td= link_to u.cn, user_path(u)
%td= u.givenname
%td= u.sn
%td= u.primary_group.cn if u.primary_group.exists?
%td= u.groups.map {|g| g.cn}.join(', ')
%td
- if u.primary_group.exists?
= link_to u.primary_group.cn, group_path(u.primary_group)
%td!= u.groups.map {|g| link_to g.cn, group_path(g)}.join(', ')
%td{class: u.active? ? 'table-success' : 'table-warning'}
%span{class: [:fas, u.active? ? 'fa-check' : 'fa-lock'], aria: {hidden: :true}, title: u.active? ? 'Enabled' : 'Disabled'}
%span.sr-only= u.active? ? 'Enabled' : 'Disabled'
%h1 User details
.btn-group
%a.btn.btn-danger{role: 'button'} Disable user
%a.btn.btn-primary{role: 'button'} Change group(s)
%table.table.table-hover
%tbody
%tr
%td User ID
%td= @u.cn
%tr
%td Given name
%td= @u.givenname
%tr
%td Surname
%td= @u.sn
%tr
%td Status
%td{class: @u.active? ? 'table-success' : 'table-warning'}
%span{class: [:fas, @u.active? ? 'fa-check' : 'fa-lock'], aria: {hidden: :true}, title: @u.active? ? 'Enabled' : 'Disabled'}
= @u.active? ? 'Enabled' : 'Disabled'
%tr
%td Primary group
- if @u.primary_group.exists?
%td= link_to @u.primary_group.cn, group_path(@u.primary_group)
- else
%td.table-warning No primary group
%tr
%td Groups
%td{class: @u.groups.empty? && 'table-warning'}
- if @u.groups.empty?
No groups
- else
%ul.list-group
- @u.groups.each do |g|
%li.list-group-item= link_to g.cn, group_path(g)
......@@ -3,4 +3,5 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resources :users
resources :groups
end
require 'test_helper'
class GroupsControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment