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;
|
||||
margin: 1rem auto 0 auto;
|
||||
}
|
||||
table.items th {
|
||||
table.items thead {
|
||||
font-size: 0.8rem;
|
||||
line-height: 2.2rem;
|
||||
}
|
||||
table.items th,
|
||||
table.items tr:hover {
|
||||
table.items thead,
|
||||
table.items tbody tr:hover {
|
||||
background-color: #f3f3f3;
|
||||
}
|
||||
table.items th,
|
||||
table.items td:not(.svg):not(.actions) {
|
||||
padding: 0.8rem;
|
||||
table.items td:not(:first-child):not(.actions) {
|
||||
padding: 0 0.8rem;
|
||||
text-align: center;
|
||||
}
|
||||
table.items td {
|
||||
border-top: 1px solid #dddddd;
|
||||
line-height: 2.5rem;
|
||||
padding: 0;
|
||||
}
|
||||
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;
|
||||
color: #909090;
|
||||
font-weight: normal;
|
||||
margin-right: 0.25rem;
|
||||
padding: 0.25rem;
|
||||
}
|
||||
table.items td:not(:first-child) {
|
||||
color: #909090;
|
||||
fill: #909090;
|
||||
text-align: center;
|
||||
}
|
||||
table.items td.actions {
|
||||
text-align: right;
|
||||
}
|
||||
table.items svg {
|
||||
height: 1.2rem;
|
||||
vertical-align: middle;
|
||||
width: 1.2rem;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
class UsersController < ApplicationController
|
||||
before_action :find_user, only: [:destroy]
|
||||
before_action :find_user, only: [:show]
|
||||
before_action do
|
||||
raise AccessForbidden unless current_user.at_least(:admin)
|
||||
end
|
||||
@ -8,9 +8,11 @@ class UsersController < ApplicationController
|
||||
@users = User.all
|
||||
end
|
||||
|
||||
# TODO: add #show and #update to change user status
|
||||
# TODO: remove admin dependent fields from registrations#edit and move them to
|
||||
# #show
|
||||
def show
|
||||
end
|
||||
|
||||
# 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
|
||||
# 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">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= User.human_attribute_name(:email).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(:created_at).capitalize %> <sup>UTC</sup></th>
|
||||
<!-- <th><%#= t :actions %></th> -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<%# TODO: add user show link %>
|
||||
<td><%= user.email %></td>
|
||||
<td><%= link_to user.email, user_path(user) %></td>
|
||||
<td><%= user.status %></td>
|
||||
<td><%= user.created_at.to_fs(:db_without_sec) %></td>
|
||||
<td class="svg">
|
||||
<%= svg_tag "pictograms/checkbox-marked-outline" if user.confirmed_at.present? %>
|
||||
</td>
|
||||
<td><%= user.created_at.to_fs(:db_without_sec) %></td>
|
||||
<!-- <td class="actions"></td> -->
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<% content_for :navigation, flush: true do %>
|
||||
<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 %>
|
||||
</div>
|
||||
<div class="right">
|
||||
@ -11,12 +11,6 @@
|
||||
<% end %>
|
||||
|
||||
<%= 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" %>
|
||||
<% if f.object.pending_reconfirmation? %>
|
||||
<%= f.text_field :unconfirmed_email, readonly: true, tabindex: -1,
|
||||
@ -24,6 +18,8 @@
|
||||
timestamp: f.object.confirmation_sent_at.to_fs(:db_without_sec)) %>
|
||||
<% end %>
|
||||
|
||||
<%= f.select :status, User.statuses, readonly: true %>
|
||||
|
||||
<%= f.password_field :password, size: 30, autocomplete: "off",
|
||||
hint: t('.blank_password_hint_html',
|
||||
subhint: t('.minimum_length_hint_html', count: @minimum_password_length)) %>
|
||||
|
@ -1,10 +1,19 @@
|
||||
<p style="color: green"><%= notice %></p>
|
||||
|
||||
<%= render @user %>
|
||||
|
||||
<div>
|
||||
<%= link_to "Edit this user", edit_user_path(@user) %> |
|
||||
<%= link_to "Back to users", users_path %>
|
||||
|
||||
<%= button_to "Destroy this user", @user, method: :delete %>
|
||||
<% content_for :navigation, flush: true do %>
|
||||
<div class="left">
|
||||
<%= image_link_to t(:back), "arrow-left-bold-outline", users_path %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= 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 %>
|
||||
|
||||
<%= f.select :status, User.statuses, readonly: true %>
|
||||
|
||||
<%= f.text_field :created_at, readonly: true %>
|
||||
<%= f.text_field :confirmed_at, readonly: true %>
|
||||
<% end %>
|
||||
|
@ -5,10 +5,12 @@ en:
|
||||
email: e-mail
|
||||
status: status
|
||||
password: password
|
||||
created_at: registration
|
||||
created_at: registered
|
||||
confirmed_at: confirmed
|
||||
unconfirmed_email: Awaiting confirmation for
|
||||
users:
|
||||
index:
|
||||
become: View as...
|
||||
passwords:
|
||||
edit:
|
||||
new_password: New password
|
||||
@ -18,7 +20,6 @@ en:
|
||||
new:
|
||||
password_confirmation: Retype password
|
||||
edit:
|
||||
back: Back
|
||||
confirm_delete: Are you sure you want to delete profile?
|
||||
All data will be irretrievably lost.
|
||||
delete: Delete profile
|
||||
@ -35,6 +36,7 @@ en:
|
||||
application:
|
||||
users: Users
|
||||
actions: Actions
|
||||
back: Back
|
||||
or: or
|
||||
profile: Profile
|
||||
register: Register
|
||||
|
@ -2,7 +2,7 @@ Rails.application.routes.draw do
|
||||
devise_for :users, path: '', path_names: {registration: 'profile'},
|
||||
controllers: {registrations: :registrations}
|
||||
|
||||
resources :users, only: [:index]
|
||||
resources :users, only: [:index, :show]
|
||||
|
||||
devise_scope :user do
|
||||
root to: "devise/sessions#new"
|
||||
|
@ -96,15 +96,19 @@ class UsersTest < ApplicationSystemTestCase
|
||||
test "show profile" do
|
||||
sign_in user: users.select(&:admin?).select(&:confirmed?).sample
|
||||
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
|
||||
|
||||
test "destroy profile" do
|
||||
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
|
||||
accept_confirm { click_link t('users.registrations.edit.delete') }
|
||||
end
|
||||
assert_current_path new_user_session_path
|
||||
end
|
||||
|
||||
test "index forbidden for non admin" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user