Class: ActivityAgenda
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ActivityAgenda
- Includes:
- Models::Auditable
- Defined in:
- app/models/activity_agenda.rb
Overview
== Schema Information
Table name: activity_agendas
Database name: primary
id :integer not null, primary key
comment :string
event :enum not null
final_rule :boolean default(FALSE), not null
position :integer not null
created_at :datetime not null
updated_at :datetime not null
activity_type_id :integer
creator_id :integer
customer_filter_id :integer
updater_id :integer
Indexes
activity_agendas_customer_filter_id_idx (customer_filter_id)
idx_activity_agendas_unique (activity_type_id,customer_filter_id) UNIQUE
Foreign Keys
fk_rails_... (activity_type_id => activity_types.id)
fk_rails_... (customer_filter_id => customer_filters.id)
Constant Summary
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Constants included from Schedulable
Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
- #event ⇒ Object readonly
Belongs to collapse
Methods included from Models::Auditable
Class Method Summary collapse
-
.for_customer ⇒ ActiveRecord::Relation<ActivityAgenda>
A relation of ActivityAgendas that are for customer.
- .seek_lead_assigned_activities(customer) ⇒ Object
Instance Method Summary collapse
-
#to_partial_path ⇒ Object
Partial lives under
app/views/crm/activity_agendas/, not the conventionalapp/views/activity_agendas/.
Methods included from Models::Auditable
#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#event ⇒ Object (readonly)
43 |
# File 'app/models/activity_agenda.rb', line 43 validates :activity_type, :customer_filter, :event, presence: true |
Class Method Details
.for_customer ⇒ ActiveRecord::Relation<ActivityAgenda>
A relation of ActivityAgendas that are for customer. Active Record Scope
51 |
# File 'app/models/activity_agenda.rb', line 51 scope :for_customer, ->(customer) { where(customer_filter_id: CustomerFilter::QueryBuilder.filter_ids_for_customer(customer)).order(:position) } |
.seek_lead_assigned_activities(customer) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/activity_agenda.rb', line 53 def self.seek_lead_assigned_activities(customer) activity_agendas = [] ActivityAgenda.for_customer(customer).lead_assigned.each do |activity_agenda| # Do a secondary check on customer filter for opportunity which is at this point not in query builder if activity_agenda.customer_filter.has_opportunity_match?(customer) activity_agendas << activity_agenda break if activity_agenda.final_rule end end activity_agendas end |
Instance Method Details
#activity_type ⇒ ActivityType
Validations:
40 |
# File 'app/models/activity_agenda.rb', line 40 belongs_to :activity_type, optional: true |
#customer_filter ⇒ CustomerFilter
Validations:
41 |
# File 'app/models/activity_agenda.rb', line 41 belongs_to :customer_filter, optional: true |
#to_partial_path ⇒ Object
Partial lives under app/views/crm/activity_agendas/, not the
conventional app/views/activity_agendas/. Override so
render @activity_agendas (or render activity_agenda) resolves
correctly from any controller, not just Crm::ActivityAgendasController.
36 37 38 |
# File 'app/models/activity_agenda.rb', line 36 def to_partial_path 'crm/activity_agendas/activity_agenda' end |