2019-06-06 13:58:49 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# A special plan associated which can be associated with some users (with role 'partner')
|
|
|
|
# These partners will be notified when the subscribers to this plan are realizing some actions
|
2016-03-23 18:39:41 +01:00
|
|
|
class PartnerPlan < Plan
|
|
|
|
resourcify
|
|
|
|
|
|
|
|
before_create :assign_default_values
|
|
|
|
|
|
|
|
def partners
|
2019-06-06 13:58:49 +02:00
|
|
|
User.joins(:roles).where(roles: { name: 'partner', resource_type: 'PartnerPlan', resource_id: id })
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
2019-06-06 13:58:49 +02:00
|
|
|
|
2016-03-23 18:39:41 +01:00
|
|
|
def assign_default_values
|
|
|
|
assign_attributes(is_rolling: false)
|
|
|
|
end
|
|
|
|
end
|