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

19
app/models/directory.rb Normal file
View File

@@ -0,0 +1,19 @@
class Directory < ApplicationRecord
belongs_to :project
belongs_to :user
has_many_attached :files
validates :name, presence: true, uniqueness: { scope: :project_id }
enum permissions: { "Everyone": 0, "Account Managers & Project Managers": 1, "Account Managers Only": 2 }
enum category: { "Other": 0, "Finance": 1, "Scripts": 2, "Call Sheets": 3, "Photos": 4, "Videos": 5 }
scope :order_by_name, -> { order(name: :asc) }
scope :for_associates, -> { where(permissions: "Everyone") }
scope :for_project_managers, -> { where(permissions: ["Everyone", "Account Managers & Project Managers"]) }
def search_files(query)
files_attachments.joins(:blob).where("active_storage_blobs.filename ILIKE ?", "%#{query}%")
end
end