fix controller update
This commit is contained in:
parent
ecfc348ea8
commit
11d0a71231
4 changed files with 56 additions and 39 deletions
|
|
@ -18,6 +18,7 @@ module Admin
|
|||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
@events = @conference.events
|
||||
@tracks = @conference.tracks
|
||||
@difficulty_levels = @conference.difficulty_levels
|
||||
@machine_states = @events.state_machine.states.map
|
||||
@event_types = @conference.event_types
|
||||
|
||||
|
|
@ -104,27 +105,15 @@ module Admin
|
|||
end
|
||||
|
||||
def update
|
||||
if params.has_key? :track_id
|
||||
@event.update_attribute(:track_id, params[:track_id])
|
||||
end
|
||||
if params.has_key? :event_type_id
|
||||
@event.update_attribute(:event_type_id, params[:event_type_id])
|
||||
end
|
||||
if params.has_key? :difficulty_level_id
|
||||
@event.update_attribute(:difficulty_level_id, params[:difficulty_level_id])
|
||||
end
|
||||
if params.has_key? :is_highlight
|
||||
@event.update_attribute(:is_highlight, params[:is_highlight])
|
||||
end
|
||||
|
||||
if @event.submitter.update_attributes!(params[:user]) && @event.
|
||||
update_attributes!(params[:event])
|
||||
flash[:notice] = "Successfully updated #{@event.title}."
|
||||
if @event.submitter.update_attributes(params[:user]) &&
|
||||
@event.update_attributes(params[:event])
|
||||
flash[:notice] = "Successfully updated event with ID #{@event.id}."
|
||||
redirect_back_or_to(admin_conference_event_path(@conference.short_title, @event))
|
||||
else
|
||||
flash[:notice] = 'Update not successful.'
|
||||
@url = admin_conference_event_path(@conference.short_title, @event)
|
||||
flash[:notice] = 'Update not successful. ' + @event.errors.full_messages.to_sentence
|
||||
render :edit
|
||||
end
|
||||
|
||||
redirect_back_or_to(admin_conference_event_path(@conference.short_title, @event))
|
||||
end
|
||||
|
||||
def create; end
|
||||
|
|
@ -186,11 +175,11 @@ module Admin
|
|||
alert = @event.update_state(transition, mail, subject, send_mail, params[:send_mail].blank?)
|
||||
|
||||
if !alert.blank?
|
||||
return redirect_to(admin_conference_events_path(conference_id: @conference.short_title),
|
||||
alert: alert) && return
|
||||
flash[:error] = error
|
||||
return redirect_back_or_to(admin_conference_events_path(conference_id: @conference.short_title)) && return
|
||||
else
|
||||
redirect_to(admin_conference_events_path(conference_id: @conference.short_title),
|
||||
notice: notice) && return
|
||||
flash[:notice] = notice
|
||||
redirect_back_or_to(admin_conference_events_path(conference_id: @conference.short_title)) && return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue