Merge remote-tracking branch 'origin/pr/22' into 2.0
This commit is contained in:
commit
cfd987800b
|
@ -1,12 +1,9 @@
|
||||||
module Proposable
|
module Proposable
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
def proposer
|
|
||||||
proposition.proposer
|
|
||||||
end
|
|
||||||
|
|
||||||
included do
|
included do
|
||||||
has_one :proposition, as: :proposable
|
has_one :proposition, as: :proposable
|
||||||
|
has_one :proposer, through: :proposition
|
||||||
|
|
||||||
Proposition.defined_enums["status"].keys.each do |status|
|
Proposition.defined_enums["status"].keys.each do |status|
|
||||||
scope status.to_sym, -> { joins(:proposition).where(propositions: {status: Proposition.defined_enums["status"][status]}) }
|
scope status.to_sym, -> { joins(:proposition).where(propositions: {status: Proposition.defined_enums["status"][status]}) }
|
||||||
|
|
|
@ -10,10 +10,10 @@ class Conference < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :tracks
|
has_many :tracks
|
||||||
has_many :halls
|
has_many :halls
|
||||||
has_many :events, through: :tracks
|
|
||||||
has_many :event_types
|
has_many :event_types
|
||||||
|
has_many :events, through: :tracks
|
||||||
has_one :call_for_participation, dependent: :destroy
|
has_one :call_for_participation, dependent: :destroy
|
||||||
has_many :participant_profiles, class_name: 'PersonalProfile'
|
has_many :participants, class_name: 'User', through: :events
|
||||||
|
|
||||||
accepts_nested_attributes_for :tracks, :halls, :event_types, reject_if: :all_blank, allow_destroy: true
|
accepts_nested_attributes_for :tracks, :halls, :event_types, reject_if: :all_blank, allow_destroy: true
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,12 @@ class Event < ActiveRecord::Base
|
||||||
|
|
||||||
has_one :track, through: :proposition, source: :proposition_accepting, source_type: Track
|
has_one :track, through: :proposition, source: :proposition_accepting, source_type: Track
|
||||||
has_one :conference, through: :track
|
has_one :conference, through: :track
|
||||||
|
|
||||||
|
has_many :participations
|
||||||
|
has_many :pending_participations, ->() { pending }, class_name: 'Participation'
|
||||||
|
has_many :approved_participations, ->() { approved }, class_name: 'Participation'
|
||||||
|
has_many :participants, through: :approved_participations
|
||||||
|
|
||||||
belongs_to :event_type
|
belongs_to :event_type
|
||||||
|
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
class Participation < ActiveRecord::Base
|
||||||
|
belongs_to :participant, class_name: User
|
||||||
|
belongs_to :event
|
||||||
|
|
||||||
|
scope :approved, ->() { where approved: true }
|
||||||
|
scope :pending, ->() { where.not approved: true }
|
||||||
|
end
|
|
@ -0,0 +1,11 @@
|
||||||
|
class CreateParticipations < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :participations do |t|
|
||||||
|
t.references :participant, index: true, foreign_key: true
|
||||||
|
t.references :event, index: true, foreign_key: true
|
||||||
|
t.boolean :approved, default: false
|
||||||
|
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,18 @@
|
||||||
|
class Participation < ActiveRecord::Base; end
|
||||||
|
class PersonalProfile < ActiveRecord::Base; end
|
||||||
|
|
||||||
|
class CreateParticipationRecords < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
event_to_speaker_profiles = execute 'SELECT * FROM events_speaker_profiles'
|
||||||
|
|
||||||
|
event_to_speaker_profiles.each do |event_to_speaker_profile|
|
||||||
|
Participation.create! event_id: event_to_speaker_profile['event_id'],
|
||||||
|
participant_id: PersonalProfile.find(event_to_speaker_profile['speaker_profile_id']).user_id,
|
||||||
|
approved: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
Participation.destroy_all
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class DropJoinTableEventsSepakerProfiles < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
drop_table :events_speaker_profiles
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,7 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :participation do
|
||||||
|
association :participant, factory: :user
|
||||||
|
event
|
||||||
|
approved false
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue