Compare commits
4 Commits
update-bro
...
enable-big
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
057bdfe882 | ||
|
|
545d12f427 | ||
|
|
ac7e67c20e | ||
|
|
9bafbe36db |
@@ -1,7 +1,4 @@
|
||||
$(document).on("click", "[data-behavior=play_recording]", function() {
|
||||
clearPlayingHighlight();
|
||||
$(this).parent().parent().addClass('playing-highlight');
|
||||
|
||||
$("#broadcast_video").data('videoType', 'recording');
|
||||
|
||||
var playback_url = $(this).attr("data-playback-url")
|
||||
@@ -17,11 +14,4 @@ $(document).on("click", "[data-behavior=play_recording]", function() {
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "[data-behavior=play_stream]", function() {
|
||||
// clearPlayingHighlight();
|
||||
$("#broadcast_video").data('videoType', 'stream');
|
||||
});
|
||||
|
||||
function clearPlayingHighlight() {
|
||||
$(".playing-highlight").removeClass("playing-highlight");
|
||||
}
|
||||
$(document).on("click", "[data-behavior=play_stream]", function() { $("#broadcast_video").data('videoType', 'stream'); });
|
||||
@@ -467,31 +467,4 @@ trix-toolbar {
|
||||
.trix-button--icon-underline::before {
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z'/%3E%3C/svg%3E");
|
||||
}
|
||||
}
|
||||
|
||||
// Play button SVG
|
||||
.play-btn {
|
||||
width: 60%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.play-btn-svg{
|
||||
transition: 0.3s;
|
||||
stroke:#fedfc2;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.play-btn:hover .play-btn-svg {
|
||||
fill-opacity: 0;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
// Play button in video thumbnail preview
|
||||
.play-thumbnail { position: relative; }
|
||||
.play-thumbnail img { display: block; }
|
||||
.play-thumbnail .play-btn { position: absolute; bottom:5px; left:10px; }
|
||||
|
||||
// Active recording highlight
|
||||
.playing-highlight {
|
||||
background-color: rgba(182, 203, 205, 1);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
class AccountSessionsController < ApplicationController
|
||||
skip_before_action :redirect_locked_accounts
|
||||
def update
|
||||
authorize :account_session, :update?
|
||||
session[:active_account] = account_session_params[:account_id]
|
||||
|
||||
31
app/controllers/admin/account_locks_controller.rb
Normal file
31
app/controllers/admin/account_locks_controller.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
class Admin::AccountLocksController < Admin::ApplicationController
|
||||
before_action :set_account
|
||||
|
||||
def create
|
||||
authorize :account_lock, :create?
|
||||
@account.update(locked: true)
|
||||
redirect_to admin_accounts_path, notice: 'Account locked'
|
||||
end
|
||||
|
||||
def destroy
|
||||
authorize :account_lock, :destroy?
|
||||
@account.update(locked: false)
|
||||
redirect_to admin_accounts_path, notice: 'Account unlocked'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_account
|
||||
if params[:account_id].present?
|
||||
@account = Account.find_by(slug: params[:account_id])
|
||||
else
|
||||
failure_redirect
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
failure_redirect
|
||||
end
|
||||
|
||||
def failure_redirect
|
||||
redirect_to admin_accounts_path, alert: 'Failed to find the account'
|
||||
end
|
||||
end
|
||||
@@ -13,6 +13,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
include SetCurrentRequestDetails
|
||||
before_action :redirect_accountless
|
||||
before_action :redirect_locked_accounts
|
||||
|
||||
private
|
||||
|
||||
@@ -29,6 +30,12 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
def redirect_locked_accounts
|
||||
if Current.user && !Current.user.admin? && Current.account.present? && Current.account.locked?
|
||||
redirect_to locked_account_path
|
||||
end
|
||||
end
|
||||
|
||||
def signed_in_as_admin?
|
||||
signed_in? && current_user.admin?
|
||||
end
|
||||
|
||||
10
app/controllers/locked_accounts_controller.rb
Normal file
10
app/controllers/locked_accounts_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class LockedAccountsController < ApplicationController
|
||||
skip_before_action :redirect_locked_accounts
|
||||
skip_after_action :verify_policy_scoped
|
||||
|
||||
def index
|
||||
unless Current.account.locked?
|
||||
redirect_to projects_path
|
||||
end
|
||||
end
|
||||
end
|
||||
9
app/policies/account_lock_policy.rb
Normal file
9
app/policies/account_lock_policy.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class AccountLockPolicy < ApplicationPolicy
|
||||
def create?
|
||||
user.admin?
|
||||
end
|
||||
|
||||
def destroy?
|
||||
user.admin?
|
||||
end
|
||||
end
|
||||
@@ -30,6 +30,11 @@
|
||||
<%= link_to fa_icon("arrow-right", text: "Overview"), admin_account_path(account), class: "dropdown-item" %>
|
||||
<%= link_to fa_icon("pencil", text: "Edit"), edit_admin_account_path(account), class: "dropdown-item" %>
|
||||
<%= link_to fa_icon("arrow-right", text: "Account Managers"), account_auths_path({ account_id: account.id}), class: "dropdown-item" %>
|
||||
<% if account.locked? %>
|
||||
<%= link_to fa_icon("unlock", text: "Unlock Account"), [:admin, account, :lock], method: :delete, class: "dropdown-item" %>
|
||||
<% else %>
|
||||
<%= link_to fa_icon("lock", text: "Lock Account"), [:admin, account, :lock], method: :post, class: "dropdown-item" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -1,30 +1,26 @@
|
||||
<% if recordings.present? %>
|
||||
<ul class="list-unstyled">
|
||||
<div class="list-group">
|
||||
<% recordings.each do |recording| %>
|
||||
<li class="media pb-1 pt-1 pr-1">
|
||||
<% if policy(BroadcastRecording).update? %>
|
||||
<%= link_to fa_icon("#{recording.starred ? 'star' : 'star-o'} fw"), [broadcast.project, broadcast, recording, :broadcast_recording_starrings], method: :post, class: "text-warning mr-3", remote: true %>
|
||||
<% end %>
|
||||
|
||||
<div class="play-thumbnail">
|
||||
<%= image_tag(recording.thumbnail_url, class: 'mr-3', size: "75x64") %>
|
||||
<%= render "broadcasts/play_button", playback_url: recording.playback_url, data_id: dom_id(recording) %>
|
||||
<div class="list-group-item list-group-item-action">
|
||||
<div class="d-flex align-items-start">
|
||||
<% if policy(BroadcastRecording).update? %>
|
||||
<%= link_to fa_icon("#{recording.starred ? 'star' : 'star-o'} fw"), [broadcast.project, broadcast, recording, :broadcast_recording_starrings], method: :post, class: "text-warning mr-3", remote: true %>
|
||||
<% end %>
|
||||
<%= image_tag(recording.thumbnail_url, class: 'img-thumbnail img-fluid max-w-75', data: { behavior: "play_recording", playback_url: recording.playback_url, id: dom_id(recording) }) %>
|
||||
<div class="ml-auto">
|
||||
<% if policy(BroadcastRecording).edit? %>
|
||||
<%= link_to fa_icon('edit'), [:edit, broadcast.project, broadcast, recording], remote: true %>
|
||||
<% end %>
|
||||
<%= link_to(fa_icon('download'), recording.download_url, target: "_blank") %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="media-body">
|
||||
<h5 class="mt-0 mb-1"><%= recording.name %></h5>
|
||||
<%= recording.description %>
|
||||
<div class="d-flex flex-column align-items-start justify-content-start p-4">
|
||||
<h5><%= recording.name %></h5>
|
||||
<p><%= recording.description %></p>
|
||||
</div>
|
||||
|
||||
<% if policy(BroadcastRecording).edit? %>
|
||||
<%= link_to fa_icon('edit'), [:edit, broadcast.project, broadcast, recording], class: "mr-3", remote: true %>
|
||||
<% end %>
|
||||
|
||||
<%= link_to(fa_icon('download'), recording.download_url, target: "_blank") %>
|
||||
</li>
|
||||
</div>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div id="recordings_pagination" class="row mt-5 justify-content-center">
|
||||
<%= will_paginate(recordings, params: {controller: "broadcasts", action: "show", project_id: broadcast.project_id, id: broadcast.id, page: params[:page], active_tab: 'recordings'}) %>
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<div id="live-take" class="media p-1 playing-highlight">
|
||||
<img class="mr-5 ml-1 mt-1" src="https://via.placeholder.com/64" alt="Live stream thumbnail">
|
||||
<div class="media-body">
|
||||
<h5 class="mt-0"><%= broadcast.name %></h5>
|
||||
<small>Created - <%= time_ago_in_words(broadcast.created_at) + " ago" %></small>
|
||||
<div class="list-group">
|
||||
<div class="list-group-item list-group-item-action flex-column align-items-start">
|
||||
<div class="d-flex w-100 justify-content-between mb-1">
|
||||
<h5 class="mb-1"><%= broadcast.name %></h5>
|
||||
<small>Created - <%= time_ago_in_words(broadcast.created_at) + " ago" %></small>
|
||||
</div>
|
||||
<div id="broadcast_updates">
|
||||
<%= render partial: 'broadcasts/broadcast_status', locals: { broadcast: broadcast } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<div class="play-btn" data-behavior="play_recording" data-playback-url="<%= playback_url %>" data-id="<%= data_id %>">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 26 26">
|
||||
<polygon class="play-btn-svg" points="9.33 6.69 9.33 19.39 19.3 13.04 9.33 6.69"/>
|
||||
</svg>
|
||||
</div>
|
||||
1
app/views/locked_accounts/index.html.erb
Normal file
1
app/views/locked_accounts/index.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<p><%= t '.account_locked_message' %></p>
|
||||
@@ -1651,3 +1651,6 @@ en:
|
||||
edit: Edit
|
||||
report: Report
|
||||
generating: Generating...
|
||||
locked_accounts:
|
||||
index:
|
||||
account_locked_message: This account is locked. Please contact a BIG admin.
|
||||
|
||||
@@ -705,3 +705,6 @@ es:
|
||||
production_elements_logs: Production Elements Logs, and more (ES)
|
||||
reduces_labor_cost: Reduces labor costs (ES)
|
||||
simplifies_cue_sheets: Simplifies Music Cue Sheets, Graphic Cue Sheets (ES)
|
||||
locked_accounts:
|
||||
index:
|
||||
account_locked_message: This account is locked. Please contact a BIG admin. (ES)
|
||||
|
||||
@@ -30,7 +30,9 @@ Rails.application.routes.draw do
|
||||
namespace :admin do
|
||||
mount Sidekiq::Web => '/background_queue', as: :background_queue
|
||||
|
||||
resources :accounts, only: [:index, :new, :create, :edit, :update, :show]
|
||||
resources :accounts, only: [:index, :new, :create, :edit, :update, :show] do
|
||||
resource :account_lock, path: :lock, as: :lock, only: [:create, :destroy]
|
||||
end
|
||||
resources :users, only: [:index, :new, :create, :edit, :update, :destroy] do
|
||||
resource :masquerade, only: :create
|
||||
end
|
||||
@@ -48,7 +50,9 @@ Rails.application.routes.draw do
|
||||
scope "(:locale)", locale: AVAILABLE_LOCALES_REGEX do
|
||||
resource :account_session, only: [:update]
|
||||
resource :session, only: [:destroy]
|
||||
resource :account, only: [:new, :create, :update]
|
||||
resource :account, only: [:new, :create, :update] do
|
||||
get 'locked' => 'locked_accounts#index'
|
||||
end
|
||||
resources :account_auths, only: [:index, :create, :update, :destroy]
|
||||
resources :projects, shallow: true do
|
||||
resources :acquired_media_releases, except: [:show], concerns: [:contractable, :notable, :file_uploadable]
|
||||
|
||||
5
db/migrate/20200908085319_add_locked_to_accounts.rb
Normal file
5
db/migrate/20200908085319_add_locked_to_accounts.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddLockedToAccounts < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :accounts, :locked, :boolean, default: false
|
||||
end
|
||||
end
|
||||
@@ -95,7 +95,8 @@ CREATE TABLE public.accounts (
|
||||
slug character varying,
|
||||
plan_uid character varying,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL
|
||||
updated_at timestamp without time zone NOT NULL,
|
||||
locked boolean DEFAULT false
|
||||
);
|
||||
|
||||
|
||||
@@ -4027,6 +4028,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20200812060406'),
|
||||
('20200819070738'),
|
||||
('20200820082501'),
|
||||
('20200824171649');
|
||||
('20200824171649'),
|
||||
('20200908085319');
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,24 @@ feature "Admin managing accounts" do
|
||||
expect(page).to have_content "Created at less than a minute ago"
|
||||
end
|
||||
|
||||
scenario "locks and unlocks account" do
|
||||
sign_in current_user
|
||||
visit admin_signed_in_root_path
|
||||
expect(Account.last.locked?).to eq false
|
||||
|
||||
click_button "Manage"
|
||||
expect(page).not_to have_content "Unlock Account"
|
||||
click_link "Lock Account"
|
||||
|
||||
expect(Account.last.locked?).to eq true
|
||||
|
||||
click_button "Manage"
|
||||
expect(page).not_to have_content "Lock Account"
|
||||
click_link "Unlock Account"
|
||||
|
||||
expect(Account.last.locked?).to eq false
|
||||
end
|
||||
|
||||
scenario "sees videos for an account in the system" do
|
||||
visit_account_overview_page
|
||||
|
||||
|
||||
@@ -151,41 +151,6 @@ feature 'User managing broadcasts' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'broadcast recordings are shown in correct layout', js: true do
|
||||
broadcast = create(:broadcast, :with_stream, :with_files, project: project)
|
||||
create(:broadcast_recording, broadcast: broadcast, asset_uid: "asset_uid_1")
|
||||
|
||||
visit project_broadcast_path(project, broadcast)
|
||||
|
||||
expect(page).to have_selector("li.media")
|
||||
expect(page).to have_selector("div.play-thumbnail")
|
||||
expect(page).to have_selector("div.media-body")
|
||||
expect(page).to have_selector("div.play-btn")
|
||||
end
|
||||
|
||||
scenario 'active playing media has highlighted background (live take or recording)', js: true do
|
||||
broadcast = create(:broadcast, :with_stream, :with_files, project: project)
|
||||
create(:broadcast_recording, broadcast: broadcast, asset_uid: "asset_uid_1")
|
||||
create(:broadcast_recording, broadcast: broadcast, asset_uid: "asset_uid_2")
|
||||
|
||||
visit project_broadcast_path(project, broadcast)
|
||||
|
||||
expect(page).to have_selector("#live-take.playing-highlight")
|
||||
expect(page).to have_selector(".play-btn-svg", count: 2, visible: false)
|
||||
|
||||
first("[data-behavior='play_recording']").click
|
||||
|
||||
expect(page).not_to have_selector("#live-take.playing-highlight")
|
||||
expect(page).to have_selector("li.media.playing-highlight", count: 1)
|
||||
expect(page).to have_selector("li.media", count: 2)
|
||||
|
||||
first("[data-behavior='play_stream']").click
|
||||
|
||||
expect(page).to have_selector("#live-take.playing-highlight")
|
||||
expect(page).to have_selector("li.media", count: 2)
|
||||
expect(page).not_to have_selector("li.media.playing-highlight")
|
||||
end
|
||||
|
||||
context 'When the user is associate' do
|
||||
let(:current_user) { create(:user, :associate) }
|
||||
|
||||
|
||||
34
spec/features/user_managing_locked_account_spec.rb
Normal file
34
spec/features/user_managing_locked_account_spec.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
require "rails_helper"
|
||||
|
||||
feature "User managing locked account" do
|
||||
let(:user) { create(:user, :account_manager) }
|
||||
let(:project) { create(:project) }
|
||||
|
||||
before do
|
||||
sign_in(user)
|
||||
user.accounts.first.update(locked: true)
|
||||
end
|
||||
|
||||
scenario "user is redirected to custom landing page when opens projects index page" do
|
||||
paths = [
|
||||
projects_path,
|
||||
project_path(project),
|
||||
project_task_requests_path(project),
|
||||
project_contract_templates_path(project),
|
||||
project_broadcasts_path(project),
|
||||
project_videos_path(project),
|
||||
]
|
||||
|
||||
paths.each do |path|
|
||||
visit path
|
||||
|
||||
expect(page).to have_content locked_account_warning
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def locked_account_warning
|
||||
t 'locked_accounts.index.account_locked_message'
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user