add users count

pull/289/head
Pete Matsyburka 1 year ago
parent 9866e5468c
commit e8c2316bb2

@ -9,6 +9,8 @@ class ConsoleRedirectController < ApplicationController
params[:redir] = Docuseal.multitenant? ? "#{Docuseal::CONSOLE_URL}/plans" : "#{Docuseal::CONSOLE_URL}/on_premise"
end
params[:redir] = "#{Docuseal::CONSOLE_URL}/manage" if request.path == '/manage'
return redirect_to(new_user_session_path({ redir: params[:redir] }.compact)) if true_user.blank?
auth = JsonWebToken.encode(uuid: true_user.uuid,

@ -5,9 +5,16 @@
<h1 class="text-4xl font-bold"><%= params[:status].to_s.titleize %> Users</h1>
<div class="flex items-center space-x-4">
<% if can?(:create, User.new(account: current_account)) %>
<%= link_to new_user_path, class: 'btn btn-primary btn-md gap-2', data: { turbo_frame: 'modal' } do %>
<%= svg_icon('plus', class: 'w-6 h-6') %>
<span>New User</span>
<% if Docuseal.multitenant? %>
<%= render 'users/extra_buttons' %>
<% end %>
<% if content_for(:add_user_button) %>
<%= content_for(:add_user_button) %>
<% else %>
<%= link_to new_user_path, class: "btn btn-primary btn-md gap-2", data: { turbo_frame: 'modal' } do %>
<%= svg_icon('plus', class: 'w-6 h-6') %>
<span>New User</span>
<% end %>
<% end %>
<% end %>
</div>

@ -55,6 +55,7 @@ Rails.application.routes.draw do
resources :submissions, only: %i[show destroy]
resources :console_redirect, only: %i[index]
resources :upgrade, only: %i[index], controller: 'console_redirect'
resources :manage, only: %i[index], controller: 'console_redirect'
resource :testing_account, only: %i[show destroy]
resources :testing_api_settings, only: %i[index]
resources :submitters_autocomplete, only: %i[index]

@ -31,6 +31,17 @@ module Accounts
new_account
end
def users_count(account)
rel = User.where(account_id: account.id).or(
User.where(account_id: account.account_linked_accounts
.where.not(account_type: :testing)
.select(:linked_account_id))
)
rel.where.not(account: account.linked_accounts.where.not(archived_at: nil))
.where.not(role: :integration).active.count
end
def find_or_create_testing_user(account)
user = User.where(role: :admin).order(:id).find_by(account: account.testing_accounts)

Loading…
Cancel
Save