diff --git a/app/controllers/organizer/proposals_controller.rb b/app/controllers/organizer/proposals_controller.rb index d40e0008f..696f7efc5 100644 --- a/app/controllers/organizer/proposals_controller.rb +++ b/app/controllers/organizer/proposals_controller.rb @@ -71,6 +71,8 @@ def destroy def new @proposal = @event.proposals.new + @speaker = @proposal.speakers.build + @person = @speaker.build_person end def create @@ -80,6 +82,7 @@ def create flash[:success] = 'Proposal Added' redirect_to organizer_event_program_path(@event) else + puts @proposal.errors.inspect flash.now[:danger] = 'There was a problem saving your proposal; please review the form for issues and try again.' render :new end @@ -91,12 +94,12 @@ def proposal_params # add updating_person to params so Proposal does not update last_change attribute when updating_person is organizer_for_event? params.require(:proposal).permit(:title, {review_tags: []}, :abstract, :details, :pitch, comments_attributes: [:body, :proposal_id, :person_id], - speakers_attributes: [:bio, :person_id, :id]).merge(updating_person: current_user) + speakers_attributes: [:bio, :person_id, :id, person_attributes:[:id, :name, :email]]) end def send_state_mail(state) case state - when Proposal::State::ACCEPTED + when Proposal::State::ACCEPTED Organizer::ProposalMailer.accept_email(@event, @proposal).deliver when Proposal::State::REJECTED Organizer::ProposalMailer.reject_email(@event, @proposal).deliver diff --git a/app/mailers/comment_notification_mailer.rb b/app/mailers/comment_notification_mailer.rb index a95dee0e2..3ea363e76 100644 --- a/app/mailers/comment_notification_mailer.rb +++ b/app/mailers/comment_notification_mailer.rb @@ -4,7 +4,7 @@ def email_notification(comment) bcc = @comment.proposal.event.participants.map do |participant| - if participant.notifications && participant.role == 'reviewer' || 'organizer' + if participant.notifications && participant.role == 'reviewer' || participant.role == 'organizer' end end diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 35f1e4793..9609b2003 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -26,6 +26,7 @@ class Proposal < ActiveRecord::Base accepts_nested_attributes_for :public_comments, reject_if: Proc.new { |comment_attributes| comment_attributes[:body].blank? } accepts_nested_attributes_for :speakers + before_create :set_uuid before_update :save_attr_history after_save :save_tags, :save_review_tags diff --git a/app/models/speaker.rb b/app/models/speaker.rb index cda8194cc..0f02b802c 100644 --- a/app/models/speaker.rb +++ b/app/models/speaker.rb @@ -2,11 +2,14 @@ class Speaker < ActiveRecord::Base belongs_to :proposal belongs_to :person + has_many :proposals, through: :person delegate :name, :email, :gravatar_hash, to: :person validates :bio, length: { maximum: 500 } + + accepts_nested_attributes_for :person end # == Schema Information diff --git a/app/views/organizer/proposals/_form.html.haml b/app/views/organizer/proposals/_form.html.haml index c1031358e..9425763c1 100644 --- a/app/views/organizer/proposals/_form.html.haml +++ b/app/views/organizer/proposals/_form.html.haml @@ -1,6 +1,7 @@ = simple_form_for proposal, url: [ :organizer, event, proposal ] do |f| .row %fieldset.col-md-6 + %h4 Proposal = proposal.title_input(f) = proposal.abstract_input(f) @@ -8,12 +9,15 @@ = f.select :review_tags, options_for_select(event.review_tags, proposal.object.review_tags), {}, {class: 'multiselect review-tags', multiple: true} + %fieldset + %h4 Speaker + = f.simple_fields_for :speakers do |speaker_fields| + = speaker_fields.input :bio, maxlength: :lookup, + placeholder: 'Bio for speaker for the event program.' - = f.simple_fields_for :speakers do |ff| - = ff.input :bio, maxlength: :lookup, - placeholder: 'Bio for the event program.', - input_html: { value: speaker.bio, rows: 4 }, - hint: 'Bio is limited to 500 characters.' + = speaker_fields.simple_fields_for :person, @person do |person_fields| + = person_fields.input :name + = person_fields.input :email .form-submit.clearfix %button.pull-right.btn.btn-primary.btn-lg{:type => "submit"} Save diff --git a/config/application.rb b/config/application.rb index d335d07f4..6b8537b34 100644 --- a/config/application.rb +++ b/config/application.rb @@ -17,7 +17,7 @@ class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - + # config.action_controller.permit_all_parameters = true # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Eastern Time (US & Canada)'