Make it possible to select favourites events

Make it possible for users to select events which they want to see in the public schedule and in the All events section of the public schedule.
This commit is contained in:
Ana 2016-08-12 00:41:02 +02:00 committed by Ana María Martínez Gómez
parent 7f7375b7db
commit 9154f1883d
5 changed files with 74 additions and 10 deletions

View file

@ -63,14 +63,28 @@ class ProposalsController < ApplicationController
end
def update
@url = conference_program_proposal_path(@conference.short_title, params[:id])
respond_to do |format|
format.html do
@url = conference_program_proposal_path(@conference.short_title, params[:id])
if @event.update(event_params)
redirect_to conference_program_proposals_path(conference_id: @conference.short_title),
notice: 'Proposal was successfully updated.'
else
flash[:error] = "Could not update proposal: #{@event.errors.full_messages.join(', ')}"
render action: 'edit'
if @event.update(event_params)
redirect_to conference_program_proposals_path(conference_id: @conference.short_title),
notice: 'Proposal was successfully updated.'
else
flash[:error] = "Could not update proposal: #{@event.errors.full_messages.join(', ')}"
render action: 'edit'
end
end
format.json do
user = User.find(params[:favourite_user_id])
users = @event.favourite_users
if users.include? user
@event.favourite_users.delete(user)
else
@event.favourite_users << User.find(params[:favourite_user_id])
end
render json: {}
end
end
end