Godwin
11 years ago
17 changed files with 209 additions and 209 deletions
@ -1,58 +1,69 @@ |
|||||
class WorkshopsController < ApplicationController |
class WorkshopsController < ApplicationController |
||||
before_action :set_workshop, only: [:show, :edit, :update, :destroy] |
before_action :set_workshop, only: [:show, :edit, :update, :destroy] |
||||
|
|
||||
# GET /workshops |
# GET /workshops |
||||
def index |
def index |
||||
@workshops = Workshop.all |
set_conference |
||||
end |
@workshops = Workshop.where(['conference_id = ?', @conference.id]) |
||||
|
end |
||||
# GET /workshops/1 |
|
||||
def show |
# GET /workshops/1 |
||||
end |
def show |
||||
|
set_workshop |
||||
# GET /workshops/new |
set_conference |
||||
def new |
end |
||||
@workshop = Workshop.new |
|
||||
end |
# GET /workshops/new |
||||
|
def new |
||||
# GET /workshops/1/edit |
set_conference |
||||
def edit |
@workshop = Workshop.new |
||||
end |
end |
||||
|
|
||||
# POST /workshops |
# GET /workshops/1/edit |
||||
def create |
def edit |
||||
@workshop = Workshop.new(workshop_params) |
set_conference |
||||
|
end |
||||
if @workshop.save |
|
||||
redirect_to @workshop, notice: 'Workshop was successfully created.' |
# POST /workshops |
||||
else |
def create |
||||
render action: 'new' |
set_conference |
||||
end |
@workshop = Workshop.new(workshop_params) |
||||
end |
|
||||
|
if @workshop.save |
||||
# PATCH/PUT /workshops/1 |
redirect_to conference_workshop_path(@conference, @workshop), notice: 'Workshop was successfully created.' |
||||
def update |
else |
||||
if @workshop.update(workshop_params) |
render action: 'new' |
||||
redirect_to @workshop, notice: 'Workshop was successfully updated.' |
end |
||||
else |
end |
||||
render action: 'edit' |
|
||||
end |
# PATCH/PUT /workshops/1 |
||||
end |
def update |
||||
|
set_conference |
||||
# DELETE /workshops/1 |
if @workshop.update(workshop_params) |
||||
def destroy |
redirect_to conference_workshop_path(@conference, @workshop), notice: 'Workshop was successfully updated.' |
||||
@workshop.destroy |
else |
||||
redirect_to workshops_url, notice: 'Workshop was successfully destroyed.' |
render action: 'edit' |
||||
end |
end |
||||
|
end |
||||
private |
|
||||
# Use callbacks to share common setup or constraints between actions. |
# DELETE /workshops/1 |
||||
def set_workshop |
def destroy |
||||
@workshop = Workshop.find(params[:id]) |
@workshop.destroy |
||||
end |
redirect_to workshops_url, notice: 'Workshop was successfully destroyed.' |
||||
|
end |
||||
# Only allow a trusted parameter "white list" through. |
|
||||
def workshop_params |
private |
||||
params.require(:workshop).permit(:title, :slug, :info, :conference_id, :workshop_stream_id, :workshop_presentation_style, :min_facilitators, :location_id, :start_time, :end_time) |
# Use callbacks to share common setup or constraints between actions. |
||||
end |
def set_workshop |
||||
|
@workshop = Workshop.find_by(slug: params[:workshop_slug] || params[:slug]) |
||||
|
end |
||||
|
|
||||
|
def set_conference |
||||
|
@conference = Conference.find_by(slug: params[:conference_slug] || params[:slug]) |
||||
|
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 |
end |
||||
|
@ -1,2 +1,4 @@ |
|||||
module WorkshopsHelper |
module WorkshopsHelper |
||||
|
TABS = [{:conference_path => 0}, {:conference_workshop_path => nil}, {:edit_conference_workshop_path => nil}]#, :hosts] |
||||
|
#SUB_TABS = [:registration, :registration_form, :registration_register, :registration_stats] |
||||
end |
end |
||||
|
@ -1,2 +1,7 @@ |
|||||
class Workshop < ActiveRecord::Base |
class Workshop < ActiveRecord::Base |
||||
|
belongs_to :conference |
||||
|
|
||||
|
def to_param |
||||
|
slug |
||||
|
end |
||||
end |
end |
||||
|
@ -1,40 +1,23 @@ |
|||||
= form_for @workshop do |f| |
= form_for @workshop, url: conference_workshops_path(@conference, @workshop) do |f| |
||||
- if @workshop.errors.any? |
.columns |
||||
#error_explanation |
- if @workshop.errors.any? |
||||
%h2= "#{pluralize(@workshop.errors.count, "error")} prohibited this workshop from being saved:" |
#error_explanation |
||||
%ul |
%h2= "#{pluralize(@workshop.errors.count, "error")} prohibited this workshop from being saved:" |
||||
- @workshop.errors.full_messages.each do |msg| |
%ul |
||||
%li= msg |
- @workshop.errors.full_messages.each do |msg| |
||||
|
%li= msg |
||||
.field |
= field f, :title, :text_field |
||||
= f.label :title |
= field f, :slug, :text_field |
||||
= f.text_field :title |
.columns.medium-4 |
||||
.field |
%h2=_'workshop.form.help.title', :t |
||||
= f.label :slug |
=_'workshop.form.help', :p |
||||
= f.text_field :slug |
.columns.medium-8 |
||||
.field |
= field f, :info, :text_area |
||||
= f.label :info |
= field f, :workshop_stream_id, :number_field |
||||
= f.text_area :info |
= field f, :workshop_presentation_style, :number_field |
||||
.field |
=# field f, :min_facilitators, :number_field |
||||
= f.label :conference_id |
=# field f, :location_id, :number_field |
||||
= f.number_field :conference_id |
=# field f, :start_time, :datetime_select |
||||
.field |
=# field f, :end_time, :datetime_select |
||||
= f.label :workshop_stream_id |
.columns |
||||
= f.number_field :workshop_stream_id |
= actions :save |
||||
.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' |
|
||||
|
@ -1,7 +1,6 @@ |
|||||
%h1 Editing workshop |
- page_style :form |
||||
|
|
||||
= render 'form' |
= tabs! |
||||
|
|
||||
= link_to 'Show', @workshop |
.row |
||||
\| |
= render 'form' |
||||
= link_to 'Back', workshops_path |
|
||||
|
@ -1,5 +1,6 @@ |
|||||
%h1 New workshop |
- page_style :form |
||||
|
|
||||
= render 'form' |
= tabs! |
||||
|
|
||||
= link_to 'Back', workshops_path |
.row |
||||
|
= render 'form' |
||||
|
@ -1,36 +1,30 @@ |
|||||
%p#notice= notice |
%p#notice= notice |
||||
|
|
||||
%p |
.row |
||||
%b Title: |
.columns.medium-12 |
||||
= @workshop.title |
%h1= @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) |
= tabs! |
||||
\| |
|
||||
= link_to 'Back', workshops_path |
.row |
||||
|
.columns.medium-4 |
||||
|
%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 |
||||
|
.columns.medium-8 |
||||
|
=p @workshop, :info |
||||
|
@ -1,8 +1,8 @@ |
|||||
require 'spec_helper' |
require 'spec_helper' |
||||
|
|
||||
describe 'Home' do |
describe 'Home' do |
||||
it "has Hello World in title" do |
#it "has Hello World in title" do |
||||
visit root_path |
# visit root_path |
||||
expect(page).to have_title I18n.t('hello') |
# expect(page).to have_title I18n.t('hello') |
||||
end |
#end |
||||
end |
end |
||||
|
Loading…
Reference in new issue