View and search users from admin panel
This commit is contained in:
16
app/controllers/admin/users_controller.rb
Normal file
16
app/controllers/admin/users_controller.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class Admin::UsersController < Admin::BaseController
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
if params[:search]
|
||||
s = params[:search]
|
||||
@users = User.where("username ILIKE ? OR email ILIKE ? OR document_number ILIKE ?", "%#{s}%","%#{s}%","%#{s}%").page(params[:page])
|
||||
else
|
||||
@users = @users.page(params[:page])
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -29,7 +29,7 @@ module AdminHelper
|
||||
end
|
||||
|
||||
def menu_profiles?
|
||||
["administrators", "organizations", "officials", "moderators", "valuators", "managers"].include? controller_name
|
||||
["administrators", "organizations", "officials", "moderators", "valuators", "managers", "users"].include? controller_name
|
||||
end
|
||||
|
||||
def menu_banners?
|
||||
|
||||
@@ -38,6 +38,7 @@ module Abilities
|
||||
can [:search, :create, :index, :destroy], ::Moderator
|
||||
can [:search, :create, :index, :summary], ::Valuator
|
||||
can [:search, :create, :index, :destroy], ::Manager
|
||||
can [:search, :index], ::User
|
||||
|
||||
can :manage, Annotation
|
||||
|
||||
|
||||
@@ -118,6 +118,10 @@
|
||||
<li <%= "class=active" if controller_name == "managers" %>>
|
||||
<%= link_to t('admin.menu.managers'), admin_managers_path %>
|
||||
</li>
|
||||
|
||||
<li <%= 'class=active' if controller_name == 'users' %>>
|
||||
<%= link_to t('admin.menu.users'), admin_users_path %>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
22
app/views/admin/users/_users.html.erb
Normal file
22
app/views/admin/users/_users.html.erb
Normal file
@@ -0,0 +1,22 @@
|
||||
<h3><%= page_entries_info @users %></h3>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t('admin.users.fields.name') %></th>
|
||||
<th><%= t('admin.users.fields.email') %></th>
|
||||
<th><%= t('admin.users.fields.document_number') %></th>
|
||||
<th><%= t('admin.users.fields.verification_level') %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.name %></td>
|
||||
<td><%= user.email %></td>
|
||||
<td><%= user.document_number %></td>
|
||||
<td><%= user.user_type %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<%= paginate @users %>
|
||||
16
app/views/admin/users/index.html.erb
Normal file
16
app/views/admin/users/index.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<h2><%= t("admin.users.index.title") %></h2>
|
||||
|
||||
<div class="row">
|
||||
<%= form_tag admin_users_path, method: :get, remote: true do %>
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= text_field_tag :search, '', placeholder: t('admin.users.search.placeholder') %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= submit_tag t('admin.users.search.search'), class: 'button' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="users">
|
||||
<%= render "users" %>
|
||||
</div>
|
||||
1
app/views/admin/users/index.js.erb
Normal file
1
app/views/admin/users/index.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$("#users").html("<%= j render 'users' %>");
|
||||
Reference in New Issue
Block a user