Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Schneider
usermanager
Commits
6644a5bb
Commit
6644a5bb
authored
Feb 10, 2020
by
Thomas Schneider
Browse files
Add UsersController#show and GroupsController
parent
5956e063
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/controllers/groups_controller.rb
0 → 100644
View file @
6644a5bb
class
GroupsController
<
ApplicationController
end
app/controllers/users_controller.rb
View file @
6644a5bb
...
...
@@ -4,4 +4,8 @@ class UsersController < ApplicationController
def
index
@users
=
User
.
find
:all
,
'*'
end
def
show
@u
=
User
.
find
:first
,
params
[
:id
]
end
end
app/views/layouts/application.html.haml
View file @
6644a5bb
...
...
@@ -2,7 +2,7 @@
%html
%head
%meta
{
:content
=>
"text/html; charset=UTF-8"
,
"http-equiv"
=>
"Content-Type"
}
/
%title
User
m
anager
%title
User
M
anager
=
csrf_meta_tags
=
csp_meta_tag
=
stylesheet_link_tag
'application'
,
media:
'all'
...
...
app/views/users/index.html.haml
View file @
6644a5bb
%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 N
ame
%th
Last N
ame
%th
Primary
G
roup
%th
Given n
ame
%th
Sur
ame
%th
Primary
g
roup
%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'
app/views/users/show.html.haml
0 → 100644
View file @
6644a5bb
%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
)
config/routes.rb
View file @
6644a5bb
...
...
@@ -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
test/controllers/groups_controller_test.rb
0 → 100644
View file @
6644a5bb
require
'test_helper'
class
GroupsControllerTest
<
ActionDispatch
::
IntegrationTest
# test "the truth" do
# assert true
# end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment