mirror of
https://github.com/openSUSE/osem.git
synced 2026-04-30 19:53:05 -04:00
About track requests: Create migration that adds the fields submitter_id, state, and cfp_active to Tracks Add validations and the self_organized? method to the Track model Create a new TracksController outide of the admin namespace Create the relevant views for index, show, new and edit Modify the admin views for tracks to include extra info for self-organized tracks About track organizers: Create the role when a self-organized track is created Define track organizer abilities Modify the roles views and controller to handle the new role The route for Roles#edit needs to have higher priority than the nested routes for track roles, otherwise, the word edit in the url is matched as a track with short_name edit
69 lines
2.0 KiB
Ruby
69 lines
2.0 KiB
Ruby
module Admin
|
|
class TracksController < Admin::BaseController
|
|
load_and_authorize_resource :conference, find_by: :short_title
|
|
load_and_authorize_resource :program, through: :conference, singleton: true
|
|
load_and_authorize_resource through: :program, find_by: :short_name
|
|
|
|
def index; end
|
|
|
|
def show
|
|
respond_to do |format|
|
|
format.html { render }
|
|
format.json { render json: @conference.tracks.to_json }
|
|
end
|
|
end
|
|
|
|
def new
|
|
@track = @program.tracks.new(color: @conference.next_color_for_collection(:tracks))
|
|
end
|
|
|
|
def create
|
|
@track = @program.tracks.new(track_params)
|
|
if @track.save
|
|
redirect_to admin_conference_program_tracks_path(conference_id: @conference.short_title),
|
|
notice: 'Track successfully created.'
|
|
else
|
|
flash.now[:error] = "Creating Track failed: #{@track.errors.full_messages.join('. ')}."
|
|
render :new
|
|
end
|
|
end
|
|
|
|
def edit; end
|
|
|
|
def update
|
|
if @track.update_attributes(track_params)
|
|
redirect_to admin_conference_program_tracks_path(conference_id: @conference.short_title),
|
|
notice: 'Track successfully updated.'
|
|
else
|
|
flash.now[:error] = "Track update failed: #{@track.errors.full_messages.join('. ')}."
|
|
render :edit
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
if @track.destroy
|
|
redirect_to admin_conference_program_tracks_path(conference_id: @conference.short_title),
|
|
notice: 'Track successfully deleted.'
|
|
else
|
|
redirect_to admin_conference_program_tracks_path(conference_id: @conference.short_title),
|
|
error: "Track couldn't be deleted. #{@track.errors.full_messages.join('. ')}."
|
|
end
|
|
end
|
|
|
|
def toggle_cfp_inclusion
|
|
@track.cfp_active = !@track.cfp_active
|
|
if @track.save
|
|
head :ok
|
|
else
|
|
head :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def track_params
|
|
params.require(:track).permit(:name, :description, :color, :short_name, :cfp_active)
|
|
end
|
|
end
|
|
end
|