Registration form more-or-less working, workshop scaffold is up

This commit is contained in:
Godwin
2014-03-13 21:20:17 -06:00
parent 4b79de7a24
commit 3d6ad3b432
22 changed files with 383 additions and 19 deletions
+12 -1
View File
@@ -37,6 +37,7 @@ class ConferencesController < ApplicationController
registration = ConferenceRegistration.find_by(:user_id => current_user.id, :conference_id => @conference.id)
if registration
registration.conference_registration_responses.destroy_all
registration.is_attending = params[:is_attending]
else
registration = ConferenceRegistration.new(user_id: current_user.id, conference_id: @conference.id, is_attending: params[:is_attending])
end
@@ -53,7 +54,7 @@ class ConferencesController < ApplicationController
end
end
data.each do |key, value|
registration.conference_registration_responses << ConferenceRegistrationResponse.new(registration_form_field_id: key.to_i, data: value.to_json.to_s)
registration.conference_registration_responses << ConferenceRegistrationResponse.new(registration_form_field_id: key.to_i, data: value.to_json)
end
registration.save!
render action: 'show'
@@ -134,6 +135,16 @@ class ConferencesController < ApplicationController
# Use callbacks to share common setup or constraints between actions.
def set_conference
@conference = Conference.find_by(slug: params[:slug] || params[:conference_slug])
set_conference_registration
end
def set_conference_registration
if !@conference || !current_user
@conference_registration = nil
return
end
@conference_registration = ConferenceRegistration.find_by(conference_id: @conference.id, user_id: current_user.id)
end
# Only allow a trusted parameter "white list" through.
+58
View File
@@ -0,0 +1,58 @@
class WorkshopsController < ApplicationController
before_action :set_workshop, only: [:show, :edit, :update, :destroy]
# GET /workshops
def index
@workshops = Workshop.all
end
# GET /workshops/1
def show
end
# GET /workshops/new
def new
@workshop = Workshop.new
end
# GET /workshops/1/edit
def edit
end
# POST /workshops
def create
@workshop = Workshop.new(workshop_params)
if @workshop.save
redirect_to @workshop, notice: 'Workshop was successfully created.'
else
render action: 'new'
end
end
# PATCH/PUT /workshops/1
def update
if @workshop.update(workshop_params)
redirect_to @workshop, notice: 'Workshop was successfully updated.'
else
render action: 'edit'
end
end
# DELETE /workshops/1
def destroy
@workshop.destroy
redirect_to workshops_url, notice: 'Workshop was successfully destroyed.'
end
private
# Use callbacks to share common setup or constraints between actions.
def set_workshop
@workshop = Workshop.find(params[:id])
end
# Only allow a trusted parameter "white list" through.
def workshop_params
params.require(:workshop).permit(:title, :slug, :info, :conference_id, :workshop_stream_id, :workshop_presentation_style, :min_facilitators, :location_id, :start_time, :end_time)
end
end