mirror of https://github.com/docusealco/docuseal
parent
f89c50d096
commit
2f1843151d
@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApiSettingsController < ApplicationController
|
||||
def index; end
|
||||
def index
|
||||
authorize!(:read, current_user.access_token)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SmsSettingsController < ApplicationController
|
||||
before_action :load_encrypted_config
|
||||
authorize_resource :encrypted_config, only: :index
|
||||
authorize_resource :encrypted_config, parent: false, except: :index
|
||||
|
||||
def index; end
|
||||
|
||||
private
|
||||
|
||||
def load_encrypted_config
|
||||
@encrypted_config =
|
||||
EncryptedConfig.find_or_initialize_by(account: current_account, key: 'sms_configs')
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,18 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SubmittersSendEmailController < ApplicationController
|
||||
def create
|
||||
submitter = Submitter.joins(:template)
|
||||
.where(template: { account_id: current_account.id })
|
||||
.find_by!(slug: params[:submitter_slug])
|
||||
load_and_authorize_resource :submitter, id_param: :submitter_slug, find_by: :slug
|
||||
|
||||
SubmitterMailer.invitation_email(submitter).deliver_later!
|
||||
def create
|
||||
SubmitterMailer.invitation_email(@submitter).deliver_later!
|
||||
|
||||
SubmissionEvent.create!(submitter:, event_type: 'send_email')
|
||||
SubmissionEvent.create!(submitter: @submitter, event_type: 'send_email')
|
||||
|
||||
submitter.sent_at ||= Time.current
|
||||
submitter.save!
|
||||
@submitter.sent_at ||= Time.current
|
||||
@submitter.save!
|
||||
|
||||
redirect_back(fallback_location: submission_path(submitter.submission), notice: 'Email has been sent')
|
||||
redirect_back(fallback_location: submission_path(@submitter.submission), notice: 'Email has been sent')
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TemplatesArchivedController < ApplicationController
|
||||
load_and_authorize_resource :template, parent: false
|
||||
|
||||
def index
|
||||
templates = current_account.templates.where.not(deleted_at: nil).preload(:author).order(id: :desc)
|
||||
templates = Templates.search(templates, params[:q])
|
||||
@templates = @templates.where.not(deleted_at: nil).preload(:author).order(id: :desc)
|
||||
@templates = Templates.search(@templates, params[:q])
|
||||
|
||||
@pagy, @templates = pagy(templates, items: 12)
|
||||
@pagy, @templates = pagy(@templates, items: 12)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TemplatesRestoreController < ApplicationController
|
||||
def create
|
||||
template = current_account.templates.find(params[:template_id])
|
||||
load_and_authorize_resource :template
|
||||
|
||||
template.update!(deleted_at: nil)
|
||||
def create
|
||||
@template.update!(deleted_at: nil)
|
||||
|
||||
redirect_to template_path(template), notice: 'Template has been unarchived'
|
||||
redirect_to template_path(@template), notice: 'Template has been unarchived'
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TemplatesUploadsController < ApplicationController
|
||||
load_and_authorize_resource :template, parent: false
|
||||
|
||||
def create
|
||||
template = current_account.templates.new(author: current_user)
|
||||
template.name = File.basename(params[:files].first.original_filename, '.*')
|
||||
@template.author = current_user
|
||||
@template.name = File.basename(params[:files].first.original_filename, '.*')
|
||||
|
||||
template.save!
|
||||
@template.save!
|
||||
|
||||
documents = Templates::CreateAttachments.call(template, params)
|
||||
documents = Templates::CreateAttachments.call(@template, params)
|
||||
|
||||
schema = documents.map { |doc| { attachment_uuid: doc.uuid, name: doc.filename.base } }
|
||||
|
||||
template.update!(schema:)
|
||||
@template.update!(schema:)
|
||||
|
||||
redirect_to edit_template_path(template)
|
||||
redirect_to edit_template_path(@template)
|
||||
end
|
||||
end
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
<div class="form-control">
|
||||
<%= f.label :role, class: 'label' %>
|
||||
<%= f.select :role, nil, {}, class: 'base-select' do %>
|
||||
<option value="admin">Admin</option>
|
||||
<option value="editor" disabled>Editor</option>
|
||||
<option value="viewer" disabled>Viewer</option>
|
||||
<% end %>
|
||||
<a class="text-sm mt-3 px-4 py-2 bg-base-300 rounded-full block" target="_blank" href="<%= "#{Docuseal::CONSOLE_URL}/#{Docuseal.multitenant? ? 'plans' : 'on_premise'}" %>">
|
||||
<%= svg_icon('info_circle', class: 'w-4 h-4 inline align-text-bottom') %>
|
||||
Unlock more user roles with DocuSeal Enterprise.
|
||||
<span class="link font-medium">Learn More</a>
|
||||
</a>
|
||||
</div>
|
||||
@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Ability
|
||||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
can :manage, Template, account_id: user.account_id
|
||||
can :manage, Submission, template: { account_id: user.account_id }
|
||||
can :manage, Submitter, template: { account_id: user.account_id }
|
||||
can :manage, User, account_id: user.account_id
|
||||
can :manage, EncryptedConfig, account_id: user.account_id
|
||||
can :manage, AccountConfig, account_id: user.account_id
|
||||
can :manage, Account, id: user.account_id
|
||||
can :manage, AccessToken, user_id: user.id
|
||||
end
|
||||
end
|
||||
Loading…
Reference in new issue