Initial commit

This commit is contained in:
Senad Uka
2020-05-31 22:38:19 +02:00
commit 858fafc3c5
1280 changed files with 65918 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
class AccountAuthPolicy < ApplicationPolicy
class Scope < Scope
def resolve
if user.admin?
scope.all
elsif user.account_manager?
scope.where(account: user.account)
else
scope.none
end
end
end
def create?
user.admin? || user.account_manager?
end
def update?
user.admin? || user.account_manager?
end
def destroy?
user.admin? || user.account_manager?
end
end

View File

@@ -0,0 +1,23 @@
class AccountPolicy < ApplicationPolicy
class Scope < Scope
def resolve
if user.admin?
scope.all
else
scope.where(id: user.accounts.map(&:id))
end
end
end
def create?
user.admin?
end
def show?
user.admin?
end
def update?
user.admin? || user.accounts.map(&:id).include?(record.id)
end
end

View File

@@ -0,0 +1,5 @@
class AccountSessionPolicy < Struct.new(:user, :account_session)
def update?
true
end
end

View File

@@ -0,0 +1,33 @@
class AcquiredMediaReleasePolicy < ApplicationPolicy
def create?
true
end
def show?
true
end
def update?
!record.native?
end
def destroy?
true
end
def tag_multiple?
true
end
def edit_file_infos?
true
end
def update_file_infos?
true
end
def download_multiple?
true
end
end

View File

@@ -0,0 +1,13 @@
class ActsAsTaggableOn::TagPolicy < ApplicationPolicy
def create?
true
end
def index?
true
end
def destroy?
true
end
end

View File

@@ -0,0 +1,29 @@
class AppearanceReleasePolicy < ReleasePolicy
def create?
true
end
def index?
true
end
def show?
true
end
def update?
!record.native?
end
def destroy?
true
end
def tag_multiple?
true
end
def download_multiple?
true
end
end

View File

@@ -0,0 +1,49 @@
class ApplicationPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
false
end
def show?
false
end
def create?
false
end
def new?
create?
end
def update?
false
end
def edit?
update?
end
def destroy?
false
end
class Scope
attr_reader :user, :scope
def initialize(user, scope)
@user = user
@scope = scope
end
def resolve
scope.all
end
end
end

View File

@@ -0,0 +1,9 @@
class AudioConfirmationPolicy < ApplicationPolicy
def create?
true
end
def destroy?
true
end
end

View File

@@ -0,0 +1,15 @@
# frozen_string_literal: true
class BlankContractPolicy < ApplicationPolicy
def show?
true
end
def new?
show?
end
def create?
show?
end
end

View File

@@ -0,0 +1,17 @@
class BookmarkPolicy < ApplicationPolicy
def create?
true
end
def edit?
create?
end
def update?
create?
end
def destroy?
true
end
end

View File

@@ -0,0 +1,21 @@
class BroadcastPolicy < ApplicationPolicy
def index?
true
end
def show?
true
end
def create?
user.manager? || user.account_manager?
end
def destroy?
create?
end
def update?
true
end
end

View File

@@ -0,0 +1,5 @@
class ContractPolicy < ApplicationPolicy
def show?
user.manager? || user.account_manager?
end
end

View File

@@ -0,0 +1,39 @@
class ContractTemplatePolicy < ApplicationPolicy
class Scope < Scope
def resolve
if user.account_manager?
scope.left_outer_joins(:project).where(projects: {account: user.account})
else
scope.left_outer_joins(project: :project_memberships).where(project_memberships: { user_id: user.id })
end
end
end
def create?
user.manager? || user.account_manager?
end
def show?
true
end
def destroy?
create?
end
def import?
if user.account_manager?
record.project.account = user.account
elsif user.manager?
user.project_memberships.exists?(project: record.project)
else
false
end
end
private
def has_signed_releases?
record.present? && !record.releases.size.zero?
end
end

View File

@@ -0,0 +1,52 @@
class DirectoryPolicy < ApplicationPolicy
class Scope < Scope
def resolve
case user.role
when "account_manager"
scope
when "project_manager"
scope.for_project_managers
when "associate"
scope.for_associates
else
scope.none
end
end
end
def create?
true
end
def edit?
true
end
def show?
true
end
def update?
true
end
def destroy?
true
end
def new_file?
true
end
def download_file?
true
end
def destroy_file?
true
end
def can_view_permissions_settings?
user.manager? || user.account_manager?
end
end

View File

@@ -0,0 +1,13 @@
class DownloadPolicy < ApplicationPolicy
def index?
true
end
def create?
true
end
def destroy?
true
end
end

View File

@@ -0,0 +1,9 @@
module ExcelReports
module AudioReports
class BrayInnovationGroupMusicCueReportPolicy < ApplicationPolicy
def show?
true
end
end
end
end

View File

@@ -0,0 +1,9 @@
module ExcelReports
module AudioReports
class DiscoveryMusicCueReportPolicy < ApplicationPolicy
def show?
true
end
end
end
end

View File

@@ -0,0 +1,9 @@
module ExcelReports
module AudioReports
class NatGeoMusicCueSheetPolicy < ApplicationPolicy
def show?
true
end
end
end
end

View File

@@ -0,0 +1,9 @@
module ExcelReports
module AudioReports
class NatGeoOriginalMusicLogPolicy < ApplicationPolicy
def show?
true
end
end
end
end

View File

@@ -0,0 +1,9 @@
module ExcelReports
module GraphicReports
class DiscoveryGfxCueListPolicy < ApplicationPolicy
def show?
true
end
end
end
end

View File

@@ -0,0 +1,9 @@
module ExcelReports
module GraphicReports
class NatGeoTextGraphicsLogPolicy < ApplicationPolicy
def show?
true
end
end
end
end

View File

@@ -0,0 +1,9 @@
module ExcelReports
module IssuesAndConcernsReports
class IssuesAndConcernsReportPolicy < ApplicationPolicy
def show?
true
end
end
end
end

View File

@@ -0,0 +1,9 @@
module ExcelReports
module VideoReports
class DiscoveryProductionElementsLogPolicy < ApplicationPolicy
def show?
true
end
end
end
end

View File

@@ -0,0 +1,9 @@
module ExcelReports
module VideoReports
class NatGeoLegalBinderLogPolicy < ApplicationPolicy
def show?
true
end
end
end
end

View File

@@ -0,0 +1,13 @@
class GraphicsElementPolicy < ApplicationPolicy
def create?
true
end
def update?
true
end
def destroy?
true
end
end

View File

@@ -0,0 +1,5 @@
class ImportPolicy < ApplicationPolicy
def create?
true
end
end

View File

@@ -0,0 +1,37 @@
class LocationReleasePolicy < ReleasePolicy
def create?
true
end
def show?
true
end
def index?
true
end
def update?
!record.native?
end
def destroy?
true
end
def edit_photos?
true
end
def update_photos?
edit_photos?
end
def tag_multiple?
true
end
def download_multiple?
true
end
end

View File

@@ -0,0 +1,9 @@
class MasqueradePolicy < Struct.new(:user, :masquerade)
def create?
user.admin?
end
def destroy?
true
end
end

View File

@@ -0,0 +1,37 @@
class MaterialReleasePolicy < ReleasePolicy
def create?
true
end
def show?
true
end
def update?
!record.native?
end
def index?
true
end
def destroy?
true
end
def edit_photos?
true
end
def update_photos?
edit_photos?
end
def tag_multiple?
true
end
def download_multiple?
true
end
end

View File

@@ -0,0 +1,25 @@
class MusicReleasePolicy < ReleasePolicy
def create?
true
end
def show?
true
end
def update?
true
end
def destroy?
true
end
def tag_multiple?
true
end
def download_multiple?
true
end
end

View File

@@ -0,0 +1,5 @@
class NotePolicy < ApplicationPolicy
def create?
true
end
end

View File

@@ -0,0 +1,9 @@
class ProfilePolicy < ApplicationPolicy
def show?
user == record
end
def update?
user == record
end
end

View File

@@ -0,0 +1,10 @@
class ProjectMembershipPolicy < ApplicationPolicy
def create?
# todo: harden the account manager case
user.manager? || user.account_manager?
end
def destroy?
create?
end
end

View File

@@ -0,0 +1,39 @@
class ProjectPolicy < ApplicationPolicy
class Scope < Scope
def resolve
if user.account_manager?
scope.joins(account: :account_auths).where(account_auths: { user_id: user.id })
else
scope.joins(:project_memberships).where(project_memberships: { user_id: user.id })
end
end
end
def index?
true
end
def create?
user.account_manager?
end
def show?
user.project_memberships.exists?(project: record) || user.account_manager?
end
def update?
user.manager? || user.account_manager?
end
def destroy?
false
end
def show_reports?
update?
end
def show_downloads?
show?
end
end

View File

@@ -0,0 +1,5 @@
class QrCodePolicy < ApplicationPolicy
def show?
true
end
end

View File

@@ -0,0 +1,5 @@
class ReleasePolicy < ApplicationPolicy
def notes?
true
end
end

View File

@@ -0,0 +1,37 @@
class TalentReleasePolicy < 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_multiple?
true
end
end

View File

@@ -0,0 +1,13 @@
class UnreleasedAppearancePolicy < ApplicationPolicy
def create?
true
end
def update?
true
end
def destroy?
true
end
end

View File

@@ -0,0 +1,27 @@
class UserPolicy < ApplicationPolicy
class Scope < Scope
def resolve
if user.admin?
scope.all
else
scope.none
end
end
end
def create?
user.admin? || user.account_manager?
end
def update?
user.admin?
end
def destroy?
user.admin?
end
def show?
user.account_manager?
end
end

View File

@@ -0,0 +1,9 @@
class VideoAnalysisPolicy < ApplicationPolicy
def create?
user.admin?
end
def show?
user.admin?
end
end

View File

@@ -0,0 +1,24 @@
class VideoPolicy < ApplicationPolicy
def create?
true
end
def show?
true
end
def update?
true
end
class Scope < Scope
def resolve
return scope.all if user.admin?
if user.account_manager?
scope.joins(project: { account: :account_auths }).where(account_auths: { user_id: user.id })
else
scope.joins(project: :project_memberships).where(projects: { project_memberships: { user: user.id }})
end
end
end
end

View File

@@ -0,0 +1,9 @@
class VideoReleaseConfirmationPolicy < ApplicationPolicy
def create?
true
end
def destroy?
true
end
end

View File

@@ -0,0 +1,9 @@
class Videos::ReportPublicationPolicy < ApplicationPolicy
def create?
user.admin?
end
def destroy?
user.admin?
end
end

View File

@@ -0,0 +1,5 @@
class ZoomMeetingPolicy < ApplicationPolicy
def show?
true
end
end