Upstream sync
This commit is contained in:
@@ -51,10 +51,8 @@ $(document).on("turbolinks:load", function() {
|
||||
$("[data-behavior=guardian-photo-preview]").each(function(index, element) {
|
||||
App.PhotoPreview.init(element);
|
||||
});
|
||||
$("[data-behavior=take-person-photo]").click(function(e) {
|
||||
$("[data-ujs-target=person-photo-input]").trigger("click");
|
||||
});
|
||||
$("[data-behavior=take-guardian-photo]").click(function(e) {
|
||||
$("[data-ujs-target=guardian-photo-input]").trigger("click");
|
||||
$("[data-behavior=trigger-click]").click(function(e) {
|
||||
const target = $(this).data("target");
|
||||
$(target).trigger("click");
|
||||
});
|
||||
});
|
||||
|
||||
13
app/controllers/concerns/misc_release_context.rb
Normal file
13
app/controllers/concerns/misc_release_context.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
module MiscReleaseContext
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def misc_releases
|
||||
policy_scope(MiscRelease)
|
||||
end
|
||||
|
||||
def set_misc_release
|
||||
misc_release_id = params[:misc_release_id] || params[:id]
|
||||
|
||||
@misc_release = authorize misc_releases.find(misc_release_id)
|
||||
end
|
||||
end
|
||||
40
app/controllers/misc_releases_controller.rb
Normal file
40
app/controllers/misc_releases_controller.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
class MiscReleasesController < ApplicationController
|
||||
include ProjectContext, MiscReleaseContext
|
||||
|
||||
before_action :set_project, only: [:index]
|
||||
before_action :set_misc_release, only: [:destroy]
|
||||
|
||||
include ProjectLayout
|
||||
|
||||
def index
|
||||
@misc_releases = filtered_misc_releases.order_by_recent.paginate(page: params[:page])
|
||||
end
|
||||
|
||||
def destroy
|
||||
@project = @misc_release.project
|
||||
|
||||
if @misc_release.destroy
|
||||
redirect_to [@project, :misc_releases], alert: t(".alert")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def misc_releases
|
||||
if @project
|
||||
policy_scope(@project.misc_releases)
|
||||
else
|
||||
policy_scope(MiscRelease)
|
||||
end
|
||||
end
|
||||
|
||||
def filtered_misc_releases
|
||||
results = misc_releases
|
||||
|
||||
if params[:query].present?
|
||||
results = results.search(params[:query])
|
||||
end
|
||||
|
||||
results
|
||||
end
|
||||
end
|
||||
@@ -71,8 +71,25 @@ class Public::AppearanceReleasesController < Public::BaseController
|
||||
]
|
||||
end
|
||||
|
||||
def second_guardian_params
|
||||
%i[
|
||||
guardian_2_first_name
|
||||
guardian_2_last_name
|
||||
guardian_2_phone
|
||||
guardian_2_email
|
||||
guardian_2_photo
|
||||
guardian_2_address_street1
|
||||
guardian_2_address_street2
|
||||
guardian_2_address_city
|
||||
guardian_2_address_state
|
||||
guardian_2_address_zip
|
||||
guardian_2_address_country
|
||||
]
|
||||
end
|
||||
|
||||
def appearance_release_params
|
||||
params.require(:appearance_release).permit(person_params, guardian_params,
|
||||
second_guardian_params,
|
||||
:minor, :signature_base64,
|
||||
:person_date_of_birth,
|
||||
:locale, :contract_template)
|
||||
|
||||
99
app/controllers/public/misc_releases_controller.rb
Normal file
99
app/controllers/public/misc_releases_controller.rb
Normal file
@@ -0,0 +1,99 @@
|
||||
class Public::MiscReleasesController < Public::BaseController
|
||||
before_action :set_account, :set_project, :set_contract_template
|
||||
|
||||
def new
|
||||
@misc_release = build_misc_release
|
||||
end
|
||||
|
||||
def create
|
||||
@misc_release = build_misc_release(misc_release_params_with_locale_and_contract_template)
|
||||
|
||||
if @misc_release.save(context: :native)
|
||||
if @misc_release.contract_template.present?
|
||||
AttachContractToReleasableJob.perform_later(@misc_release)
|
||||
end
|
||||
log_create_analytics
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_project
|
||||
@project = @account.projects.find(params[:project_id])
|
||||
end
|
||||
|
||||
def set_account
|
||||
@account = Account.find_by(slug: params[:account_id])
|
||||
end
|
||||
|
||||
def set_contract_template
|
||||
@contract_template = @project.contract_templates.find(params[:contract_template_id])
|
||||
end
|
||||
|
||||
def misc_releases
|
||||
policy_scope(@project.misc_releases)
|
||||
end
|
||||
|
||||
def build_misc_release(params = {})
|
||||
authorize misc_releases.build(params)
|
||||
end
|
||||
|
||||
def misc_release_params
|
||||
params
|
||||
.require(:misc_release)
|
||||
.permit(
|
||||
person_params,
|
||||
guardian_params,
|
||||
:signature_base64,
|
||||
:locale,
|
||||
:contract_template,
|
||||
photos: [],
|
||||
)
|
||||
end
|
||||
|
||||
def person_params
|
||||
[
|
||||
:person_first_name,
|
||||
:person_last_name,
|
||||
:person_phone,
|
||||
:person_email,
|
||||
:person_address_street1,
|
||||
:person_address_street2,
|
||||
:person_address_city,
|
||||
:person_address_state,
|
||||
:person_address_zip,
|
||||
:person_address_country,
|
||||
]
|
||||
end
|
||||
|
||||
def guardian_params
|
||||
[
|
||||
:guardian_first_name,
|
||||
:guardian_last_name,
|
||||
:guardian_phone,
|
||||
:guardian_email,
|
||||
:minor,
|
||||
:guardian_address_street1,
|
||||
:guardian_address_street2,
|
||||
:guardian_address_city,
|
||||
:guardian_address_state,
|
||||
:guardian_address_zip,
|
||||
:guardian_address_country,
|
||||
:guardian_photo
|
||||
]
|
||||
end
|
||||
|
||||
def misc_release_params_with_locale
|
||||
misc_release_params.merge(locale: I18n.locale)
|
||||
end
|
||||
|
||||
def misc_release_params_with_locale_and_contract_template
|
||||
misc_release_params_with_locale.merge(contract_template: @contract_template)
|
||||
end
|
||||
|
||||
def log_create_analytics
|
||||
TrackAnalyticsJob.perform_later(nil, nil, :track_create_native_release, release_type: MiscRelease.to_s, account: @account, user_agent: request.user_agent, user_ip: request.remote_ip)
|
||||
end
|
||||
end
|
||||
@@ -12,7 +12,9 @@ class AppearanceRelease < ApplicationRecord
|
||||
include Taggable
|
||||
include PersonName
|
||||
include GuardianPhotoable
|
||||
include SecondGuardianPhotoable
|
||||
include GuardianName
|
||||
include SecondGuardianName
|
||||
|
||||
has_one_attached :person_photo
|
||||
|
||||
@@ -38,6 +40,17 @@ class AppearanceRelease < ApplicationRecord
|
||||
%w[guardian_address_country country]
|
||||
]
|
||||
|
||||
composed_of :guardian_2_address,
|
||||
class_name: 'Address',
|
||||
mapping: [
|
||||
%w[guardian_2_address_street1 street1],
|
||||
%w[guardian_2_address_street2 street2],
|
||||
%w[guardian_2_address_city city],
|
||||
%w[guardian_2_address_state state],
|
||||
%w[guardian_2_address_zip zip],
|
||||
%w[guardian_2_address_country country]
|
||||
]
|
||||
|
||||
|
||||
# These validations apply to all releases
|
||||
validates :person_email, email: true, allow_blank: true
|
||||
@@ -132,6 +145,10 @@ class AppearanceRelease < ApplicationRecord
|
||||
true
|
||||
end
|
||||
|
||||
def second_guardian_present?
|
||||
self.guardian_2_first_name.present?
|
||||
end
|
||||
|
||||
def contract_file_name
|
||||
"#{project.name.parameterize}_#{contract_template.release_type}_#{(signed_at || created_at).strftime('%Y.%m.%d')}_#{release_number}_#{filename_suffix.parameterize}"
|
||||
end
|
||||
|
||||
20
app/models/concerns/second_guardian_name.rb
Normal file
20
app/models/concerns/second_guardian_name.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
module SecondGuardianName
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
def guardian_2_name
|
||||
"#{guardian_2_first_name} #{guardian_2_last_name}".titleize
|
||||
end
|
||||
|
||||
def guardian_2_name=(value)
|
||||
if value.include?(' ')
|
||||
split = value.split(" ", 2)
|
||||
self.guardian_2_first_name = split.first
|
||||
self.guardian_2_last_name = split.last
|
||||
else
|
||||
self.guardian_2_first_name = value
|
||||
self.guardian_2_last_name = "(Not Given)"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
9
app/models/concerns/second_guardian_photoable.rb
Normal file
9
app/models/concerns/second_guardian_photoable.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
module SecondGuardianPhotoable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
has_one_attached :guardian_2_photo
|
||||
|
||||
validates :guardian_2_photo, content_type: ["image/png", "image/jpeg"]
|
||||
end
|
||||
end
|
||||
@@ -8,6 +8,7 @@ class MiscRelease < ApplicationRecord
|
||||
include Syncable
|
||||
include PersonName
|
||||
include GuardianName
|
||||
include GuardianPhotoable
|
||||
|
||||
composed_of :person_address,
|
||||
class_name: "Address",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class ReleasableParam
|
||||
TYPES = %w(talent appearance location material acquired_media music medical)
|
||||
TYPES = %w(talent appearance location material acquired_media music medical misc)
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
|
||||
41
app/policies/misc_release_policy.rb
Normal file
41
app/policies/misc_release_policy.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
class MiscReleasePolicy < ReleasePolicy
|
||||
def create?
|
||||
true
|
||||
end
|
||||
|
||||
def show?
|
||||
true
|
||||
end
|
||||
|
||||
def update?
|
||||
!record.native?
|
||||
end
|
||||
|
||||
def destroy?
|
||||
true
|
||||
end
|
||||
|
||||
def edit_photos?
|
||||
true
|
||||
end
|
||||
|
||||
def index?
|
||||
true
|
||||
end
|
||||
|
||||
def update_photos?
|
||||
edit_photos?
|
||||
end
|
||||
|
||||
def tag_multiple?
|
||||
true
|
||||
end
|
||||
|
||||
def download_single?
|
||||
true
|
||||
end
|
||||
|
||||
def download_multiple?
|
||||
download_single?
|
||||
end
|
||||
end
|
||||
@@ -5,6 +5,9 @@
|
||||
<% if release.respond_to? :guardian_photo %>
|
||||
<% @total_photos_count += release.guardian_photo.attached? ? 1 : 0 %>
|
||||
<% end %>
|
||||
<% if release.respond_to? :guardian_2_photo %>
|
||||
<% @total_photos_count += release.guardian_2_photo.attached? ? 1 : 0 %>
|
||||
<% end %>
|
||||
<p class="heading"><strong><u><%= t '.heading', count: @total_photos_count %></u></strong></p>
|
||||
|
||||
<ul>
|
||||
@@ -29,6 +32,14 @@
|
||||
<%= release.guardian_photo.filename.to_s %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if release.respond_to?(:guardian_2_photo) && release.guardian_2_photo.attached? %>
|
||||
<br>
|
||||
<p class="heading"><strong><%= t '.guardian_2_photo_heading' %></strong></p>
|
||||
<li>
|
||||
<%= image_tag release.guardian_2_photo.variant(auto_orient: true, resize: "200x200") %><br />
|
||||
<%= release.guardian_2_photo.filename.to_s %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -69,4 +69,19 @@
|
||||
<%= description_list_pair_for releasable, :signed_on, append: ":" %>
|
||||
</dl>
|
||||
|
||||
<% if releasable.respond_to?(:second_guardian_present?) && releasable.second_guardian_present? %>
|
||||
|
||||
<br/>
|
||||
<p class="text-left"><strong>Second guardian Information</strong></p>
|
||||
|
||||
<% # Second guardian information %>
|
||||
<dl>
|
||||
<%= description_list_pair_for releasable, :guardian_2_name, append: ":" %>
|
||||
<%= description_list_pair_for releasable, :guardian_2_address, append: ":" %>
|
||||
<%= description_list_pair_for releasable, :guardian_2_phone, append: ":" %>
|
||||
<%= description_list_pair_for releasable, :guardian_2_email, append: ":" %>
|
||||
</dl>
|
||||
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
|
||||
48
app/views/misc_releases/_misc_release.html.erb
Normal file
48
app/views/misc_releases/_misc_release.html.erb
Normal file
@@ -0,0 +1,48 @@
|
||||
<tr id="<%= dom_id(misc_release) %>">
|
||||
<td data-behavior="select"><%= check_box_tag "misc_release_ids[]", misc_release.id, false %></td>
|
||||
<td>
|
||||
<% if misc_release.photo.attached? %>
|
||||
<%= image_tag medium_variant(misc_release.photo), class: "img-fluid" %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<%= misc_release.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= contact_info(
|
||||
address: misc_release.person_address,
|
||||
phone: misc_release.person_phone,
|
||||
email: misc_release.person_email
|
||||
) %>
|
||||
</td>
|
||||
<td>
|
||||
<%= notes_preview misc_release.notes.order_by_recent %>
|
||||
</td>
|
||||
<td id="<%= dom_id misc_release, "tags_preview" %>">
|
||||
<%= tags_preview misc_release, misc_release.tags %>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<%= misc_release.signed_on %>
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
<div class="btn-group">
|
||||
<%= button_tag t(".actions.manage"), class: "btn btn-light btn-sm dropdown-toggle border", data: { toggle: "dropdown", boundary: "window" }, aria: { haspopup: true, expanded: false } %>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<% if policy(Note).new? %>
|
||||
<%= link_to fa_icon("sticky-note fw", text: "Notes"), [:new, misc_release, :note], class: "dropdown-item", remote: true %>
|
||||
<% end %>
|
||||
<% if policy(misc_release.tags).new? %>
|
||||
<%= link_to fa_icon("tags fw", text: "Tags"), [:new, misc_release, :acts_as_taggable_on_tag], class: "dropdown-item", remote: true %>
|
||||
<% end %>
|
||||
<% if policy(MedicalRelease).download_single? && policy(Contract).show? && (misc_release.contract.attached? || misc_release.contract_template.present?) %>
|
||||
<%= link_to fa_icon("download fw", text: "Download"), [misc_release, :contracts, format: "pdf"], class: "dropdown-item", target: "_blank" %>
|
||||
<% end %>
|
||||
<% if policy(misc_release).destroy? %>
|
||||
<%= link_to fa_icon("trash fw", text: "Delete"), misc_release, class: "dropdown-item", method: :delete, data: { confirm: "Are you sure?" } %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
48
app/views/misc_releases/index.html.erb
Normal file
48
app/views/misc_releases/index.html.erb
Normal file
@@ -0,0 +1,48 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3">
|
||||
<% if @misc_releases.any? && policy(MiscRelease).tag_multiple? %>
|
||||
<%= button_to_bulk_tagging(@project) %>
|
||||
<% end %>
|
||||
|
||||
<% if @misc_releases.any? && policy(MiscRelease).download_multiple? %>
|
||||
<%= link_to "Download All", [@project, :contract_downloads, release_type: @misc_releases.name], method: :post, remote: true, class: "btn btn-light border ml-auto mr-2 mb-2", data: {
|
||||
disable_with: "Please wait..." } %>
|
||||
<% end %>
|
||||
|
||||
<%= bootstrap_form_with url: [@project, :misc_releases], method: :get, remote: true, layout: :inline, id: "search" do |form| %>
|
||||
<%= form.search_field :query, hide_label: true, placeholder: t(".actions.search"), class: "rounded-pill-right", value: params[:query], prepend: form.button(fa_icon("search"), class: "btn btn-light border mb-2 rounded-pill-left") %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="border bg-white rounded shadow-sm pb-3 table-responsive">
|
||||
<table class="table table-striped tr-px-4 align-all-middle">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th data-behavior="all-selectable"><%= check_box_tag "misc_release_ids[]", false, false %></th>
|
||||
<th></th>
|
||||
<th><%= MiscRelease.human_attribute_name(:person_name) %></th>
|
||||
<th><%= MiscRelease.human_attribute_name(:contact_info) %></th>
|
||||
<th><%= t(".table_headers.notes") %></th>
|
||||
<th><%= t(".table_headers.tags") %></th>
|
||||
<th><%= t(".table_headers.signed_at") %></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="misc_releases">
|
||||
<% if @misc_releases.any? %>
|
||||
<%= render @misc_releases %>
|
||||
<% else %>
|
||||
<tr>
|
||||
<td colspan="12" class="py-4 text-center text-muted"><%= t(".empty") %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="misc_releases_pagination" class="mt-3">
|
||||
<%= will_paginate @misc_releases %>
|
||||
</div>
|
||||
3
app/views/misc_releases/index.js.erb
Normal file
3
app/views/misc_releases/index.js.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
$("#misc_releases").html("<%= j render(@misc_releases) %>");
|
||||
$("form input[type='search']").val("<%= params[:query] %>");
|
||||
$("#misc_releases_pagination").html("<%= j will_paginate(@misc_releases) %>");
|
||||
@@ -57,7 +57,7 @@
|
||||
<%= form.hidden_field :person_photo, value: form.object.person_photo.signed_id if @appearance_release.person_photo.attached? %>
|
||||
<%= form.file_field :person_photo, hide_label: true, data: { ujs_target: "person-photo-input" }, accept: @appearance_release.class.face_photo_acceptable_content_types.join(","), direct_upload: true %>
|
||||
</div>
|
||||
<%= button_tag t(".photo.take_photo"), type: "button", class: "btn btn-lg btn-primary take-photo-button", data: { behavior: "take-person-photo" } %>
|
||||
<%= button_tag t(".photo.take_photo"), type: "button", class: "btn btn-lg btn-primary take-photo-button", data: { behavior: "trigger-click", target: "[data-ujs-target=person-photo-input]" } %>
|
||||
</div>
|
||||
<p class="p-2 font-weight-bold">
|
||||
<%= fa_icon "arrow-up", text: t(".photo.camera_instructions_html") %><br>
|
||||
@@ -75,8 +75,6 @@
|
||||
<%= form.text_field :guardian_first_name, required: @appearance_release.minor?, wrapper_class: "col-sm-3" %>
|
||||
<%= form.text_field :guardian_last_name, required: @appearance_release.minor?, wrapper_class: "col-sm-3" %>
|
||||
<%= form.phone_field :guardian_phone, required: @appearance_release.minor?, wrapper_class: "col-sm-6" %>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<%= form.text_field :guardian_email, required: @appearance_release.minor?, wrapper_class: "col-sm-6" %>
|
||||
</div>
|
||||
<%= render "shared/address_fields", form: form, subject: "guardian", required: @appearance_release.minor? %>
|
||||
@@ -102,7 +100,48 @@
|
||||
<%= form.hidden_field :guardian_photo, value: form.object.guardian_photo.signed_id if @appearance_release.guardian_photo.attached? %>
|
||||
<%= form.file_field :guardian_photo, required: @appearance_release.minor?, hide_label: true, data: { ujs_target: "guardian-photo-input" }, accept: @appearance_release.class.face_photo_acceptable_content_types.join(","), direct_upload: true %>
|
||||
</div>
|
||||
<%= button_tag t(".photo.take_photo"), type: "button", class: "btn btn-lg btn-primary take-photo-button", data: { behavior: "take-guardian-photo" } %>
|
||||
<%= button_tag t(".photo.take_photo"), type: "button", class: "btn btn-lg btn-primary take-photo-button", data: { behavior: "trigger-click", target: "[data-ujs-target=guardian-photo-input]" } %>
|
||||
</div>
|
||||
<p class="p-2 font-weight-bold">
|
||||
<%= fa_icon "arrow-up", text: t(".photo.camera_instructions_html") %><br>
|
||||
<small class="text-muted"><%= t ".photo.warning" %></small>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<hr>
|
||||
|
||||
<%= card_field_set_tag t(".guardian_2_info.heading") do %>
|
||||
<div class="form-row">
|
||||
<%= form.text_field :guardian_2_first_name, wrapper_class: "col-sm-3" %>
|
||||
<%= form.text_field :guardian_2_last_name, wrapper_class: "col-sm-3" %>
|
||||
<%= form.phone_field :guardian_2_phone, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :guardian_2_email, wrapper_class: "col-sm-6" %>
|
||||
</div>
|
||||
<%= render "shared/address_fields", form: form, subject: "guardian_2" %>
|
||||
<% end %>
|
||||
|
||||
<hr>
|
||||
|
||||
<%= card_field_set_tag t(".guardian_2_photo.heading") do %>
|
||||
<div class="alert alert-warning font-weight-bold"><%= t ".guardian_2_photo.instructions" %></div>
|
||||
<div class="text-center">
|
||||
<div class="d-inline-block mb-2" data-behavior="guardian-photo-preview" data-file-input="[data-ujs-target=guardian-2-photo-input]">
|
||||
<div class="align-items-center d-flex photo-preview img-thumbnail justify-content-center">
|
||||
<span><%= t ".photo.no_photo" %></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-inline-block text-left">
|
||||
<% if @appearance_release.guardian_2_photo.attached? %>
|
||||
<%= javascript_tag nonce: true do %>
|
||||
App.PhotoPreview.set("[data-behavior=guardian-photo-preview]", "<%= url_for(@appearance_release.guardian_2_photo.variant(auto_orient: true, resize: '200x200')) %>");
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="hidden-file-input">
|
||||
<%= form.hidden_field :guardian_2_photo, value: form.object.guardian_2_photo.signed_id if @appearance_release.guardian_2_photo.attached? %>
|
||||
<%= form.file_field :guardian_2_photo, hide_label: true, data: { ujs_target: "guardian-2-photo-input" }, accept: @appearance_release.class.face_photo_acceptable_content_types.join(","), direct_upload: true %>
|
||||
</div>
|
||||
<%= button_tag t(".photo.take_photo"), type: "button", class: "btn btn-lg btn-primary take-photo-button", data: { behavior: "trigger-click", target: "[data-ujs-target=guardian-2-photo-input]" } %>
|
||||
</div>
|
||||
<p class="p-2 font-weight-bold">
|
||||
<%= fa_icon "arrow-up", text: t(".photo.camera_instructions_html") %><br>
|
||||
|
||||
1
app/views/public/misc_releases/create.html.erb
Normal file
1
app/views/public/misc_releases/create.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<p class="alert alert-success p-3 lead text-center">Your release was successfully submitted. Thank you.</p>
|
||||
97
app/views/public/misc_releases/new.html.erb
Normal file
97
app/views/public/misc_releases/new.html.erb
Normal file
@@ -0,0 +1,97 @@
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<%= errors_summary_for @misc_release %>
|
||||
<%= bootstrap_form_with model: [@account, @project, @contract_template, @misc_release], local: true, validation_context: :native do |form| %>
|
||||
<div class="alert alert-warning font-weight-bold"><%= t ".instructions_html", name: @project.name %></div>
|
||||
<%= card_field_set_tag t(".legal.heading") do %>
|
||||
<p><%= @contract_template.body %></p>
|
||||
<% end %>
|
||||
|
||||
<hr>
|
||||
|
||||
<% unless @contract_template.guardian_clause.blank? %>
|
||||
<%= form.form_group :minor do %>
|
||||
<%= form.check_box :minor, label: t("helpers.label.appearance_release.minor"), data: { target: "[data-ujs-target=guardian-fields]", toggle: "collapse" } %>
|
||||
<% end %>
|
||||
|
||||
<%= card_field_set_tag t(".guardian_clause.heading") do %>
|
||||
<p><%= @contract_template.guardian_clause %></p>
|
||||
<% end %>
|
||||
<hr>
|
||||
<% end %>
|
||||
|
||||
<%= card_field_set_tag t(".personal_info.heading") do %>
|
||||
<div class="alert alert-warning font-weight-bold"><%= t ".personal_info.instructions" %></div>
|
||||
<div class="form-row">
|
||||
<%= form.text_field :person_first_name, required: true, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_last_name, required: true, wrapper_class: "col-sm-6" %>
|
||||
<%= form.phone_field :person_phone, wrapper_class: "col-sm-6" %>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<%= form.email_field :person_email, wrapper_class: "col-sm-6" %>
|
||||
</div>
|
||||
<%= render "shared/address_fields", form: form, subject: "person" %>
|
||||
<% end %>
|
||||
|
||||
<hr>
|
||||
|
||||
<%= card_field_set_tag t(".photo.heading") do %>
|
||||
<%= render "shared/photos_dropzone_fields", form: form, release: @misc_release %>
|
||||
<% end %>
|
||||
|
||||
<% unless @contract_template.guardian_clause.blank? %>
|
||||
<div class="<%= class_string("collapse" => !@misc_release.minor?) %>" data-ujs-target="guardian-fields">
|
||||
<%= card_field_set_tag t(".guardian_info.heading") do %>
|
||||
<div class="form-row">
|
||||
<%= form.text_field :guardian_first_name, required: @misc_release.minor?, wrapper_class: "col-sm-3" %>
|
||||
<%= form.text_field :guardian_last_name, required: @misc_release.minor?, wrapper_class: "col-sm-3" %>
|
||||
<%= form.phone_field :guardian_phone, wrapper_class: "col-sm-6" %>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<%= form.text_field :guardian_email, wrapper_class: "col-sm-6" %>
|
||||
</div>
|
||||
<%= render "shared/address_fields", form: form, subject: "guardian" %>
|
||||
<% end %>
|
||||
|
||||
<hr>
|
||||
|
||||
<%= card_field_set_tag t(".guardian_photo.heading") do %>
|
||||
<div class="alert alert-warning font-weight-bold"><%= t ".guardian_photo.instructions" %></div>
|
||||
<div class="text-center">
|
||||
<div class="d-inline-block mb-2" data-behavior="guardian-photo-preview" data-file-input="[data-ujs-target=guardian-photo-input]">
|
||||
<div class="align-items-center d-flex photo-preview img-thumbnail justify-content-center">
|
||||
<span><%= t ".guardian_photo.no_photo" %></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-inline-block text-left">
|
||||
<% if @misc_release.guardian_photo.attached? %>
|
||||
<%= javascript_tag nonce: true do %>
|
||||
App.PhotoPreview.set("[data-behavior=guardian-photo-preview]", "<%= url_for(@misc_release.guardian_photo.variant(auto_orient: true, resize: '200x200')) %>");
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="hidden-file-input">
|
||||
<%= form.hidden_field :guardian_photo, value: form.object.guardian_photo.signed_id if @misc_release.guardian_photo.attached? %>
|
||||
<%= form.file_field :guardian_photo, hide_label: true, data: { ujs_target: "guardian-photo-input" }, accept: @misc_release.class.face_photo_acceptable_content_types.join(","), direct_upload: true %>
|
||||
</div>
|
||||
<%= button_tag t(".guardian_photo.take_photo"), type: "button", class: "btn btn-lg btn-primary take-photo-button", data: { behavior: "take-guardian-photo" } %>
|
||||
</div>
|
||||
<p class="p-2 font-weight-bold">
|
||||
<%= fa_icon "arrow-up", text: t(".guardian_photo.camera_instructions_html") %><br>
|
||||
<small class="text-muted"><%= t ".guardian_photo.warning" %></small>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<hr>
|
||||
<% end %>
|
||||
|
||||
<%= card_field_set_tag t(".signature.heading") do %>
|
||||
<%= render "shared/signature_fields", 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>
|
||||
@@ -78,7 +78,7 @@
|
||||
<%= form.hidden_field :guardian_photo, value: form.object.guardian_photo.signed_id if @talent_release.guardian_photo.attached? %>
|
||||
<%= form.file_field :guardian_photo, hide_label: true, data: { ujs_target: "guardian-photo-input" }, accept: @talent_release.class.face_photo_acceptable_content_types.join(","), direct_upload: true %>
|
||||
</div>
|
||||
<%= button_tag t(".guardian_photo.take_photo"), type: "button", class: "btn btn-lg btn-primary take-photo-button", data: { behavior: "take-guardian-photo" } %>
|
||||
<%= button_tag t(".guardian_photo.take_photo"), type: "button", class: "btn btn-lg btn-primary take-photo-button", data: { behavior: "trigger-click", target: "[data-ujs-target=guardian-photo-input]" } %>
|
||||
</div>
|
||||
<p class="p-2 font-weight-bold">
|
||||
<%= fa_icon "arrow-up", text: t(".guardian_photo.camera_instructions_html") %><br>
|
||||
|
||||
@@ -60,6 +60,10 @@ en:
|
||||
activerecord:
|
||||
attributes:
|
||||
appearance_release:
|
||||
guardian_2_address: Guardian 2 address
|
||||
guardian_2_email: Guardian 2 email
|
||||
guardian_2_name: Guardian 2 name
|
||||
guardian_2_phone: Guardian 2 phone
|
||||
person_address: Address
|
||||
person_email: Email
|
||||
person_name: Name
|
||||
@@ -237,6 +241,7 @@ en:
|
||||
heading: New Release Template
|
||||
contracts:
|
||||
photos:
|
||||
guardian_2_photo_heading: Second guardian photo
|
||||
guardian_photo_heading: Guardian photo
|
||||
heading:
|
||||
one: Photo
|
||||
@@ -328,6 +333,16 @@ en:
|
||||
person_phone: Phone number
|
||||
person_title: Title
|
||||
appearance_release:
|
||||
guardian_2_address_city: Guardian 2 city
|
||||
guardian_2_address_country: Guardian 2 country
|
||||
guardian_2_address_state: Guardian 2 state
|
||||
guardian_2_address_street1: Guardian 2 address
|
||||
guardian_2_address_street2: Guardian 2 address (Line 2)
|
||||
guardian_2_address_zip: Guardian 2 zip code
|
||||
guardian_2_email: Guardian 2 email
|
||||
guardian_2_first_name: Guardian 2 first name
|
||||
guardian_2_last_name: Guardian 2 last name
|
||||
guardian_2_phone: Guardian 2 phone
|
||||
guardian_address_city: Guardian city
|
||||
guardian_address_country: Guardian country
|
||||
guardian_address_state: Guardian state
|
||||
@@ -645,6 +660,20 @@ en:
|
||||
medical_release:
|
||||
actions:
|
||||
manage: Manage
|
||||
misc_releases:
|
||||
destroy:
|
||||
alert: The misc release has been deleted
|
||||
index:
|
||||
actions:
|
||||
search: Search
|
||||
empty: Misc Releases will appear here
|
||||
table_headers:
|
||||
notes: Notes
|
||||
signed_at: Date Signed
|
||||
tags: Tags
|
||||
misc_release:
|
||||
actions:
|
||||
manage: Manage
|
||||
music_releases:
|
||||
create:
|
||||
notice: The music release has been created
|
||||
@@ -802,6 +831,12 @@ en:
|
||||
notice: Your release has been signed. Thank you!
|
||||
new:
|
||||
cancel: Cancel
|
||||
guardian_2_info:
|
||||
heading: Second Guardian Information (if company requires)
|
||||
guardian_2_photo:
|
||||
heading: Second Guardian Photo
|
||||
instructions: >
|
||||
Lastly, it's time for second guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese!
|
||||
guardian_clause:
|
||||
heading: Guardian Clause
|
||||
guardian_info:
|
||||
@@ -880,6 +915,34 @@ en:
|
||||
heading: Questionnaire
|
||||
signature:
|
||||
heading: Signature
|
||||
misc_releases:
|
||||
create:
|
||||
notice: Your release has been signed. Thank you!
|
||||
new:
|
||||
cancel: Cancel
|
||||
guardian_clause:
|
||||
heading: Guardian Clause
|
||||
guardian_info:
|
||||
heading: Guardian Information
|
||||
guardian_photo:
|
||||
camera_instructions_html: Click <em>Take Photo</em> to Turn ON Camera
|
||||
heading: Guardian Photo
|
||||
instructions: >
|
||||
Lastly, it's time for guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese!
|
||||
no_photo: No photo yet
|
||||
take_photo: Take Photo
|
||||
warning: If your photo appears sideways, it will be autocorrected when you submit your release.
|
||||
instructions_html: >
|
||||
Below is the misc release form. After scrolling down and reading the misc release form, please enter your personal information, take a photo, and press the "Submit Release" button.
|
||||
legal:
|
||||
heading: Legal
|
||||
personal_info:
|
||||
heading: Personal Information
|
||||
instructions: Now, enter your personal information.
|
||||
photo:
|
||||
heading: Photos
|
||||
signature:
|
||||
heading: Signature
|
||||
talent_releases:
|
||||
create:
|
||||
notice: Your release has been signed. Thank you!
|
||||
|
||||
@@ -66,6 +66,7 @@ es:
|
||||
heading: Release Info (ES)
|
||||
contracts:
|
||||
photos:
|
||||
guardian_2_photo_heading: Second guardian photo (ES)
|
||||
guardian_photo_heading: Guardian photo (ES)
|
||||
heading:
|
||||
one: Photo (ES)
|
||||
@@ -115,6 +116,16 @@ es:
|
||||
helpers:
|
||||
label:
|
||||
appearance_release:
|
||||
guardian_2_address_city: Second guardian city (ES)
|
||||
guardian_2_address_country: Second guardian country (ES)
|
||||
guardian_2_address_state: Second guardian state (ES)
|
||||
guardian_2_address_street1: Second guardian address (ES)
|
||||
guardian_2_address_street2: Second guardian address (Line 2) (ES)
|
||||
guardian_2_address_zip: Second guardian zip code (ES)
|
||||
guardian_2_email: Second guardian email (ES)
|
||||
guardian_2_first_name: Second guardian first name (ES)
|
||||
guardian_2_last_name: Second guardian last name (ES)
|
||||
guardian_2_phone: Second guardian phone (ES)
|
||||
guardian_address_city: Guardian city (ES)
|
||||
guardian_address_country: Guardian country (ES)
|
||||
guardian_address_state: Guardian state (ES)
|
||||
@@ -167,6 +178,12 @@ es:
|
||||
notice: La autorización está firmada. ¡Gracias!
|
||||
new:
|
||||
cancel: Cancelar
|
||||
guardian_2_info:
|
||||
heading: Second Guardian Information (ES)
|
||||
guardian_2_photo:
|
||||
heading: Second Guardian Photo (ES)
|
||||
instructions: >
|
||||
(ES) Lastly, it's time for second guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese! (ES)
|
||||
guardian_clause:
|
||||
heading: Guardian Clause (ES)
|
||||
guardian_photo:
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class ChangeExistingZoomUserSettings < ActiveRecord::DataMigration
|
||||
def up
|
||||
gateway = ZoomGateway.new
|
||||
|
||||
ZoomUser.find_each do |zu|
|
||||
gateway.update_user_settings zu.api_id
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
class AddSecondGuardianFieldsToAppearanceReleases < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :appearance_releases, :guardian_2_first_name, :string
|
||||
add_column :appearance_releases, :guardian_2_last_name, :string
|
||||
add_column :appearance_releases, :guardian_2_email, :string
|
||||
add_column :appearance_releases, :guardian_2_phone, :string
|
||||
add_column :appearance_releases, :guardian_2_address_street1, :string
|
||||
add_column :appearance_releases, :guardian_2_address_street2, :string
|
||||
add_column :appearance_releases, :guardian_2_address_city, :string
|
||||
add_column :appearance_releases, :guardian_2_address_state, :string
|
||||
add_column :appearance_releases, :guardian_2_address_zip, :string
|
||||
add_column :appearance_releases, :guardian_2_address_country, :string
|
||||
end
|
||||
end
|
||||
@@ -9,20 +9,6 @@ SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
--
|
||||
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
|
||||
--
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
|
||||
|
||||
|
||||
--
|
||||
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
|
||||
--
|
||||
|
||||
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
|
||||
|
||||
|
||||
--
|
||||
-- Name: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: -
|
||||
--
|
||||
@@ -342,7 +328,17 @@ CREATE TABLE public.appearance_releases (
|
||||
guardian_address_city character varying,
|
||||
guardian_address_state character varying,
|
||||
guardian_address_zip character varying,
|
||||
guardian_address_country character varying
|
||||
guardian_address_country character varying,
|
||||
guardian_2_first_name character varying,
|
||||
guardian_2_last_name character varying,
|
||||
guardian_2_email character varying,
|
||||
guardian_2_phone character varying,
|
||||
guardian_2_address_street1 character varying,
|
||||
guardian_2_address_street2 character varying,
|
||||
guardian_2_address_city character varying,
|
||||
guardian_2_address_state character varying,
|
||||
guardian_2_address_zip character varying,
|
||||
guardian_2_address_country character varying
|
||||
);
|
||||
|
||||
|
||||
@@ -3793,6 +3789,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20200615133602'),
|
||||
('20200616124214'),
|
||||
('20200619081446'),
|
||||
('20200619085823');
|
||||
('20200619085823'),
|
||||
('20200619134853');
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require './lib/zoom_wrapper_monkeypatch'
|
||||
|
||||
class ZoomGateway
|
||||
class AuthenticationError < StandardError; end
|
||||
class MeetingExpired < StandardError; end
|
||||
@@ -65,6 +69,23 @@ class ZoomGateway
|
||||
parse_zoom_error(e)
|
||||
end
|
||||
|
||||
# Update user with custom settings
|
||||
def update_user_settings(user_id)
|
||||
custom_defaults = {
|
||||
id: user_id,
|
||||
in_meeting: {
|
||||
auto_saving_chat: true,
|
||||
co_host: true,
|
||||
non_verbal_feedback: true,
|
||||
breakout_room: true,
|
||||
group_hd: true,
|
||||
far_end_camera_control: true,
|
||||
allow_live_streaming: true
|
||||
}
|
||||
}
|
||||
@client.user_settings_update custom_defaults
|
||||
end
|
||||
|
||||
def create_host(host_email)
|
||||
# Find role
|
||||
host_role = @client.roles_list["roles"].try(:select) { |r| r["name"] == self.class.HOST_ROLE }.try(:first)
|
||||
@@ -82,6 +103,8 @@ class ZoomGateway
|
||||
type: self.class.USER_TYPE
|
||||
})
|
||||
|
||||
update_user_settings(host_user["id"])
|
||||
|
||||
# Assign role to user
|
||||
@client.roles_assign role_id: host_role["id"], members: [{id: host_user["id"]}]
|
||||
|
||||
|
||||
25
lib/zoom_wrapper_monkeypatch.rb
Normal file
25
lib/zoom_wrapper_monkeypatch.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Zoom
|
||||
module Actions
|
||||
module User
|
||||
def user_settings_update(*args)
|
||||
params = Zoom::Params.new(Utils.extract_options!(args))
|
||||
permitted_in_meeting_params = %i[
|
||||
auto_saving_chat
|
||||
co_host
|
||||
non_verbal_feedback
|
||||
breakout_room
|
||||
group_hd
|
||||
far_end_camera_control
|
||||
allow_live_streaming
|
||||
]
|
||||
permitted_params = { in_meeting: permitted_in_meeting_params }
|
||||
params.require(:id).permit permitted_params
|
||||
request_body = params.except(:id).to_json
|
||||
resp = self.class.patch("/users/#{params[:id]}/settings", body: request_body, headers: request_headers)
|
||||
Utils.parse_response resp
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
116
spec/controllers/misc_releases_controller_spec.rb
Normal file
116
spec/controllers/misc_releases_controller_spec.rb
Normal file
@@ -0,0 +1,116 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe MiscReleasesController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:account) { user.primary_account }
|
||||
let(:project) { create(:project, account: user.primary_account) }
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
describe "#index" do
|
||||
it "responds successfully" do
|
||||
get :index, params: { project_id: project }
|
||||
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
it "renders content" do
|
||||
release = create(:misc_release, project: project,
|
||||
person_first_name: "My",
|
||||
person_last_name: "Release",
|
||||
person_phone: "5551234567",
|
||||
person_email: "jane.doe@test.com")
|
||||
create(:note, notable: release, content: "Some notes here")
|
||||
|
||||
get :index, params: { project_id: project }
|
||||
|
||||
expect(response.body).to have_content "My Release"
|
||||
expect(response.body).to have_content "P: 5551234567"
|
||||
expect(response.body).to have_content "jane.doe@test.com"
|
||||
expect(response.body).to have_content "Some notes here"
|
||||
expect(response.body).to have_content "Manage"
|
||||
end
|
||||
|
||||
context "when there are no misc releases" do
|
||||
it "renders an empty message" do
|
||||
get :index, params: { project_id: project }
|
||||
|
||||
expect(response.body).to have_content("Misc Releases will appear here")
|
||||
end
|
||||
end
|
||||
|
||||
context "when there are many records" do
|
||||
it "paginates the table" do
|
||||
create_list(:misc_release, 20, project: project)
|
||||
|
||||
get :index, params: { project_id: project }
|
||||
|
||||
expect(response.body).to have_link("2", href: project_misc_releases_path(project, page: 2))
|
||||
end
|
||||
end
|
||||
|
||||
context "for xhr request" do
|
||||
it "filters the releases by a query param" do
|
||||
misc_releases = [
|
||||
create(:misc_release, person_name: "Adam Sandler", project: project),
|
||||
create(:misc_release, person_name: "Zoe Perry", project: project),
|
||||
]
|
||||
|
||||
get :index, params: { project_id: project, query: "Zoe" }, xhr: true
|
||||
|
||||
expect(response.body).not_to have_content("Adam Sandler")
|
||||
expect(response.body).to have_content("Zoe Perry")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#destroy" do
|
||||
let!(:misc_release) { create(:misc_release, project: project) }
|
||||
|
||||
it "responds with redirect" do
|
||||
delete :destroy, params: { project_id: project, id: misc_release }
|
||||
|
||||
expect(response).to be_redirect
|
||||
expect(response).to redirect_to [project, :misc_releases]
|
||||
end
|
||||
|
||||
it "sets the flash" do
|
||||
delete :destroy, params: { project_id: project, id: misc_release }
|
||||
|
||||
expect(flash.alert).not_to be_nil
|
||||
end
|
||||
|
||||
it "destroys the record" do
|
||||
expect {
|
||||
delete :destroy, params: { project_id: project, id: misc_release }
|
||||
}.to change(MiscRelease, :count).by(-1)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def misc_release_params
|
||||
attributes_for(:misc_release).merge(exploitable_rights_params)
|
||||
end
|
||||
|
||||
def minor_misc_release_params
|
||||
attributes_for(:misc_release, :minor_with_guardian_photo).merge(exploitable_rights_params)
|
||||
end
|
||||
|
||||
def exploitable_rights_params
|
||||
{
|
||||
applicable_medium_id: ApplicableMedium.last.id,
|
||||
applicable_medium_text: "applicable_media",
|
||||
territory_id: Territory.last.id,
|
||||
territory_text: "territory",
|
||||
term_id: Term.last.id,
|
||||
term_text: "term",
|
||||
restriction_id: Restriction.last.id,
|
||||
restriction_text: "restrictions",
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -23,6 +23,17 @@ FactoryBot.define do
|
||||
guardian_phone "123-555-1234"
|
||||
end
|
||||
|
||||
trait :minor_with_guardian_photo do
|
||||
minor true
|
||||
guardian_first_name "Jamie"
|
||||
guardian_last_name "Doe"
|
||||
guardian_phone "123-555-1234"
|
||||
guardian_photo do
|
||||
path = Rails.root.join("spec", "fixtures", "files", "pratt.jpg")
|
||||
Rack::Test::UploadedFile.new(path, "image/jpeg")
|
||||
end
|
||||
end
|
||||
|
||||
factory :misc_release_with_contract_template do
|
||||
after(:build) do |misc_release, _|
|
||||
misc_release.contract_template = build(:misc_release_contract_template)
|
||||
|
||||
@@ -109,4 +109,10 @@ feature "User creates notes" do
|
||||
|
||||
it_behaves_like "a notable collection UI"
|
||||
end
|
||||
|
||||
context "for misc releases" do
|
||||
subject! { create(:misc_release, project: project, notes: []) }
|
||||
|
||||
it_behaves_like "a notable collection UI"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -92,4 +92,10 @@ feature "User creates tags" do
|
||||
|
||||
it_behaves_like "a taggable collection UI"
|
||||
end
|
||||
|
||||
context "for misc releases" do
|
||||
subject! { create(:misc_release, project: project, tags: []) }
|
||||
|
||||
it_behaves_like "a taggable collection UI"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -72,6 +72,61 @@ feature 'User managing appearance releases' do
|
||||
|
||||
expect(page).to have_content(successful_submission_message)
|
||||
end
|
||||
|
||||
scenario 'creating a release for a minor with two guardians', js: true do
|
||||
allow(BrayniacAI::Validation).to receive(:create).and_return(double(:validation, valid: true))
|
||||
|
||||
project = create(:project, members: current_user, account: current_user.primary_account)
|
||||
contract_template = create(:contract_template, project: project)
|
||||
|
||||
visit new_account_project_contract_template_appearance_release_path(project.account, project, contract_template)
|
||||
|
||||
expect(page).to have_photo_button
|
||||
expect(page).not_to have_content('SECOND GUARDIAN INFORMATION')
|
||||
expect(page).not_to have_content('SECOND GUARDIAN PHOTO')
|
||||
|
||||
page.check person_is_minor_checkbox
|
||||
expect(page).to have_content('GUARDIAN INFORMATION')
|
||||
expect(page).to have_content('GUARDIAN PHOTO')
|
||||
expect(page).to have_content 'Guardian Email'
|
||||
|
||||
expect(page).to have_content 'SECOND GUARDIAN INFORMATION'
|
||||
expect(page).to have_content 'SECOND GUARDIAN PHOTO'
|
||||
expect(page).to have_content 'Guardian 2 Email'
|
||||
expect(page).to have_content 'Guardian 2 Phone'
|
||||
expect(page).to have_content 'Guardian 2 Address'
|
||||
|
||||
fill_in guardian_first_name_field, with: 'Guardian'
|
||||
fill_in guardian_last_name_field, with: 'Name'
|
||||
fill_in guardian_phone_field, with: '001101'
|
||||
fill_in person_first_name_field, with: 'Jane'
|
||||
fill_in person_last_name_field, with: 'Doe'
|
||||
fill_in_person_address_fields
|
||||
fill_in person_phone_field, with: '555-555-5555'
|
||||
fill_in person_email_field, with: 'jane.doe@test.com'
|
||||
fill_in person_date_of_birth, with: '01/01/1999'
|
||||
attach_file person_photo_field, file_fixture('person_photo.png'), visible: :all
|
||||
attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all
|
||||
draw_signature file_fixture('signature.png'), 'appearance_release_signature_base64'
|
||||
|
||||
fill_in guardian_email_field, with: 'invalid@email'
|
||||
click_button submit_release_button
|
||||
expect(page).to have_content('Guardian email is not an email')
|
||||
|
||||
fill_in guardian_email_field, with: 'valid@email.com'
|
||||
fill_in_guardian_address_fields
|
||||
attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all
|
||||
draw_signature file_fixture('signature.png'), 'appearance_release_signature_base64'
|
||||
|
||||
fill_in guardian_2_first_name_field, with: 'Second'
|
||||
fill_in guardian_2_last_name_field, with: 'Guardian'
|
||||
fill_in guardian_2_phone_field, with: '999'
|
||||
|
||||
click_button submit_release_button
|
||||
|
||||
expect(page).to have_content(successful_submission_message)
|
||||
expect(AppearanceRelease.last.guardian_2_first_name).to eq 'Second'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when signed in' do
|
||||
@@ -454,6 +509,18 @@ feature 'User managing appearance releases' do
|
||||
'appearance_release_minor'
|
||||
end
|
||||
|
||||
def guardian_2_first_name_field
|
||||
'Guardian 2 first name'
|
||||
end
|
||||
|
||||
def guardian_2_last_name_field
|
||||
'Guardian 2 last name'
|
||||
end
|
||||
|
||||
def guardian_2_phone_field
|
||||
'Guardian 2 phone'
|
||||
end
|
||||
|
||||
def guardian_first_name_field
|
||||
'Guardian first name'
|
||||
end
|
||||
|
||||
55
spec/features/user_managing_misc_releases_spec.rb
Normal file
55
spec/features/user_managing_misc_releases_spec.rb
Normal file
@@ -0,0 +1,55 @@
|
||||
require "rails_helper"
|
||||
|
||||
feature "User managing misc releases" do
|
||||
let(:current_user) { create(:user) }
|
||||
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
|
||||
|
||||
context "when signed in as account manager" do
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
scenario "Download All is visible" do
|
||||
create(:misc_release_with_contract_template, :native, project: project)
|
||||
|
||||
visit project_misc_releases_path(project)
|
||||
|
||||
expect(page).to have_content download_all_button
|
||||
end
|
||||
|
||||
scenario "Downloading PDF of native misc release is possible" do
|
||||
native_release = create(:misc_release_with_contract_template, :native, project: project)
|
||||
|
||||
visit project_misc_releases_path(project)
|
||||
|
||||
click_link *view_release_pdf_link_for(native_release)
|
||||
expect(content_type).to eq('application/pdf')
|
||||
end
|
||||
end
|
||||
|
||||
context "when the user is manager(project manager)" do
|
||||
let(:current_user) { create(:user, :manager) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
scenario "Download action in Manage menu is not visible" do
|
||||
create(:misc_release_with_contract_template, :native, project: project)
|
||||
|
||||
visit project_misc_releases_path(project)
|
||||
|
||||
expect(page).to have_link("Download", exact: true, count: 0)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def download_all_button
|
||||
'Download All'
|
||||
end
|
||||
|
||||
def view_release_pdf_link_for(release)
|
||||
['Download', href: misc_release_contracts_path(release, format: 'pdf')]
|
||||
end
|
||||
end
|
||||
@@ -5,6 +5,7 @@ RSpec.describe ZoomGateway do
|
||||
let(:host_user_hash) { {"email" => "user1@directme", "id" => "host_user_id"} }
|
||||
let(:roles_members_response) { {"members" => [host_user_hash]} }
|
||||
let(:user_create_response) { {"id" => "new_host_id"} }
|
||||
let(:user_settings_update_response) { "User settings updated" }
|
||||
let(:roles_assign_response) { {"ids" => ["new_host_id"]} }
|
||||
let(:meeting_hash) { {"id" => "meeting_id", "start_url" => "https://start_url", "join_url" => "https://join_url"} }
|
||||
let(:gateway) { ZoomGateway.new }
|
||||
@@ -121,7 +122,9 @@ RSpec.describe ZoomGateway do
|
||||
it "returns new host id" do
|
||||
allow_any_instance_of(Zoom.new.class).to receive(:user_create).and_return(user_create_response)
|
||||
allow_any_instance_of(Zoom.new.class).to receive(:roles_assign).and_return(roles_assign_response)
|
||||
allow_any_instance_of(Zoom.new.class).to receive(:user_settings_update).and_return(user_settings_update_response)
|
||||
|
||||
expect_any_instance_of(Zoom.new.class).to receive(:user_settings_update)
|
||||
expect(gateway.create_host("host-email@address")).to eq("new_host_id")
|
||||
end
|
||||
|
||||
|
||||
60
spec/lib/zoom_wrapper_monkeypatch_spec.rb
Normal file
60
spec/lib/zoom_wrapper_monkeypatch_spec.rb
Normal file
@@ -0,0 +1,60 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Zoom::Actions::User do
|
||||
let(:wrapper) { Zoom.new }
|
||||
|
||||
describe '.update_user_settings' do
|
||||
it 'raises exception if id param is missing' do
|
||||
params = {
|
||||
in_meeting: {
|
||||
not_allowed_param: 1
|
||||
}
|
||||
}
|
||||
|
||||
expect do
|
||||
wrapper.user_settings_update(params)
|
||||
end.to raise_exception(Zoom::ParameterMissing)
|
||||
end
|
||||
|
||||
it 'raises exception if not allowed param is present' do
|
||||
params = {
|
||||
id: 'dw3-3sd33',
|
||||
in_meeting: {
|
||||
not_allowed_param: 1
|
||||
}
|
||||
}
|
||||
|
||||
expect do
|
||||
wrapper.user_settings_update(params)
|
||||
end.to raise_exception(Zoom::ParameterNotPermitted)
|
||||
end
|
||||
|
||||
it 'sends PATCH request to the Zoom API endpoint' do
|
||||
params = {
|
||||
id: 'zoom-120-id',
|
||||
in_meeting: {
|
||||
auto_saving_chat: true,
|
||||
co_host: true,
|
||||
non_verbal_feedback: true,
|
||||
breakout_room: true,
|
||||
group_hd: true,
|
||||
far_end_camera_control: true,
|
||||
allow_live_streaming: true
|
||||
}
|
||||
}
|
||||
|
||||
allow(Zoom::Utils).to receive(:parse_response).and_return 'Success!'
|
||||
|
||||
path = "/users/#{params[:id]}/settings"
|
||||
body_params = { body: params.except(:id).to_json }
|
||||
allow(wrapper.class)
|
||||
.to receive(:patch)
|
||||
.with(path, hash_including(body_params))
|
||||
.and_return({})
|
||||
|
||||
mock_response = wrapper.user_settings_update params
|
||||
expect(mock_response).to eq 'Success!'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
33
spec/policies/misc_release_policy_spec.rb
Normal file
33
spec/policies/misc_release_policy_spec.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe MiscReleasePolicy do
|
||||
let(:user_context) { build(:user_context) }
|
||||
|
||||
subject { described_class }
|
||||
|
||||
permissions :create? do
|
||||
it { is_expected.to permit(:create) }
|
||||
end
|
||||
|
||||
permissions :show? do
|
||||
it { is_expected.to permit(:show) }
|
||||
end
|
||||
|
||||
permissions :update? do
|
||||
context "for a native release" do
|
||||
it { is_expected.not_to permit(user_context, build(:misc_release, :native)) }
|
||||
end
|
||||
end
|
||||
|
||||
permissions :destroy? do
|
||||
it { is_expected.to permit(:destroy) }
|
||||
end
|
||||
|
||||
permissions :edit_photos? do
|
||||
it { is_expected.to permit(:edit_photos) }
|
||||
end
|
||||
|
||||
permissions :update_photos? do
|
||||
it { is_expected.to permit(:update_photos) }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user