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])
|
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||||
@events = @conference.events
|
@events = @conference.events
|
||||||
@tracks = @conference.tracks
|
@tracks = @conference.tracks
|
||||||
|
@difficulty_levels = @conference.difficulty_levels
|
||||||
@machine_states = @events.state_machine.states.map
|
@machine_states = @events.state_machine.states.map
|
||||||
@event_types = @conference.event_types
|
@event_types = @conference.event_types
|
||||||
|
|
||||||
|
|
@ -104,27 +105,15 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if params.has_key? :track_id
|
if @event.submitter.update_attributes(params[:user]) &&
|
||||||
@event.update_attribute(:track_id, params[:track_id])
|
@event.update_attributes(params[:event])
|
||||||
end
|
flash[:notice] = "Successfully updated event with ID #{@event.id}."
|
||||||
if params.has_key? :event_type_id
|
redirect_back_or_to(admin_conference_event_path(@conference.short_title, @event))
|
||||||
@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}."
|
|
||||||
else
|
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
|
end
|
||||||
|
|
||||||
redirect_back_or_to(admin_conference_event_path(@conference.short_title, @event))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create; end
|
def create; end
|
||||||
|
|
@ -186,11 +175,11 @@ module Admin
|
||||||
alert = @event.update_state(transition, mail, subject, send_mail, params[:send_mail].blank?)
|
alert = @event.update_state(transition, mail, subject, send_mail, params[:send_mail].blank?)
|
||||||
|
|
||||||
if !alert.blank?
|
if !alert.blank?
|
||||||
return redirect_to(admin_conference_events_path(conference_id: @conference.short_title),
|
flash[:error] = error
|
||||||
alert: alert) && return
|
return redirect_back_or_to(admin_conference_events_path(conference_id: @conference.short_title)) && return
|
||||||
else
|
else
|
||||||
redirect_to(admin_conference_events_path(conference_id: @conference.short_title),
|
flash[:notice] = notice
|
||||||
notice: notice) && return
|
redirect_back_or_to(admin_conference_events_path(conference_id: @conference.short_title)) && return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
class Event < ActiveRecord::Base
|
class Event < ActiveRecord::Base
|
||||||
include ActiveRecord::Transitions
|
include ActiveRecord::Transitions
|
||||||
has_paper_trail
|
has_paper_trail
|
||||||
attr_accessible :title, :subtitle, :abstract, :description, :event_type_id, :users_attributes,
|
attr_accessible :title, :subtitle, :abstract, :description, :user, :users_attributes,
|
||||||
:user, :proposal_additional_speakers, :track_id,
|
:proposal_additional_speakers, :event_type_id, :track_id,
|
||||||
:require_registration, :difficulty_level_id
|
:difficulty_level_id, :require_registration, :is_highlight
|
||||||
|
|
||||||
acts_as_commentable
|
acts_as_commentable
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,11 @@
|
||||||
<b class="caret"></b>
|
<b class="caret"></b>
|
||||||
%ul.dropdown-menu
|
%ul.dropdown-menu
|
||||||
- @event_types.each do |type|
|
- @event_types.each do |type|
|
||||||
%li= link_to type.title, admin_conference_event_path(@conference.short_title, @event, :event_type_id => type.id) ,
|
%li= link_to type.title,
|
||||||
:method => :put, :event_type_id => type.id
|
admin_conference_event_path(@conference.short_title,
|
||||||
|
@event,
|
||||||
|
event: { event_type_id: type.id }),
|
||||||
|
method: :patch
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%b Highlight
|
%b Highlight
|
||||||
|
|
@ -32,8 +35,8 @@
|
||||||
= link_to "#{@event.is_highlight}".capitalize,
|
= link_to "#{@event.is_highlight}".capitalize,
|
||||||
admin_conference_event_path(@conference.short_title,
|
admin_conference_event_path(@conference.short_title,
|
||||||
@event,
|
@event,
|
||||||
is_highlight: !@event.is_highlight),
|
event: { is_highlight: !@event.is_highlight }),
|
||||||
method: :put, is_highlight: !@event.is_highlight
|
method: :patch
|
||||||
- if @event.is_highlight
|
- if @event.is_highlight
|
||||||
(the event is as a highlight and will appear in the splashpage)
|
(the event is as a highlight and will appear in the splashpage)
|
||||||
- else
|
- else
|
||||||
|
|
@ -61,8 +64,11 @@
|
||||||
<b class="caret"></b>
|
<b class="caret"></b>
|
||||||
%ul.dropdown-menu
|
%ul.dropdown-menu
|
||||||
- @tracks.each do |track|
|
- @tracks.each do |track|
|
||||||
%li= link_to track.name, admin_conference_event_path(@conference.short_title, @event, :track_id => track.id) ,
|
%li= link_to track.name,
|
||||||
:method => :put, :track_id => track.id
|
admin_conference_event_path(@conference.short_title,
|
||||||
|
@event,
|
||||||
|
event: { track_id: track.id }),
|
||||||
|
method: :patch
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%b Difficulty
|
%b Difficulty
|
||||||
|
|
@ -76,8 +82,10 @@
|
||||||
<b class="caret"></b>
|
<b class="caret"></b>
|
||||||
%ul.dropdown-menu
|
%ul.dropdown-menu
|
||||||
- @difficulty_levels.each do |difficulty|
|
- @difficulty_levels.each do |difficulty|
|
||||||
%li= link_to difficulty.title, admin_conference_event_path(@conference.short_title, @event, :difficulty_level_id => difficulty.id) ,
|
%li= link_to difficulty.title, admin_conference_event_path(@conference.short_title,
|
||||||
:method => :put, :difficulty_level_id => difficulty.id
|
@event,
|
||||||
|
event: { difficulty_level_id: difficulty.id }),
|
||||||
|
method: :patch
|
||||||
- if !@event.room.nil?
|
- if !@event.room.nil?
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,11 @@
|
||||||
%span.caret
|
%span.caret
|
||||||
%ul.dropdown-menu
|
%ul.dropdown-menu
|
||||||
- @event_types.each do |type|
|
- @event_types.each do |type|
|
||||||
%li= link_to type.title, admin_conference_event_path(@conference.short_title, event, :event_type_id => type.id) ,
|
%li= link_to type.title,
|
||||||
:method => :put, :event_type_id => type.id
|
admin_conference_event_path(@conference.short_title,
|
||||||
|
event,
|
||||||
|
event: { event_type_id: type.id }),
|
||||||
|
method: :patch
|
||||||
%td
|
%td
|
||||||
.btn-group
|
.btn-group
|
||||||
%button{:type=>"button", :class=>"btn btn-link dropdown-toggle", "data-toggle"=>"dropdown"}
|
%button{:type=>"button", :class=>"btn btn-link dropdown-toggle", "data-toggle"=>"dropdown"}
|
||||||
|
|
@ -92,10 +95,27 @@
|
||||||
%span.caret
|
%span.caret
|
||||||
%ul.dropdown-menu
|
%ul.dropdown-menu
|
||||||
- @tracks.each do |track|
|
- @tracks.each do |track|
|
||||||
%li= link_to track.name, admin_conference_event_path(@conference.short_title, event, :track_id => track.id) ,
|
%li= link_to track.name,
|
||||||
:method => :put, :track_id => track.id
|
admin_conference_event_path(@conference.short_title,
|
||||||
|
event,
|
||||||
|
event: { track_id: track.id }),
|
||||||
|
method: :patch
|
||||||
%td
|
%td
|
||||||
= event.difficulty_level.title if event.difficulty_level
|
.btn-group
|
||||||
|
%button{:type=>"button", :class=>"btn btn-link dropdown-toggle", "data-toggle"=>"dropdown"}
|
||||||
|
- if event.difficulty_level.nil?
|
||||||
|
Difficulty
|
||||||
|
- else
|
||||||
|
= event.difficulty_level.title
|
||||||
|
%span.caret
|
||||||
|
%ul.dropdown-menu
|
||||||
|
- @difficulty_levels.each do |difficulty_level|
|
||||||
|
%li= link_to difficulty_level.title,
|
||||||
|
admin_conference_event_path(@conference.short_title,
|
||||||
|
event,
|
||||||
|
event: { difficulty_level_id: difficulty_level.id }),
|
||||||
|
method: :patch
|
||||||
|
|
||||||
%td
|
%td
|
||||||
- if event.state == "withdrawn"
|
- if event.state == "withdrawn"
|
||||||
Withdrawn
|
Withdrawn
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue