2015-04-20 18:35:22 +03:00
|
|
|
module Proposable
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
2015-09-02 00:07:50 +03:00
|
|
|
has_one :proposition, as: :proposable, dependent: :destroy
|
2015-07-29 17:54:41 +03:00
|
|
|
has_one :proposer, through: :proposition
|
2015-08-20 01:42:35 +03:00
|
|
|
delegate :email, to: :proposer, prefix: true
|
2015-04-20 18:35:22 +03:00
|
|
|
|
|
|
|
Proposition.defined_enums["status"].keys.each do |status|
|
|
|
|
scope status.to_sym, -> { joins(:proposition).where(propositions: {status: Proposition.defined_enums["status"][status]}) }
|
|
|
|
end
|
|
|
|
end
|
2015-08-20 01:42:35 +03:00
|
|
|
|
|
|
|
def proposable_type
|
|
|
|
self.class.model_name.human
|
|
|
|
end
|
|
|
|
|
|
|
|
def notification_email
|
|
|
|
conference.email
|
|
|
|
end
|
|
|
|
|
|
|
|
def proposable_title
|
|
|
|
title
|
|
|
|
end
|
|
|
|
|
|
|
|
def proposable_description
|
|
|
|
end
|
2015-04-20 18:35:22 +03:00
|
|
|
end
|