implement amendment signing
This commit is contained in:
44
app/controllers/public/amendments_controller.rb
Normal file
44
app/controllers/public/amendments_controller.rb
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
class Public::AmendmentsController < Public::BaseController
|
||||||
|
skip_after_action :verify_authorized, :verify_policy_scoped
|
||||||
|
before_action :set_account, :set_project, :set_contract_template, :set_release
|
||||||
|
|
||||||
|
def new
|
||||||
|
if @release.amendment_signed?
|
||||||
|
render :create, locals: { already_signed: true }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@release.amendment_signer_name = release_params[:amendment_signer_name]
|
||||||
|
@release.amendment_signature_base64 = release_params[:amendment_signature_base64]
|
||||||
|
render :new unless @release.save
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def release_params
|
||||||
|
release_type = @contract_template.release_type
|
||||||
|
param_name = "#{release_type}_release".to_s
|
||||||
|
params.require(param_name).permit(:amendment_signer_name, :amendment_signature_base64)
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_release
|
||||||
|
release_type = @contract_template.release_type
|
||||||
|
param_name = "#{release_type}_release_id".to_s
|
||||||
|
release_id = params[param_name]
|
||||||
|
|
||||||
|
@release = @contract_template.releases.find(release_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_contract_template
|
||||||
|
@contract_template = @project.contract_templates.find(params[:contract_template_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_project
|
||||||
|
@project = @account.projects.find(params[:project_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_account
|
||||||
|
@account = Account.find_by(slug: params[:account_id])
|
||||||
|
end
|
||||||
|
end
|
||||||
27
app/models/concerns/amendmenable.rb
Normal file
27
app/models/concerns/amendmenable.rb
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
module Amendmenable
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
include ActiveStorageSupport::SupportForBase64
|
||||||
|
|
||||||
|
has_one_base64_attached :amendment_signature
|
||||||
|
end
|
||||||
|
|
||||||
|
def amendment_signable?
|
||||||
|
contract_template.amendment_clause.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def amendment_signed?
|
||||||
|
amendment_signature.attached?
|
||||||
|
end
|
||||||
|
|
||||||
|
def amendment_signature_base64
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def amendment_signature_base64=(data_uri)
|
||||||
|
return if data_uri.blank?
|
||||||
|
|
||||||
|
amendment_signature.attach(data: data_uri, filename: "amendment_signature.png", content_type: "image/png", identify: "false")
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -12,6 +12,7 @@ class LocationRelease < ApplicationRecord
|
|||||||
include PersonName
|
include PersonName
|
||||||
include CsvExportable
|
include CsvExportable
|
||||||
include Approvable
|
include Approvable
|
||||||
|
include Amendmenable
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def custom_csv_exportable_headers
|
def custom_csv_exportable_headers
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ class LocationReleasePolicy < ReleasePolicy
|
|||||||
user.account_manager?
|
user.account_manager?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sign_amendment?
|
||||||
|
user.manager? || user.account_manager?
|
||||||
|
end
|
||||||
|
|
||||||
def approve?
|
def approve?
|
||||||
review?
|
review?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,6 +30,15 @@
|
|||||||
<td>
|
<td>
|
||||||
<%= location_release.signed_on %>
|
<%= location_release.signed_on %>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<% if location_release.amendment_signed? %>
|
||||||
|
<i class="fa fa-check-square-o text-dark"
|
||||||
|
data-toggle="tooltip"
|
||||||
|
title="<%= t '.messages.amendment_signed_tooltip' %>"></i>
|
||||||
|
<% else %>
|
||||||
|
<i class="fa fa-square-o"></i>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
@@ -44,6 +53,9 @@
|
|||||||
<% if policy(location_release).edit_photos? %>
|
<% if policy(location_release).edit_photos? %>
|
||||||
<%= link_to fa_icon("picture-o fw", text: "Photos"), [:edit, location_release, :photos], class: "dropdown-item" %>
|
<%= link_to fa_icon("picture-o fw", text: "Photos"), [:edit, location_release, :photos], class: "dropdown-item" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if policy(location_release).sign_amendment? && location_release.amendment_signable? && !location_release.amendment_signed? %>
|
||||||
|
<%= link_to fa_icon("file-text fw", text: t('.actions.sign_amendment')), [:new, location_release.project.account, location_release.project, location_release.contract_template, location_release, :amendment], class: "dropdown-item", target: "_blank" %>
|
||||||
|
<% end %>
|
||||||
<% if policy(Contract).show? && (location_release.contract.attached? || location_release.contract_template.present?) %>
|
<% if policy(Contract).show? && (location_release.contract.attached? || location_release.contract_template.present?) %>
|
||||||
<%= link_to fa_icon("download fw", text: "Download"), [location_release, :contracts, format: "pdf"], class: "dropdown-item", target: "_blank" %>
|
<%= link_to fa_icon("download fw", text: "Download"), [location_release, :contracts, format: "pdf"], class: "dropdown-item", target: "_blank" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -32,8 +32,8 @@
|
|||||||
<th><%= t(".table_headers.address") %>
|
<th><%= t(".table_headers.address") %>
|
||||||
<th><%= t(".table_headers.notes") %></th>
|
<th><%= t(".table_headers.notes") %></th>
|
||||||
<th><%= t(".table_headers.tags") %></th>
|
<th><%= t(".table_headers.tags") %></th>
|
||||||
<th><%= t(".table_headers.signed_at") %></th>
|
<th><%= t(".table_headers.signed_at") %></th>
|
||||||
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|||||||
3
app/views/public/amendments/create.html.erb
Normal file
3
app/views/public/amendments/create.html.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<% message = local_assigns[:already_signed] ? t('.amendment_already_signed_message') : t('.amendment_signed_message') %>
|
||||||
|
<% alert_type = local_assigns[:already_signed] ? "alert-warning" : "alert-success" %>
|
||||||
|
<p class="alert <%= alert_type %> p-3 lead text-center"><%= message %></p>
|
||||||
24
app/views/public/amendments/new.html.erb
Normal file
24
app/views/public/amendments/new.html.erb
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<div class="card shadow-sm">
|
||||||
|
<div class="card-body">
|
||||||
|
<%= errors_summary_for @release %>
|
||||||
|
<%= bootstrap_form_with model: @release, method: :post, url: public_send("account_project_contract_template_#{@contract_template.release_type}_release_amendments_path"), local: true do |form| %>
|
||||||
|
<%= card_field_set_tag t(".amendment.heading") do %>
|
||||||
|
<p><%= @contract_template.amendment_clause %></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<%= form.text_field :amendment_signer_name, required: true, wrapper_class: "col-sm-6" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= card_field_set_tag t(".signature.heading") do %>
|
||||||
|
<%= render "shared/signature_fields", signature_field: :amendment_signature_base64, form: form %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="mt-5">
|
||||||
|
<%= form.button t("shared.submit_release_long"), class: "btn btn-block btn-lg btn-success", data: { disable_with: t("shared.disable_with") } %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<% signature_field = local_assigns[:signature_field] ? local_assigns[:signature_field] : :signature_base64 %>
|
||||||
<canvas class="border bg-light w-100" data-behavior="digital-signature" data-signature-input="[data-ujs-target=signature-input]" style="height: 150px"></canvas>
|
<canvas class="border bg-light w-100" data-behavior="digital-signature" data-signature-input="[data-ujs-target=signature-input]" style="height: 150px"></canvas>
|
||||||
|
|
||||||
<% if local_assigns[:instruction] %>
|
<% if local_assigns[:instruction] %>
|
||||||
@@ -6,7 +7,7 @@
|
|||||||
</small>
|
</small>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= form.hidden_field :signature_base64, data: { ujs_target: "signature-input" } %>
|
<%= form.hidden_field signature_field, data: { ujs_target: "signature-input" } %>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<%= button_tag class: "btn btn-sm btn-danger", data: { behavior: "clear-digital-signature" } do %>
|
<%= button_tag class: "btn btn-sm btn-danger", data: { behavior: "clear-digital-signature" } do %>
|
||||||
<%= fa_icon "refresh" %> <%= t "shared.clear" %>
|
<%= fa_icon "refresh" %> <%= t "shared.clear" %>
|
||||||
|
|||||||
@@ -781,7 +781,9 @@ en:
|
|||||||
actions:
|
actions:
|
||||||
manage: Manage
|
manage: Manage
|
||||||
review: Review
|
review: Review
|
||||||
|
sign_amendment: Sign Amendment
|
||||||
messages:
|
messages:
|
||||||
|
amendment_signed_tooltip: Amendment Signed
|
||||||
approved_tooltip: Approved by %{user} on %{timestamp}
|
approved_tooltip: Approved by %{user} on %{timestamp}
|
||||||
no_photos: Needs Photo
|
no_photos: Needs Photo
|
||||||
new:
|
new:
|
||||||
@@ -1028,6 +1030,15 @@ en:
|
|||||||
heading: Licensor/Owner Contact Information
|
heading: Licensor/Owner Contact Information
|
||||||
signature:
|
signature:
|
||||||
heading: Signature
|
heading: Signature
|
||||||
|
amendments:
|
||||||
|
create:
|
||||||
|
amendment_already_signed_message: Release amendment is already signed!
|
||||||
|
amendment_signed_message: Release amendment signed successfully! Thank you
|
||||||
|
new:
|
||||||
|
amendment:
|
||||||
|
heading: Amendment
|
||||||
|
signature:
|
||||||
|
heading: Signature
|
||||||
appearance_releases:
|
appearance_releases:
|
||||||
create:
|
create:
|
||||||
notice: Your release has been signed. Thank you!
|
notice: Your release has been signed. Thank you!
|
||||||
|
|||||||
@@ -339,6 +339,11 @@ es:
|
|||||||
notes: Notes (ES)
|
notes: Notes (ES)
|
||||||
signed_at: Date Signed (ES)
|
signed_at: Date Signed (ES)
|
||||||
tags: Tags (ES)
|
tags: Tags (ES)
|
||||||
|
location_release:
|
||||||
|
actions:
|
||||||
|
sign_amendment: Sign Amendment (ES)
|
||||||
|
messages:
|
||||||
|
amendment_signed_tooltip: Amendment Signed (ES)
|
||||||
material_releases:
|
material_releases:
|
||||||
form:
|
form:
|
||||||
photos:
|
photos:
|
||||||
@@ -385,6 +390,15 @@ es:
|
|||||||
signed_at: Date Signed (ES)
|
signed_at: Date Signed (ES)
|
||||||
tags: Tags (ES)
|
tags: Tags (ES)
|
||||||
public:
|
public:
|
||||||
|
amendments:
|
||||||
|
create:
|
||||||
|
amendment_already_signed_message: Release amendment is already signed! (ES)
|
||||||
|
amendment_signed_message: Release amendment signed successfully! Thank you (ES)
|
||||||
|
new:
|
||||||
|
amendment:
|
||||||
|
heading: Amendment
|
||||||
|
signature:
|
||||||
|
heading: Signature (ES)
|
||||||
appearance_releases:
|
appearance_releases:
|
||||||
create:
|
create:
|
||||||
notice: La autorización está firmada. ¡Gracias!
|
notice: La autorización está firmada. ¡Gracias!
|
||||||
|
|||||||
@@ -128,7 +128,9 @@ Rails.application.routes.draw do
|
|||||||
resources :talent_releases, only: [:new, :create]
|
resources :talent_releases, only: [:new, :create]
|
||||||
resources :appearance_releases, only: [:new, :create]
|
resources :appearance_releases, only: [:new, :create]
|
||||||
resources :acquired_media_releases, only: [:new, :create]
|
resources :acquired_media_releases, only: [:new, :create]
|
||||||
resources :location_releases, only: [:new, :create]
|
resources :location_releases, only: [:new, :create] do
|
||||||
|
resources :amendments, only: [:new, :create]
|
||||||
|
end
|
||||||
resources :material_releases, only: [:new, :create]
|
resources :material_releases, only: [:new, :create]
|
||||||
resources :medical_releases, only: [:new, :create]
|
resources :medical_releases, only: [:new, :create]
|
||||||
resources :misc_releases, only: [:new, :create]
|
resources :misc_releases, only: [:new, :create]
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddAmendmentSignerDetailsToLocationReleases < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
add_column :location_releases, :amendment_signer_name, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user