add archived at to accounts

pull/267/head
Pete Matsyburka 2 years ago
parent 1b2dec4c2a
commit bb613059de

@ -1,10 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
class UsersController < ApplicationController class UsersController < ApplicationController
load_and_authorize_resource :user, only: %i[index edit new update destroy] load_and_authorize_resource :user, only: %i[index edit update destroy]
before_action :build_user, only: :create before_action :build_user, only: %i[new create]
authorize_resource :user, only: :create authorize_resource :user, only: %i[new create]
def index def index
@users = @users =
@ -14,7 +14,7 @@ class UsersController < ApplicationController
@users.active @users.active
end end
@pagy, @users = pagy(@users.order(id: :desc)) @pagy, @users = pagy(@users.where(account: current_account).order(id: :desc))
end end
def new; end def new; end
@ -81,6 +81,11 @@ class UsersController < ApplicationController
end end
def user_params def user_params
params.require(:user).permit(:email, :first_name, :last_name, :password, :role, :archived_at) if params.key?(:user)
params.require(:user).permit(:email, :first_name, :last_name, :password,
:role, :archived_at, :account_id)
else
{}
end
end end
end end

@ -4,13 +4,14 @@
# #
# Table name: accounts # Table name: accounts
# #
# id :bigint not null, primary key # id :bigint not null, primary key
# locale :string not null # archived_at :datetime
# name :string not null # locale :string not null
# timezone :string not null # name :string not null
# uuid :string not null # timezone :string not null
# created_at :datetime not null # uuid :string not null
# updated_at :datetime not null # created_at :datetime not null
# updated_at :datetime not null
# #
# Indexes # Indexes
# #
@ -49,6 +50,8 @@ class Account < ApplicationRecord
attribute :timezone, :string, default: 'UTC' attribute :timezone, :string, default: 'UTC'
attribute :locale, :string, default: 'en-US' attribute :locale, :string, default: 'en-US'
scope :active, -> { where(archived_at: nil) }
def testing? def testing?
linked_account_account&.testing? linked_account_account&.testing?
end end

@ -73,7 +73,7 @@ class User < ApplicationRecord
end end
def active_for_authentication? def active_for_authentication?
super && !archived_at? super && !archived_at? && !account.archived_at?
end end
def remember_me def remember_me

@ -37,11 +37,17 @@
<%= link_to 'E-Signature', settings_esign_path, class: 'text-base hover:bg-base-300' %> <%= link_to 'E-Signature', settings_esign_path, class: 'text-base hover:bg-base-300' %>
</li> </li>
<% end %> <% end %>
<% if can?(:read, AccountConfig) %>
<li>
<%= link_to 'Personalization', settings_personalization_path, class: 'text-base hover:bg-base-300' %>
</li>
<% end %>
<% if can?(:read, User) %> <% if can?(:read, User) %>
<li> <li>
<%= link_to 'Users', settings_users_path, class: 'text-base hover:bg-base-300' %> <%= link_to 'Users', settings_users_path, class: 'text-base hover:bg-base-300' %>
</li> </li>
<% end %> <% end %>
<%= render 'shared/settings_nav_extra' %>
<% if Docuseal.demo? || !Docuseal.multitenant? %> <% if Docuseal.demo? || !Docuseal.multitenant? %>
<% if can?(:read, AccessToken) %> <% if can?(:read, AccessToken) %>
<li> <li>
@ -54,12 +60,6 @@
</li> </li>
<% end %> <% end %>
<% end %> <% end %>
<% if can?(:read, AccountConfig) %>
<li>
<%= link_to 'Personalization', settings_personalization_path, class: 'text-base hover:bg-base-300' %>
</li>
<% end %>
<%= render 'shared/settings_nav_extra' %>
<% if !Docuseal.demo? && can?(:manage, EncryptedConfig) && (current_user != true_user || !current_account.testing?) %> <% if !Docuseal.demo? && can?(:manage, EncryptedConfig) && (current_user != true_user || !current_account.testing?) %>
<li> <li>
<%= link_to Docuseal.multitenant? ? console_redirect_index_path(redir: "#{Docuseal::CONSOLE_URL}/plans") : "#{Docuseal::CLOUD_URL}/sign_up?#{{ redir: "#{Docuseal::CONSOLE_URL}/on_premise" }.to_query}", class: 'text-base hover:bg-base-300', data: { prefetch: false } do %> <%= link_to Docuseal.multitenant? ? console_redirect_index_path(redir: "#{Docuseal::CONSOLE_URL}/plans") : "#{Docuseal::CLOUD_URL}/sign_up?#{{ redir: "#{Docuseal::CONSOLE_URL}/on_premise" }.to_query}", class: 'text-base hover:bg-base-300', data: { prefetch: false } do %>

@ -0,0 +1,7 @@
# frozen_string_literal: true
class AddArchivedAtToAccounts < ActiveRecord::Migration[7.1]
def change
add_column :accounts, :archived_at, :datetime
end
end

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_04_16_170023) do ActiveRecord::Schema[7.1].define(version: 2024_04_28_072623) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@ -52,6 +52,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_04_16_170023) do
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "uuid", null: false t.string "uuid", null: false
t.datetime "archived_at"
t.index ["uuid"], name: "index_accounts_on_uuid", unique: true t.index ["uuid"], name: "index_accounts_on_uuid", unique: true
end end

Loading…
Cancel
Save