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
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
authorize_resource :user, only: :create
before_action :build_user, only: %i[new create]
authorize_resource :user, only: %i[new create]
def index
@users =
@ -14,7 +14,7 @@ class UsersController < ApplicationController
@users.active
end
@pagy, @users = pagy(@users.order(id: :desc))
@pagy, @users = pagy(@users.where(account: current_account).order(id: :desc))
end
def new; end
@ -81,6 +81,11 @@ class UsersController < ApplicationController
end
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

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

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

@ -37,11 +37,17 @@
<%= link_to 'E-Signature', settings_esign_path, class: 'text-base hover:bg-base-300' %>
</li>
<% 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) %>
<li>
<%= link_to 'Users', settings_users_path, class: 'text-base hover:bg-base-300' %>
</li>
<% end %>
<%= render 'shared/settings_nav_extra' %>
<% if Docuseal.demo? || !Docuseal.multitenant? %>
<% if can?(:read, AccessToken) %>
<li>
@ -54,12 +60,6 @@
</li>
<% 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?) %>
<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 %>

@ -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.
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
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 "updated_at", null: false
t.string "uuid", null: false
t.datetime "archived_at"
t.index ["uuid"], name: "index_accounts_on_uuid", unique: true
end

Loading…
Cancel
Save