Skip to content

Commit

Permalink
An organizer can add an accepted proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
Kel4545 committed Apr 3, 2015
1 parent 693e189 commit cebe295
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
7 changes: 5 additions & 2 deletions app/controllers/organizer/proposals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def destroy

def new
@proposal = @event.proposals.new
@speaker = @proposal.speakers.build
@person = @speaker.build_person
end

def create
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/comment_notification_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions app/models/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/models/speaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions app/views/organizer/proposals/_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
= 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)


= 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
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand Down

0 comments on commit cebe295

Please sign in to comment.