forked from fixin.me/fixin.me
Add Users#show
This commit is contained in:
parent
e68092f6b5
commit
a7fce807c5
@ -250,36 +250,52 @@ table.items {
|
|||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
margin: 1rem auto 0 auto;
|
margin: 1rem auto 0 auto;
|
||||||
}
|
}
|
||||||
table.items th {
|
table.items thead {
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
|
line-height: 2.2rem;
|
||||||
}
|
}
|
||||||
table.items th,
|
table.items thead,
|
||||||
table.items tr:hover {
|
table.items tbody tr:hover {
|
||||||
background-color: #f3f3f3;
|
background-color: #f3f3f3;
|
||||||
}
|
}
|
||||||
table.items th,
|
table.items th,
|
||||||
table.items td:not(.svg):not(.actions) {
|
table.items td:not(:first-child):not(.actions) {
|
||||||
padding: 0.8rem;
|
padding: 0 0.8rem;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
table.items td {
|
table.items td {
|
||||||
border-top: 1px solid #dddddd;
|
border-top: 1px solid #dddddd;
|
||||||
|
line-height: 2.5rem;
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
table.items td a {
|
table.items td a {
|
||||||
|
color: black;
|
||||||
|
cursor: pointer;
|
||||||
|
display: block;
|
||||||
|
font-weight: normal;
|
||||||
|
padding: 0 0.8rem;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
table.items td a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
text-decoration-thickness: 0.05rem;
|
||||||
|
text-underline-offset: 0.2rem;
|
||||||
|
}
|
||||||
|
table.items td a.image-button {
|
||||||
border-color: #dddddd;
|
border-color: #dddddd;
|
||||||
color: #909090;
|
color: #909090;
|
||||||
font-weight: normal;
|
|
||||||
margin-right: 0.25rem;
|
margin-right: 0.25rem;
|
||||||
padding: 0.25rem;
|
padding: 0.25rem;
|
||||||
}
|
}
|
||||||
table.items td:not(:first-child) {
|
table.items td:not(:first-child) {
|
||||||
color: #909090;
|
color: #909090;
|
||||||
fill: #909090;
|
fill: #909090;
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
table.items td.actions {
|
table.items td.actions {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
table.items svg {
|
table.items svg {
|
||||||
height: 1.2rem;
|
height: 1.2rem;
|
||||||
|
vertical-align: middle;
|
||||||
width: 1.2rem;
|
width: 1.2rem;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
before_action :find_user, only: [:destroy]
|
before_action :find_user, only: [:show]
|
||||||
before_action do
|
before_action do
|
||||||
raise AccessForbidden unless current_user.at_least(:admin)
|
raise AccessForbidden unless current_user.at_least(:admin)
|
||||||
end
|
end
|
||||||
@ -8,9 +8,11 @@ class UsersController < ApplicationController
|
|||||||
@users = User.all
|
@users = User.all
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: add #show and #update to change user status
|
def show
|
||||||
# TODO: remove admin dependent fields from registrations#edit and move them to
|
end
|
||||||
# #show
|
|
||||||
|
# TODO: add #update to change user status
|
||||||
|
# TODO: add #become/#revert to change to user view
|
||||||
|
|
||||||
# NOTE: limited actions availabe to :admin by design. Users are meant to
|
# NOTE: limited actions availabe to :admin by design. Users are meant to
|
||||||
# manage their accounts by themselves through registrations. In future :admin
|
# manage their accounts by themselves through registrations. In future :admin
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
<% if current_user.at_least(:admin) %>
|
<table class="items" id="users">
|
||||||
<table class="items" id="users">
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= User.human_attribute_name(:email).capitalize %></th>
|
<th><%= User.human_attribute_name(:email).capitalize %></th>
|
||||||
<th><%= User.human_attribute_name(:status).capitalize %></th>
|
<th><%= User.human_attribute_name(:status).capitalize %></th>
|
||||||
<th><%= User.human_attribute_name(:created_at).capitalize %> <sup>UTC</sup></th>
|
|
||||||
<th><%= User.human_attribute_name(:confirmed_at).capitalize %></th>
|
<th><%= User.human_attribute_name(:confirmed_at).capitalize %></th>
|
||||||
|
<th><%= User.human_attribute_name(:created_at).capitalize %> <sup>UTC</sup></th>
|
||||||
<!-- <th><%#= t :actions %></th> -->
|
<!-- <th><%#= t :actions %></th> -->
|
||||||
</tr>
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
<% @users.each do |user| %>
|
<% @users.each do |user| %>
|
||||||
<tr>
|
<tr>
|
||||||
<%# TODO: add user show link %>
|
<td><%= link_to user.email, user_path(user) %></td>
|
||||||
<td><%= user.email %></td>
|
|
||||||
<td><%= user.status %></td>
|
<td><%= user.status %></td>
|
||||||
<td><%= user.created_at.to_fs(:db_without_sec) %></td>
|
|
||||||
<td class="svg">
|
<td class="svg">
|
||||||
<%= svg_tag "pictograms/checkbox-marked-outline" if user.confirmed_at.present? %>
|
<%= svg_tag "pictograms/checkbox-marked-outline" if user.confirmed_at.present? %>
|
||||||
</td>
|
</td>
|
||||||
|
<td><%= user.created_at.to_fs(:db_without_sec) %></td>
|
||||||
<!-- <td class="actions"></td> -->
|
<!-- <td class="actions"></td> -->
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</tbody>
|
||||||
<% end %>
|
</table>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<% content_for :navigation, flush: true do %>
|
<% content_for :navigation, flush: true do %>
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<%= image_link_to t(".back"), "arrow-left-bold-outline",
|
<%= image_link_to t(:back), "arrow-left-bold-outline",
|
||||||
request.referer.present? ? :back : root_url %>
|
request.referer.present? ? :back : root_url %>
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
@ -11,12 +11,6 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= tabular_form_for resource, url: registration_path(resource), html: {method: :patch} do |f| %>
|
<%= tabular_form_for resource, url: registration_path(resource), html: {method: :patch} do |f| %>
|
||||||
<%= f.select :status, User.statuses, readonly: !current_user.at_least(:admin) %>
|
|
||||||
|
|
||||||
<% if current_user.at_least(:admin) %>
|
|
||||||
<%= f.text_field :created_at, readonly: true, tabindex: -1 %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= f.email_field :email, size: 30, autofocus: true, autocomplete: "off" %>
|
<%= f.email_field :email, size: 30, autofocus: true, autocomplete: "off" %>
|
||||||
<% if f.object.pending_reconfirmation? %>
|
<% if f.object.pending_reconfirmation? %>
|
||||||
<%= f.text_field :unconfirmed_email, readonly: true, tabindex: -1,
|
<%= f.text_field :unconfirmed_email, readonly: true, tabindex: -1,
|
||||||
@ -24,6 +18,8 @@
|
|||||||
timestamp: f.object.confirmation_sent_at.to_fs(:db_without_sec)) %>
|
timestamp: f.object.confirmation_sent_at.to_fs(:db_without_sec)) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<%= f.select :status, User.statuses, readonly: true %>
|
||||||
|
|
||||||
<%= f.password_field :password, size: 30, autocomplete: "off",
|
<%= f.password_field :password, size: 30, autocomplete: "off",
|
||||||
hint: t('.blank_password_hint_html',
|
hint: t('.blank_password_hint_html',
|
||||||
subhint: t('.minimum_length_hint_html', count: @minimum_password_length)) %>
|
subhint: t('.minimum_length_hint_html', count: @minimum_password_length)) %>
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
<p style="color: green"><%= notice %></p>
|
<% content_for :navigation, flush: true do %>
|
||||||
|
<div class="left">
|
||||||
|
<%= image_link_to t(:back), "arrow-left-bold-outline", users_path %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%= render @user %>
|
<%= tabular_form_for @user do |f| %>
|
||||||
|
<%= f.email_field :email, readonly: true %>
|
||||||
|
<% if f.object.pending_reconfirmation? %>
|
||||||
|
<%= f.email_field :unconfirmed_email, readonly: true,
|
||||||
|
hint: t("users.registrations.edit.unconfirmed_email_hint",
|
||||||
|
timestamp: f.object.confirmation_sent_at.to_fs(:db_without_sec)) %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div>
|
<%= f.select :status, User.statuses, readonly: true %>
|
||||||
<%= link_to "Edit this user", edit_user_path(@user) %> |
|
|
||||||
<%= link_to "Back to users", users_path %>
|
|
||||||
|
|
||||||
<%= button_to "Destroy this user", @user, method: :delete %>
|
<%= f.text_field :created_at, readonly: true %>
|
||||||
</div>
|
<%= f.text_field :confirmed_at, readonly: true %>
|
||||||
|
<% end %>
|
||||||
|
@ -5,10 +5,12 @@ en:
|
|||||||
email: e-mail
|
email: e-mail
|
||||||
status: status
|
status: status
|
||||||
password: password
|
password: password
|
||||||
created_at: registration
|
created_at: registered
|
||||||
confirmed_at: confirmed
|
confirmed_at: confirmed
|
||||||
unconfirmed_email: Awaiting confirmation for
|
unconfirmed_email: Awaiting confirmation for
|
||||||
users:
|
users:
|
||||||
|
index:
|
||||||
|
become: View as...
|
||||||
passwords:
|
passwords:
|
||||||
edit:
|
edit:
|
||||||
new_password: New password
|
new_password: New password
|
||||||
@ -18,7 +20,6 @@ en:
|
|||||||
new:
|
new:
|
||||||
password_confirmation: Retype password
|
password_confirmation: Retype password
|
||||||
edit:
|
edit:
|
||||||
back: Back
|
|
||||||
confirm_delete: Are you sure you want to delete profile?
|
confirm_delete: Are you sure you want to delete profile?
|
||||||
All data will be irretrievably lost.
|
All data will be irretrievably lost.
|
||||||
delete: Delete profile
|
delete: Delete profile
|
||||||
@ -35,6 +36,7 @@ en:
|
|||||||
application:
|
application:
|
||||||
users: Users
|
users: Users
|
||||||
actions: Actions
|
actions: Actions
|
||||||
|
back: Back
|
||||||
or: or
|
or: or
|
||||||
profile: Profile
|
profile: Profile
|
||||||
register: Register
|
register: Register
|
||||||
|
@ -2,7 +2,7 @@ Rails.application.routes.draw do
|
|||||||
devise_for :users, path: '', path_names: {registration: 'profile'},
|
devise_for :users, path: '', path_names: {registration: 'profile'},
|
||||||
controllers: {registrations: :registrations}
|
controllers: {registrations: :registrations}
|
||||||
|
|
||||||
resources :users, only: [:index]
|
resources :users, only: [:index, :show]
|
||||||
|
|
||||||
devise_scope :user do
|
devise_scope :user do
|
||||||
root to: "devise/sessions#new"
|
root to: "devise/sessions#new"
|
||||||
|
@ -96,15 +96,19 @@ class UsersTest < ApplicationSystemTestCase
|
|||||||
test "show profile" do
|
test "show profile" do
|
||||||
sign_in user: users.select(&:admin?).select(&:confirmed?).sample
|
sign_in user: users.select(&:admin?).select(&:confirmed?).sample
|
||||||
click_link t('layouts.application.users')
|
click_link t('layouts.application.users')
|
||||||
#all('tr').drop(1).sample.click_link t(:view)
|
email = all('tr').drop(1).sample.first('a').text
|
||||||
|
click_link email
|
||||||
|
assert_current_path user_path(User.find_by_email!(email))
|
||||||
end
|
end
|
||||||
|
|
||||||
test "destroy profile" do
|
test "destroy profile" do
|
||||||
sign_in user: users.select(&:confirmed?).sample
|
sign_in user: users.select(&:confirmed?).sample
|
||||||
click_link t(:profile)
|
# TODO: remove condition after root changed to different path than profile
|
||||||
|
click_link t(:profile) unless has_current_path?(edit_user_registration_path)
|
||||||
assert_difference ->{ User.count }, -1 do
|
assert_difference ->{ User.count }, -1 do
|
||||||
accept_confirm { click_link t('users.registrations.edit.delete') }
|
accept_confirm { click_link t('users.registrations.edit.delete') }
|
||||||
end
|
end
|
||||||
|
assert_current_path new_user_session_path
|
||||||
end
|
end
|
||||||
|
|
||||||
test "index forbidden for non admin" do
|
test "index forbidden for non admin" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user