Merge pull request #16 from ignisf/scoped-events
Scope event operations to the current conference
This commit is contained in:
commit
8d744299ab
@ -2,23 +2,22 @@ module Management
|
|||||||
class EventsController < ManagementController
|
class EventsController < ManagementController
|
||||||
def index
|
def index
|
||||||
@conference = find_conference
|
@conference = find_conference
|
||||||
# TODO (2015-07-14) Scoped by conference? Why no conference_id
|
@events = @conference.events.approved
|
||||||
@events = Event.approved
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@conference = find_conference
|
@conference = find_conference
|
||||||
@event = Event.find(params[:id])
|
@event = @conference.events.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@conference = find_conference
|
@conference = find_conference
|
||||||
@event = Event.find(params[:id])
|
@event = @conference.events.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@conference = find_conference
|
@conference = find_conference
|
||||||
@event = Event.find(params[:id])
|
@event = @conference.events.find(params[:id])
|
||||||
|
|
||||||
if @event.update_attributes(event_params)
|
if @event.update_attributes(event_params)
|
||||||
flash[:notice] = 'Event was successfully updated.'
|
flash[:notice] = 'Event was successfully updated.'
|
||||||
@ -30,7 +29,7 @@ module Management
|
|||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@conference = find_conference
|
@conference = find_conference
|
||||||
@event = Event.find(params[:id])
|
@event = @conference.events.find(params[:id])
|
||||||
@event.destroy
|
@event.destroy
|
||||||
|
|
||||||
redirect_to action: :index
|
redirect_to action: :index
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
class Event < ActiveRecord::Base
|
class Event < ActiveRecord::Base
|
||||||
include Proposable
|
include Proposable
|
||||||
|
|
||||||
|
has_one :track, through: :proposition, source: :proposition_accepting, source_type: Track
|
||||||
|
has_one :conference, through: :track
|
||||||
|
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
validates :length, presence: true, numericality: {only_integer: true, greater_than: 0}
|
validates :length, presence: true, numericality: {only_integer: true, greater_than: 0}
|
||||||
validates :abstract, presence: true
|
validates :abstract, presence: true
|
||||||
|
Loading…
Reference in New Issue
Block a user