Initial commit
This commit is contained in:
25
app/policies/account_auth_policy.rb
Normal file
25
app/policies/account_auth_policy.rb
Normal 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
|
||||
23
app/policies/account_policy.rb
Normal file
23
app/policies/account_policy.rb
Normal 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
|
||||
5
app/policies/account_session_policy.rb
Normal file
5
app/policies/account_session_policy.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AccountSessionPolicy < Struct.new(:user, :account_session)
|
||||
def update?
|
||||
true
|
||||
end
|
||||
end
|
||||
33
app/policies/acquired_media_release_policy.rb
Normal file
33
app/policies/acquired_media_release_policy.rb
Normal 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
|
||||
13
app/policies/acts_as_taggable_on/tag_policy.rb
Normal file
13
app/policies/acts_as_taggable_on/tag_policy.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class ActsAsTaggableOn::TagPolicy < ApplicationPolicy
|
||||
def create?
|
||||
true
|
||||
end
|
||||
|
||||
def index?
|
||||
true
|
||||
end
|
||||
|
||||
def destroy?
|
||||
true
|
||||
end
|
||||
end
|
||||
29
app/policies/appearance_release_policy.rb
Normal file
29
app/policies/appearance_release_policy.rb
Normal 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
|
||||
49
app/policies/application_policy.rb
Normal file
49
app/policies/application_policy.rb
Normal 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
|
||||
9
app/policies/audio_confirmation_policy.rb
Normal file
9
app/policies/audio_confirmation_policy.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class AudioConfirmationPolicy < ApplicationPolicy
|
||||
def create?
|
||||
true
|
||||
end
|
||||
|
||||
def destroy?
|
||||
true
|
||||
end
|
||||
end
|
||||
15
app/policies/blank_contract_policy.rb
Normal file
15
app/policies/blank_contract_policy.rb
Normal 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
|
||||
17
app/policies/bookmark_policy.rb
Normal file
17
app/policies/bookmark_policy.rb
Normal 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
|
||||
21
app/policies/broadcast_policy.rb
Normal file
21
app/policies/broadcast_policy.rb
Normal 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
|
||||
5
app/policies/contract_policy.rb
Normal file
5
app/policies/contract_policy.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class ContractPolicy < ApplicationPolicy
|
||||
def show?
|
||||
user.manager? || user.account_manager?
|
||||
end
|
||||
end
|
||||
39
app/policies/contract_template_policy.rb
Normal file
39
app/policies/contract_template_policy.rb
Normal 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
|
||||
52
app/policies/directory_policy.rb
Normal file
52
app/policies/directory_policy.rb
Normal 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
|
||||
13
app/policies/download_policy.rb
Normal file
13
app/policies/download_policy.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class DownloadPolicy < ApplicationPolicy
|
||||
def index?
|
||||
true
|
||||
end
|
||||
|
||||
def create?
|
||||
true
|
||||
end
|
||||
|
||||
def destroy?
|
||||
true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module ExcelReports
|
||||
module AudioReports
|
||||
class BrayInnovationGroupMusicCueReportPolicy < ApplicationPolicy
|
||||
def show?
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module ExcelReports
|
||||
module AudioReports
|
||||
class DiscoveryMusicCueReportPolicy < ApplicationPolicy
|
||||
def show?
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module ExcelReports
|
||||
module AudioReports
|
||||
class NatGeoMusicCueSheetPolicy < ApplicationPolicy
|
||||
def show?
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module ExcelReports
|
||||
module AudioReports
|
||||
class NatGeoOriginalMusicLogPolicy < ApplicationPolicy
|
||||
def show?
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module ExcelReports
|
||||
module GraphicReports
|
||||
class DiscoveryGfxCueListPolicy < ApplicationPolicy
|
||||
def show?
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module ExcelReports
|
||||
module GraphicReports
|
||||
class NatGeoTextGraphicsLogPolicy < ApplicationPolicy
|
||||
def show?
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module ExcelReports
|
||||
module IssuesAndConcernsReports
|
||||
class IssuesAndConcernsReportPolicy < ApplicationPolicy
|
||||
def show?
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module ExcelReports
|
||||
module VideoReports
|
||||
class DiscoveryProductionElementsLogPolicy < ApplicationPolicy
|
||||
def show?
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module ExcelReports
|
||||
module VideoReports
|
||||
class NatGeoLegalBinderLogPolicy < ApplicationPolicy
|
||||
def show?
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
13
app/policies/graphics_element_policy.rb
Normal file
13
app/policies/graphics_element_policy.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class GraphicsElementPolicy < ApplicationPolicy
|
||||
def create?
|
||||
true
|
||||
end
|
||||
|
||||
def update?
|
||||
true
|
||||
end
|
||||
|
||||
def destroy?
|
||||
true
|
||||
end
|
||||
end
|
||||
5
app/policies/import_policy.rb
Normal file
5
app/policies/import_policy.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class ImportPolicy < ApplicationPolicy
|
||||
def create?
|
||||
true
|
||||
end
|
||||
end
|
||||
37
app/policies/location_release_policy.rb
Normal file
37
app/policies/location_release_policy.rb
Normal 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
|
||||
9
app/policies/masquerade_policy.rb
Normal file
9
app/policies/masquerade_policy.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class MasqueradePolicy < Struct.new(:user, :masquerade)
|
||||
def create?
|
||||
user.admin?
|
||||
end
|
||||
|
||||
def destroy?
|
||||
true
|
||||
end
|
||||
end
|
||||
37
app/policies/material_release_policy.rb
Normal file
37
app/policies/material_release_policy.rb
Normal 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
|
||||
25
app/policies/music_release_policy.rb
Normal file
25
app/policies/music_release_policy.rb
Normal 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
|
||||
5
app/policies/note_policy.rb
Normal file
5
app/policies/note_policy.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class NotePolicy < ApplicationPolicy
|
||||
def create?
|
||||
true
|
||||
end
|
||||
end
|
||||
9
app/policies/profile_policy.rb
Normal file
9
app/policies/profile_policy.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class ProfilePolicy < ApplicationPolicy
|
||||
def show?
|
||||
user == record
|
||||
end
|
||||
|
||||
def update?
|
||||
user == record
|
||||
end
|
||||
end
|
||||
10
app/policies/project_membership_policy.rb
Normal file
10
app/policies/project_membership_policy.rb
Normal 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
|
||||
39
app/policies/project_policy.rb
Normal file
39
app/policies/project_policy.rb
Normal 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
|
||||
5
app/policies/qr_code_policy.rb
Normal file
5
app/policies/qr_code_policy.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class QrCodePolicy < ApplicationPolicy
|
||||
def show?
|
||||
true
|
||||
end
|
||||
end
|
||||
5
app/policies/release_policy.rb
Normal file
5
app/policies/release_policy.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class ReleasePolicy < ApplicationPolicy
|
||||
def notes?
|
||||
true
|
||||
end
|
||||
end
|
||||
37
app/policies/talent_release_policy.rb
Normal file
37
app/policies/talent_release_policy.rb
Normal 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
|
||||
13
app/policies/unreleased_appearance_policy.rb
Normal file
13
app/policies/unreleased_appearance_policy.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class UnreleasedAppearancePolicy < ApplicationPolicy
|
||||
def create?
|
||||
true
|
||||
end
|
||||
|
||||
def update?
|
||||
true
|
||||
end
|
||||
|
||||
def destroy?
|
||||
true
|
||||
end
|
||||
end
|
||||
27
app/policies/user_policy.rb
Normal file
27
app/policies/user_policy.rb
Normal 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
|
||||
9
app/policies/video_analysis_policy.rb
Normal file
9
app/policies/video_analysis_policy.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class VideoAnalysisPolicy < ApplicationPolicy
|
||||
def create?
|
||||
user.admin?
|
||||
end
|
||||
|
||||
def show?
|
||||
user.admin?
|
||||
end
|
||||
end
|
||||
24
app/policies/video_policy.rb
Normal file
24
app/policies/video_policy.rb
Normal 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
|
||||
9
app/policies/video_release_confirmation_policy.rb
Normal file
9
app/policies/video_release_confirmation_policy.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class VideoReleaseConfirmationPolicy < ApplicationPolicy
|
||||
def create?
|
||||
true
|
||||
end
|
||||
|
||||
def destroy?
|
||||
true
|
||||
end
|
||||
end
|
||||
9
app/policies/videos/report_publication_policy.rb
Normal file
9
app/policies/videos/report_publication_policy.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class Videos::ReportPublicationPolicy < ApplicationPolicy
|
||||
def create?
|
||||
user.admin?
|
||||
end
|
||||
|
||||
def destroy?
|
||||
user.admin?
|
||||
end
|
||||
end
|
||||
5
app/policies/zoom_meeting_policy.rb
Normal file
5
app/policies/zoom_meeting_policy.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class ZoomMeetingPolicy < ApplicationPolicy
|
||||
def show?
|
||||
true
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user