Godwin
11 years ago
22 changed files with 383 additions and 19 deletions
@ -0,0 +1,3 @@ |
|||||
|
# Place all the behaviors and hooks related to the matching controller here. |
||||
|
# All this logic will automatically be available in application.js. |
||||
|
# You can use CoffeeScript in this file: http://coffeescript.org/ |
@ -0,0 +1,3 @@ |
|||||
|
// Place all the styles related to the workshops controller here. |
||||
|
// They will automatically be included in application.css. |
||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/ |
@ -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 |
@ -0,0 +1,2 @@ |
|||||
|
module WorkshopsHelper |
||||
|
end |
@ -0,0 +1,2 @@ |
|||||
|
class Workshop < ActiveRecord::Base |
||||
|
end |
@ -1,7 +1,8 @@ |
|||||
.columns.medium-8 |
.columns.medium-8 |
||||
= field :is_attending, :select_tag, ConferenceRegistration::AttendingOptions, label: 'Are you attending?' |
= field :is_attending, :select_tag, ConferenceRegistration::AttendingOptions, label: 'Are you attending?', value: @conference_registration.try(:is_attending) |
||||
%ol |
%ol |
||||
- @conference.registration_form_fields.each do |ff| |
- @conference.registration_form_fields.each do |ff| |
||||
%li |
%li |
||||
= form_field ff |
- response = @conference_registration ? ConferenceRegistrationResponse.find_by(conference_registration_id: @conference_registration.id, registration_form_field_id: ff.id) : nil |
||||
|
= form_field ff, response |
||||
= actions :register |
= actions :register |
||||
|
@ -0,0 +1,40 @@ |
|||||
|
= form_for @workshop do |f| |
||||
|
- if @workshop.errors.any? |
||||
|
#error_explanation |
||||
|
%h2= "#{pluralize(@workshop.errors.count, "error")} prohibited this workshop from being saved:" |
||||
|
%ul |
||||
|
- @workshop.errors.full_messages.each do |msg| |
||||
|
%li= msg |
||||
|
|
||||
|
.field |
||||
|
= f.label :title |
||||
|
= f.text_field :title |
||||
|
.field |
||||
|
= f.label :slug |
||||
|
= f.text_field :slug |
||||
|
.field |
||||
|
= f.label :info |
||||
|
= f.text_area :info |
||||
|
.field |
||||
|
= f.label :conference_id |
||||
|
= f.number_field :conference_id |
||||
|
.field |
||||
|
= f.label :workshop_stream_id |
||||
|
= f.number_field :workshop_stream_id |
||||
|
.field |
||||
|
= f.label :workshop_presentation_style |
||||
|
= f.number_field :workshop_presentation_style |
||||
|
.field |
||||
|
= f.label :min_facilitators |
||||
|
= f.number_field :min_facilitators |
||||
|
.field |
||||
|
= f.label :location_id |
||||
|
= f.number_field :location_id |
||||
|
.field |
||||
|
= f.label :start_time |
||||
|
= f.datetime_select :start_time |
||||
|
.field |
||||
|
= f.label :end_time |
||||
|
= f.datetime_select :end_time |
||||
|
.actions |
||||
|
= f.submit 'Save' |
@ -0,0 +1,7 @@ |
|||||
|
%h1 Editing workshop |
||||
|
|
||||
|
= render 'form' |
||||
|
|
||||
|
= link_to 'Show', @workshop |
||||
|
\| |
||||
|
= link_to 'Back', workshops_path |
@ -0,0 +1,37 @@ |
|||||
|
%h1 Listing workshops |
||||
|
|
||||
|
%table |
||||
|
%tr |
||||
|
%th Title |
||||
|
%th Slug |
||||
|
%th Info |
||||
|
%th Conference |
||||
|
%th Workshop stream |
||||
|
%th Workshop presentation style |
||||
|
%th Min facilitators |
||||
|
%th Location |
||||
|
%th Start time |
||||
|
%th End time |
||||
|
%th |
||||
|
%th |
||||
|
%th |
||||
|
|
||||
|
- @workshops.each do |workshop| |
||||
|
%tr |
||||
|
%td= workshop.title |
||||
|
%td= workshop.slug |
||||
|
%td= workshop.info |
||||
|
%td= workshop.conference_id |
||||
|
%td= workshop.workshop_stream_id |
||||
|
%td= workshop.workshop_presentation_style |
||||
|
%td= workshop.min_facilitators |
||||
|
%td= workshop.location_id |
||||
|
%td= workshop.start_time |
||||
|
%td= workshop.end_time |
||||
|
%td= link_to 'Show', workshop |
||||
|
%td= link_to 'Edit', edit_workshop_path(workshop) |
||||
|
%td= link_to 'Destroy', workshop, :method => :delete, :data => { :confirm => 'Are you sure?' } |
||||
|
|
||||
|
%br |
||||
|
|
||||
|
= link_to 'New Workshop', new_workshop_path |
@ -0,0 +1,5 @@ |
|||||
|
%h1 New workshop |
||||
|
|
||||
|
= render 'form' |
||||
|
|
||||
|
= link_to 'Back', workshops_path |
@ -0,0 +1,36 @@ |
|||||
|
%p#notice= notice |
||||
|
|
||||
|
%p |
||||
|
%b Title: |
||||
|
= @workshop.title |
||||
|
%p |
||||
|
%b Slug: |
||||
|
= @workshop.slug |
||||
|
%p |
||||
|
%b Info: |
||||
|
= @workshop.info |
||||
|
%p |
||||
|
%b Conference: |
||||
|
= @workshop.conference_id |
||||
|
%p |
||||
|
%b Workshop stream: |
||||
|
= @workshop.workshop_stream_id |
||||
|
%p |
||||
|
%b Workshop presentation style: |
||||
|
= @workshop.workshop_presentation_style |
||||
|
%p |
||||
|
%b Min facilitators: |
||||
|
= @workshop.min_facilitators |
||||
|
%p |
||||
|
%b Location: |
||||
|
= @workshop.location_id |
||||
|
%p |
||||
|
%b Start time: |
||||
|
= @workshop.start_time |
||||
|
%p |
||||
|
%b End time: |
||||
|
= @workshop.end_time |
||||
|
|
||||
|
= link_to 'Edit', edit_workshop_path(@workshop) |
||||
|
\| |
||||
|
= link_to 'Back', workshops_path |
@ -0,0 +1,18 @@ |
|||||
|
class CreateWorkshops < ActiveRecord::Migration |
||||
|
def change |
||||
|
create_table :workshops do |t| |
||||
|
t.string :title |
||||
|
t.string :slug |
||||
|
t.text :info |
||||
|
t.integer :conference_id |
||||
|
t.integer :workshop_stream_id |
||||
|
t.integer :workshop_presentation_style |
||||
|
t.integer :min_facilitators |
||||
|
t.integer :location_id |
||||
|
t.datetime :start_time |
||||
|
t.datetime :end_time |
||||
|
|
||||
|
t.timestamps |
||||
|
end |
||||
|
end |
||||
|
end |
@ -0,0 +1,49 @@ |
|||||
|
require 'test_helper' |
||||
|
|
||||
|
class WorkshopsControllerTest < ActionController::TestCase |
||||
|
setup do |
||||
|
@workshop = workshops(:one) |
||||
|
end |
||||
|
|
||||
|
test "should get index" do |
||||
|
get :index |
||||
|
assert_response :success |
||||
|
assert_not_nil assigns(:workshops) |
||||
|
end |
||||
|
|
||||
|
test "should get new" do |
||||
|
get :new |
||||
|
assert_response :success |
||||
|
end |
||||
|
|
||||
|
test "should create workshop" do |
||||
|
assert_difference('Workshop.count') do |
||||
|
post :create, workshop: { conference_id: @workshop.conference_id, end_time: @workshop.end_time, info: @workshop.info, location_id: @workshop.location_id, min_facilitators: @workshop.min_facilitators, slug: @workshop.slug, start_time: @workshop.start_time, title: @workshop.title, workshop_presentation_style: @workshop.workshop_presentation_style, workshop_stream_id: @workshop.workshop_stream_id } |
||||
|
end |
||||
|
|
||||
|
assert_redirected_to workshop_path(assigns(:workshop)) |
||||
|
end |
||||
|
|
||||
|
test "should show workshop" do |
||||
|
get :show, id: @workshop |
||||
|
assert_response :success |
||||
|
end |
||||
|
|
||||
|
test "should get edit" do |
||||
|
get :edit, id: @workshop |
||||
|
assert_response :success |
||||
|
end |
||||
|
|
||||
|
test "should update workshop" do |
||||
|
patch :update, id: @workshop, workshop: { conference_id: @workshop.conference_id, end_time: @workshop.end_time, info: @workshop.info, location_id: @workshop.location_id, min_facilitators: @workshop.min_facilitators, slug: @workshop.slug, start_time: @workshop.start_time, title: @workshop.title, workshop_presentation_style: @workshop.workshop_presentation_style, workshop_stream_id: @workshop.workshop_stream_id } |
||||
|
assert_redirected_to workshop_path(assigns(:workshop)) |
||||
|
end |
||||
|
|
||||
|
test "should destroy workshop" do |
||||
|
assert_difference('Workshop.count', -1) do |
||||
|
delete :destroy, id: @workshop |
||||
|
end |
||||
|
|
||||
|
assert_redirected_to workshops_path |
||||
|
end |
||||
|
end |
@ -0,0 +1,16 @@ |
|||||
|
# Read about factories at https://github.com/thoughtbot/factory_girl |
||||
|
|
||||
|
FactoryGirl.define do |
||||
|
factory :workshop do |
||||
|
title "MyString" |
||||
|
slug "MyString" |
||||
|
info "MyText" |
||||
|
conference_id 1 |
||||
|
workshop_stream_id 1 |
||||
|
workshop_presentation_style 1 |
||||
|
min_facilitators 1 |
||||
|
location_id 1 |
||||
|
start_time "2014-03-13 20:56:47" |
||||
|
end_time "2014-03-13 20:56:47" |
||||
|
end |
||||
|
end |
@ -0,0 +1,4 @@ |
|||||
|
require 'test_helper' |
||||
|
|
||||
|
class WorkshopsHelperTest < ActionView::TestCase |
||||
|
end |
@ -0,0 +1,7 @@ |
|||||
|
require 'test_helper' |
||||
|
|
||||
|
class WorkshopTest < ActiveSupport::TestCase |
||||
|
# test "the truth" do |
||||
|
# assert true |
||||
|
# end |
||||
|
end |
Loading…
Reference in new issue