Upstream sync
This commit is contained in:
16
README.md
16
README.md
@@ -95,14 +95,28 @@ rake i18n:sort
|
||||
```
|
||||
|
||||
## Zoom.us integration
|
||||
DirectMe app offers live broadcasting. Users are offered to paralelly connect to the Zoom meeting to have a video conference while the streaming happens. In order to use the Zoom functionality, the app needs to have the API keys provided. You need Zoom PRO account for this feature.
|
||||
DirectMe app offers live broadcasting feature. Users are offered to paralelly connect to the Zoom meeting to have a video conference while the streaming happens. In order to use the Zoom functionality, the app needs to have the API and verification token keys provided along with the account number that is available after login into the Zoom account. You need to have Zoom PRO subscription in order to use this feature.
|
||||
|
||||
#### Zoom.us api keys
|
||||
1. Log in to you zoom.us account
|
||||
2. Go to https://marketplace.zoom.us/develop/create
|
||||
3. Choose JWT application
|
||||
4. Copy API Key and API Secret
|
||||
5. Set up ZOOM_API_KEY and ZOOM_API_SECRET environment variables
|
||||
|
||||
#### Setup
|
||||
There is some configuration that has to be done through the API on the Zoom account so that you can use the feature. Run `rails zoom:setup` rake task to do it.
|
||||
|
||||
#### Zoom.us webhooks
|
||||
To ensure integrity in between different Zoom environments, the app uses Zoom webhooks. To set them up, go to https://marketplace.czoom.us -> Develop -> JWT app -> Feature -> Event Subscriptions and enable following hooks:
|
||||
* Start Meeting
|
||||
* End Meeting
|
||||
* All Recordings have completed
|
||||
* User has been created
|
||||
* User had been deleted
|
||||
|
||||
#### Syncing app with Zoom account configuration
|
||||
If you are setting up the app to use Zoom account that has been previously used with DirectME, it is a good idea to make sure that the db state reflects the account situation. To do that, run `rails zoom:sync` rake task.
|
||||
|
||||
## Working Locally
|
||||
|
||||
|
||||
40
app/controllers/api/direct_uploads_controller.rb
Normal file
40
app/controllers/api/direct_uploads_controller.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
# Duplicated from ActiveStorage::DirectUploadsController
|
||||
# https://github.com/rails/rails/blob/v6.0.0/activestorage/app/controllers/active_storage/direct_uploads_controller.rb
|
||||
class Api::DirectUploadsController < Api::ApiController
|
||||
include ActiveStorage::SetCurrent
|
||||
|
||||
def create
|
||||
blob = ActiveStorage::Blob.create_before_direct_upload!(blob_args)
|
||||
render jsonapi: DirectUpload.new(blob)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def blob_args
|
||||
params.require(:blob).permit(:filename, :byte_size, :checksum, :content_type, :metadata).to_h.symbolize_keys
|
||||
end
|
||||
|
||||
class SerializableDirectUpload < JSONAPI::Serializable::Resource
|
||||
type 'direct_upload'
|
||||
|
||||
attributes :id, :key, :signed_id, :url, :headers
|
||||
end
|
||||
|
||||
class DirectUpload
|
||||
delegate :id, :key, :signed_id, to: :blob
|
||||
|
||||
attr_reader :blob
|
||||
|
||||
def initialize(blob)
|
||||
@blob = blob
|
||||
end
|
||||
|
||||
def url
|
||||
blob.service_url_for_direct_upload
|
||||
end
|
||||
|
||||
def headers
|
||||
blob.service_headers_for_direct_upload
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -78,7 +78,7 @@ class AppearanceReleasesController < ApplicationController
|
||||
end
|
||||
|
||||
def appearance_release_params
|
||||
params.require(:appearance_release).permit(:contract, :guardian_address, :guardian_first_name, :guardian_last_name, :guardian_phone, :guardian_photo, :minor,
|
||||
params.require(:appearance_release).permit(:contract, :guardian_address, :guardian_first_name, :guardian_last_name, :guardian_phone, :guardian_photo, :guardian_email, :minor,
|
||||
:person_address, :person_first_name, :person_last_name, :person_phone, :person_email, :person_photo,
|
||||
:applicable_medium_id, :applicable_medium_text,
|
||||
:territory_id, :territory_text,
|
||||
|
||||
@@ -41,7 +41,7 @@ class Public::AppearanceReleasesController < Public::BaseController
|
||||
|
||||
def appearance_release_params
|
||||
params.require(:appearance_release).permit(:person_address, :person_first_name, :person_last_name, :person_phone, :person_email, :person_photo,
|
||||
:guardian_address, :guardian_first_name, :guardian_last_name, :guardian_phone, :guardian_photo, :minor,
|
||||
:guardian_address, :guardian_first_name, :guardian_last_name, :guardian_phone, :guardian_email, :guardian_photo, :minor,
|
||||
:signature_base64, :person_date_of_birth,
|
||||
:locale, :contract_template,)
|
||||
end
|
||||
|
||||
@@ -39,6 +39,7 @@ class AppearanceRelease < ApplicationRecord
|
||||
# These validations apply to releases being signed by a minor
|
||||
with_options if: :minor? do
|
||||
validates :guardian_first_name, :guardian_last_name, presence: true
|
||||
validates :guardian_email, email: true, allow_blank: true
|
||||
end
|
||||
|
||||
validates :person_photo, content_type: face_photo_acceptable_content_types
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
<%= description_list_pair_for releasable, :guardian_name, append: ":" %>
|
||||
<%= description_list_pair_for releasable, :guardian_address, append: ":" %>
|
||||
<%= description_list_pair_for releasable, :guardian_phone, append: ":" %>
|
||||
<%= description_list_pair_for releasable, :guardian_email, append: ":" %>
|
||||
<%= description_list_pair_for releasable, :signed_on, append: ":" %>
|
||||
</dl>
|
||||
|
||||
|
||||
@@ -76,6 +76,9 @@
|
||||
<%= form.text_field :guardian_last_name, required: @appearance_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>
|
||||
<div class="form-row">
|
||||
<%= form.text_field :guardian_address, wrapper_class: "col-sm-6" %>
|
||||
</div>
|
||||
|
||||
@@ -163,6 +163,7 @@ Rails.application.routes.draw do
|
||||
resources :appearance_releases, only: [:show] do
|
||||
resources :notes, controller: "notes", only: [:create, :index]
|
||||
end
|
||||
resources :direct_uploads, only: [:create]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddGuardianEmailToAppearanceReleases < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :appearance_releases, :guardian_email, :string
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class RemoveBroadcastIdFromZoomMeetings < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
remove_column :zoom_meetings, :broadcast_id
|
||||
end
|
||||
end
|
||||
@@ -330,7 +330,8 @@ CREATE TABLE public.appearance_releases (
|
||||
person_first_name character varying,
|
||||
person_last_name character varying,
|
||||
guardian_first_name character varying,
|
||||
guardian_last_name character varying
|
||||
guardian_last_name character varying,
|
||||
guardian_email character varying
|
||||
);
|
||||
|
||||
|
||||
@@ -1252,7 +1253,6 @@ CREATE TABLE public.settings (
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.settings_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
@@ -1288,7 +1288,6 @@ CREATE TABLE public.taggings (
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.taggings_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
@@ -1319,7 +1318,6 @@ CREATE TABLE public.tags (
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.tags_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
@@ -3617,6 +3615,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20200603090419'),
|
||||
('20200606044747'),
|
||||
('20200610085411'),
|
||||
('20200610140459');
|
||||
('20200610140459'),
|
||||
('20200612121539');
|
||||
|
||||
|
||||
|
||||
36
spec/controllers/api/direct_uploads_controller_spec.rb
Normal file
36
spec/controllers/api/direct_uploads_controller_spec.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Api::DirectUploadsController, type: :controller do
|
||||
let(:current_user) { create(:user) }
|
||||
let(:project) { create(:project, account: current_user.primary_account) }
|
||||
|
||||
before do
|
||||
sign_in_to_api(current_user)
|
||||
end
|
||||
|
||||
describe '#create' do
|
||||
it 'returns data for a direct upload' do
|
||||
post :create, params: { blob: blob_params }
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response_body_data_attributes).to include('id', 'key', 'signed_id', 'url', 'headers')
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def blob_params
|
||||
file = file_fixture("video_file.mp4")
|
||||
checksum = Digest::MD5.base64digest(StringIO.new(file.read).to_s)
|
||||
|
||||
{ filename: file.basename.to_s, content_type: "video/mp4", byte_size: file.size, checksum: checksum }
|
||||
end
|
||||
|
||||
def response_body_data
|
||||
JSON.parse(response.body).dig('data')
|
||||
end
|
||||
|
||||
def response_body_data_attributes
|
||||
response_body_data.dig('attributes')
|
||||
end
|
||||
end
|
||||
@@ -263,7 +263,9 @@ RSpec.describe AppearanceReleasesController, tye: :controller do
|
||||
end
|
||||
|
||||
def minor_appearance_release_params
|
||||
attributes_for(:appearance_release, :non_native, :minor_with_guardian_photo).except(:contract).merge(contract_param, exploitable_rights_params)
|
||||
attributes_for(:appearance_release, :non_native, :minor_with_guardian_photo)
|
||||
.except(:contract)
|
||||
.merge(contract_param, exploitable_rights_params)
|
||||
end
|
||||
|
||||
def exploitable_rights_params
|
||||
|
||||
@@ -33,6 +33,7 @@ FactoryBot.define do
|
||||
guardian_last_name "Doe"
|
||||
guardian_address "100 Test Lane, New York, 10001"
|
||||
guardian_phone "123-555-1234"
|
||||
guardian_email "guardian@galaxy.all"
|
||||
end
|
||||
|
||||
trait :minor_with_guardian_photo do
|
||||
@@ -41,6 +42,7 @@ FactoryBot.define do
|
||||
guardian_last_name "Doe"
|
||||
guardian_address "100 Test Lane, New York, 10001"
|
||||
guardian_phone "123-555-1234"
|
||||
guardian_email "guardian@galaxy.all"
|
||||
guardian_photo do
|
||||
path = Rails.root.join("spec", "fixtures", "files", "pratt.jpg")
|
||||
Rack::Test::UploadedFile.new(path, "image/jpeg")
|
||||
|
||||
@@ -25,7 +25,7 @@ feature 'User managing appearance releases' do
|
||||
fill_in person_date_of_birth, with: '01/01/1999'
|
||||
attach_file person_photo_field, file_fixture('person_photo.png'), visible: :all
|
||||
draw_signature file_fixture('signature.png'), 'appearance_release_signature_base64'
|
||||
click_button 'I have read and agree to the above'
|
||||
click_button submit_release_button
|
||||
|
||||
expect(page).to have_content(successful_submission_message)
|
||||
end
|
||||
@@ -45,6 +45,7 @@ feature 'User managing appearance releases' do
|
||||
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'
|
||||
|
||||
fill_in guardian_first_name_field, with: 'Guardian'
|
||||
fill_in guardian_last_name_field, with: 'Name'
|
||||
@@ -58,7 +59,14 @@ feature 'User managing appearance releases' do
|
||||
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'
|
||||
click_button 'I have read and agree to the above'
|
||||
|
||||
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'
|
||||
draw_signature file_fixture('signature.png'), 'appearance_release_signature_base64'
|
||||
click_button submit_release_button
|
||||
|
||||
expect(page).to have_content(successful_submission_message)
|
||||
end
|
||||
@@ -249,6 +257,7 @@ feature 'User managing appearance releases' do
|
||||
expect(pdf_body).to have_content('TAGS')
|
||||
expect(pdf_body).to have_content('Woman')
|
||||
expect(pdf_body).to have_content('Brunette')
|
||||
expect(pdf_body).not_to have_content('Guardian Email')
|
||||
end
|
||||
|
||||
scenario 'viewing contract PDF for a minor without guardian photo' do
|
||||
@@ -262,8 +271,10 @@ feature 'User managing appearance releases' do
|
||||
expect(pdf_filename).to include(appearance_release.filename_suffix.parameterize)
|
||||
expect(pdf_body).to have_content(appearance_release.name)
|
||||
expect(pdf_body).to have_content(appearance_release.guardian_name)
|
||||
expect(pdf_body).to have_content(appearance_release.guardian_email)
|
||||
expect(pdf_body).to have_content photos_heading.upcase
|
||||
expect(pdf_body).to have_content(appearance_release.photo.filename.to_s)
|
||||
expect(pdf_body).to have_content('Guardian Email')
|
||||
end
|
||||
|
||||
scenario 'viewing contract PDF for a minor with guardian photo' do
|
||||
@@ -277,9 +288,11 @@ feature 'User managing appearance releases' do
|
||||
expect(pdf_filename).to include(appearance_release.filename_suffix.parameterize)
|
||||
expect(pdf_body).to have_content(appearance_release.name)
|
||||
expect(pdf_body).to have_content(appearance_release.guardian_name)
|
||||
expect(pdf_body).to have_content(appearance_release.guardian_email)
|
||||
expect(pdf_body).to have_content photos_heading(2).upcase
|
||||
expect(pdf_body).to have_content(appearance_release.photo.filename.to_s)
|
||||
expect(pdf_body).to have_content(appearance_release.guardian_photo.filename.to_s)
|
||||
expect(pdf_body).to have_content('Guardian Email')
|
||||
end
|
||||
|
||||
scenario 'deleting a release', js: true do
|
||||
@@ -470,6 +483,10 @@ feature 'User managing appearance releases' do
|
||||
'Guardian phone'
|
||||
end
|
||||
|
||||
def guardian_email_field
|
||||
'Guardian email'
|
||||
end
|
||||
|
||||
def guardian_photo_field
|
||||
'appearance_release[guardian_photo]'
|
||||
end
|
||||
@@ -518,6 +535,10 @@ feature 'User managing appearance releases' do
|
||||
'Import Release'
|
||||
end
|
||||
|
||||
def submit_release_button
|
||||
'I have read and agree to the above'
|
||||
end
|
||||
|
||||
def submit_update_button
|
||||
'Save Changes'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user