73 lines
3.0 KiB
Ruby
73 lines
3.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Releasable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
belongs_to :project, touch: true
|
|
belongs_to :contract_template, optional: true
|
|
|
|
scope :order_by_recent, -> { order(created_at: :desc) }
|
|
end
|
|
|
|
def release_number
|
|
@release_number ||= ReleaseNumber.new(self).value
|
|
end
|
|
|
|
def signed_on
|
|
if respond_to?(:signed_at) && signed_at.present?
|
|
signed_at.strftime('%D')
|
|
else
|
|
created_at.strftime('%D')
|
|
end
|
|
end
|
|
|
|
def fill_with_dummy_data(previewed_contract_template)
|
|
self.contract_template = previewed_contract_template
|
|
self.project_id = contract_template.project_id
|
|
self.created_at = DateTime.current
|
|
self.name = 'Dummy Name' if has_attribute? :name
|
|
self.person_first_name = 'Dummy' if has_attribute? :person_first_name
|
|
self.person_last_name = 'Person' if has_attribute? :person_last_name
|
|
if has_attribute? :person_date_of_birth
|
|
self.person_date_of_birth = DateTime.current
|
|
end
|
|
if has_attribute? :person_address_street1
|
|
self.person_address_street1 = 'Street 1'
|
|
end
|
|
if has_attribute? :person_address_street2
|
|
self.person_address_street2 = 'Street 2'
|
|
end
|
|
self.person_address_city = 'City' if has_attribute? :person_address_city
|
|
self.person_address_state = 'State' if has_attribute? :person_address_state
|
|
self.person_address_zip = 12_345 if has_attribute? :person_address_zip
|
|
if has_attribute? :person_address_country
|
|
self.person_address_country = 'Country'
|
|
end
|
|
if has_attribute? :person_address
|
|
self.person_address = 'Street 1, Street 2, City, State 12345, Country'
|
|
end
|
|
self.person_phone = '00 111 222 333 4444' if has_attribute? :person_phone
|
|
self.person_email = 'email@email.com' if has_attribute? :person_email
|
|
self.description = 'Dummy description' if has_attribute? :description
|
|
self.filming_started_on = DateTime.current if has_attribute? :filming_started_on
|
|
self.filming_ended_on = DateTime.current if has_attribute? :filming_ended_on
|
|
return if contract_template.guardian_clause.blank?
|
|
|
|
self.guardian_name = 'Guardian name' if has_attribute? :guardian_name
|
|
if has_attribute? :guardian_address
|
|
self.guardian_address = 'Street 3, Street 4, City-2, State-2 112233, Country-2'
|
|
end
|
|
self.guardian_address_street1 = 'Street 3' if has_attribute? :guardian_address_street1
|
|
self.guardian_address_street2 = 'Street 4' if has_attribute? :guardian_address_street2
|
|
self.guardian_address_city = 'City-2' if has_attribute? :guardian_address_city
|
|
self.guardian_address_state = 'State-2' if has_attribute? :guardian_address_state
|
|
self.guardian_address_zip = '112233' if has_attribute? :guardian_address_zip
|
|
self.guardian_address_country = 'Country-2' if has_attribute? :guardian_address_country
|
|
self.guardian_phone = '00 123 456 7890' if has_attribute? :guardian_phone
|
|
self.guardian_email = 'guardian.email@mail.com' if has_attribute? :guardian_email
|
|
self.minor = true if has_attribute? :minor
|
|
|
|
end
|
|
end
|