From 3d6ad3b432b29b7ea1ebf631d59e6100d9faefd0 Mon Sep 17 00:00:00 2001 From: Godwin Date: Thu, 13 Mar 2014 21:20:17 -0600 Subject: [PATCH 01/15] Registration form more-or-less working, workshop scaffold is up --- DB specs.txt | 5 +- app/assets/javascripts/workshops.js.coffee | 3 + app/assets/stylesheets/workshops.css.scss | 3 + app/controllers/conferences_controller.rb | 13 +++- app/controllers/workshops_controller.rb | 58 +++++++++++++++++ app/helpers/application_helper.rb | 65 +++++++++++++++---- app/helpers/workshops_helper.rb | 2 + app/models/registration_form_field.rb | 8 +++ app/models/workshop.rb | 2 + .../_registration_register.html.haml | 5 +- app/views/workshops/_form.html.haml | 40 ++++++++++++ app/views/workshops/edit.html.haml | 7 ++ app/views/workshops/index.html.haml | 37 +++++++++++ app/views/workshops/new.html.haml | 5 ++ app/views/workshops/show.html.haml | 36 ++++++++++ config/routes.rb | 2 + db/migrate/20140314025647_create_workshops.rb | 18 +++++ db/schema.rb | 17 ++++- test/controllers/workshops_controller_test.rb | 49 ++++++++++++++ test/factories/workshops.rb | 16 +++++ test/helpers/workshops_helper_test.rb | 4 ++ test/models/workshop_test.rb | 7 ++ 22 files changed, 383 insertions(+), 19 deletions(-) create mode 100644 app/assets/javascripts/workshops.js.coffee create mode 100644 app/assets/stylesheets/workshops.css.scss create mode 100644 app/controllers/workshops_controller.rb create mode 100644 app/helpers/workshops_helper.rb create mode 100644 app/models/workshop.rb create mode 100644 app/views/workshops/_form.html.haml create mode 100644 app/views/workshops/edit.html.haml create mode 100644 app/views/workshops/index.html.haml create mode 100644 app/views/workshops/new.html.haml create mode 100644 app/views/workshops/show.html.haml create mode 100644 db/migrate/20140314025647_create_workshops.rb create mode 100644 test/controllers/workshops_controller_test.rb create mode 100644 test/factories/workshops.rb create mode 100644 test/helpers/workshops_helper_test.rb create mode 100644 test/models/workshop_test.rb diff --git a/DB specs.txt b/DB specs.txt index 39cdb6c..1cf838e 100644 --- a/DB specs.txt +++ b/DB specs.txt @@ -106,4 +106,7 @@ workshop - slug : string - info : text -rails g scaffold \ No newline at end of file +rails g scaffold workshop title:string slug:string info:text conference_id:integer workshop_stream_id:integer workshop_presentation_style:integer min_facilitators:integer location_id:integer start_time:datetime end_time:datetime + + - requested_resources : NtoN[workshop_resource] + - facilitators : NtoN[user] \ No newline at end of file diff --git a/app/assets/javascripts/workshops.js.coffee b/app/assets/javascripts/workshops.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/workshops.js.coffee @@ -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/ diff --git a/app/assets/stylesheets/workshops.css.scss b/app/assets/stylesheets/workshops.css.scss new file mode 100644 index 0000000..d7f7461 --- /dev/null +++ b/app/assets/stylesheets/workshops.css.scss @@ -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/ diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 6bc80e4..d5b577a 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -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. diff --git a/app/controllers/workshops_controller.rb b/app/controllers/workshops_controller.rb new file mode 100644 index 0000000..853cbe3 --- /dev/null +++ b/app/controllers/workshops_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8e73304..2b5cc7f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -90,7 +90,7 @@ module ApplicationHelper return nil end - def _(key, behavior = nil, behavior_size = nil, fake: nil, vars: {}, html: nil, blockData: {}, &block) + def _(key, behavior = nil, behavior_size = nil, vars: {}, html: nil, blockData: {}, &block) queued_keys = nil result = nil @@ -201,7 +201,7 @@ module ApplicationHelper end end - def field(form, name, type = nil, param = nil, html: nil, help: false, attrs: [], classes: nil, label: nil, placeholder: nil) + def field(form, name, type = nil, param = nil, html: nil, help: false, attrs: [], classes: nil, label: nil, placeholder: nil, value: nil, checked: nil) if form.is_a?(Symbol) || form.is_a?(String) param = type @@ -228,18 +228,24 @@ module ApplicationHelper select_prompt = nil show_label = true label_after = true + value_attribute = !form if /select(_tag)?$/.match(type.to_s) - placeholder = nil if !label - select_prompt = 'Select a ' + name.to_s + select_prompt = placeholder || (form ? 'Select a ' + name.to_s : 'Select one') label_html = '' show_label = false end - label_after = false - if param && param.is_a?(Array) - param = options_for_select(param) + placeholder = nil + label_after = false + if param + if param.is_a?(Array) + param = options_for_select(param, value) + elsif param.is_a?(Hash) + param = options_from_collection_for_select(param, :first, :last, value) + end end + value_attribute = false elsif type.to_s == 'image_field' || type.to_s == 'user_select_field' || type.to_s == 'organization_select_field' placeholder = nil label_html = '' @@ -316,14 +322,29 @@ module ApplicationHelper end else ph = '' + va = '' + if value_attribute + if /^(check_box|radio_button)/.match(type.to_s) + if checked === nil + checked = value == "on" || value.to_s == "1" + end + if /^(radio_button)/.match(type.to_s) + va = ', "' + value + '", checked' + else + va = ', "1", checked' + end + else + va = ', value' + end + end if placeholder if form ph = ", :placeholder => '#{placeholder}'" else - ph = ", nil, placeholder: '#{placeholder}'" + ph = ", placeholder: '#{placeholder}'" end end - form_html = (form ? "form.#{type} :#{name}" : "#{type} :#{name}") + ph + (param ? ', param' : '') + form_html = (form ? "form.#{type} :#{name}" : "#{type} :#{name}") + va + ph + (param ? ', param' : '') attrs.each_index { |i| form_html += (i >= attrs_used ? ', attrs[' + i.to_s + ']' : '') } if select_prompt if form @@ -451,10 +472,11 @@ module ApplicationHelper ('

' + object.send(attribute.to_s).strip.gsub(/\s*\n+\s*/, '

') + '

').html_safe end - def form_field(f) + def form_field(f, response = nil) id = 'field_' + f.id.to_s html = p(f, 'title')#'' + #options = ActiveSupport::JSON.decode(options)#JSON.parse(f.options) options = JSON.parse(f.options) if f.field_type == 'multiple' if f.help @@ -466,12 +488,27 @@ module ApplicationHelper kv = value.split(/\s*\|\s*/, 2) opts[kv[0]] = kv[1] end - opts.each do |key, value| - #html += self.send(options['selection_type'] + '_tag', 'field-' + id) - html += field((id + '_' + key), options['selection_type'] + '_tag', label: value) + + val = response ? ActiveSupport::JSON.decode(response.data) : Hash.new + #val = nil + + if f.repeats? + is_array = f.is_array? + opts.each do |key, value| + #html += self.send(options['selection_type'] + '_tag', 'field-' + id) + #ActiveSupport::JSON.decode(key) + if is_array + #x + end + html += field((id + (is_array ? ('_' + key) : '')).to_sym, options['selection_type'] + '_tag', label: value, value: is_array ? (val ? val[key] : nil) : key, checked: is_array ? (val[key] == "1" || val[key] == "on") : val.to_s == key.to_s) + end + else + html += field(id.to_sym, options['selection_type'] + '_tag', opts, value: val) end + #html += collection_check_boxes nil, nil, opts, nil, :key else - html += field(id.to_sym, options['input_type'] + '_tag', label: false, placeholder: f.help) + #x + html += field(id.to_sym, options['input_type'] + '_tag', label: false, placeholder: f.help, value: response ? ActiveSupport::JSON.decode(response.data) : nil) end html.html_safe diff --git a/app/helpers/workshops_helper.rb b/app/helpers/workshops_helper.rb new file mode 100644 index 0000000..215662b --- /dev/null +++ b/app/helpers/workshops_helper.rb @@ -0,0 +1,2 @@ +module WorkshopsHelper +end diff --git a/app/models/registration_form_field.rb b/app/models/registration_form_field.rb index 95f41c5..c02288d 100644 --- a/app/models/registration_form_field.rb +++ b/app/models/registration_form_field.rb @@ -56,6 +56,14 @@ class RegistrationFormField < ActiveRecord::Base o end + def repeats?() + field_type.to_s == 'multiple' && selection_type.to_s != 'select' + end + + def is_array?() + field_type.to_s == 'multiple' && selection_type.to_s != 'radio_button' + end + private def get_from_options(key) if options diff --git a/app/models/workshop.rb b/app/models/workshop.rb new file mode 100644 index 0000000..001018a --- /dev/null +++ b/app/models/workshop.rb @@ -0,0 +1,2 @@ +class Workshop < ActiveRecord::Base +end diff --git a/app/views/conferences/_registration_register.html.haml b/app/views/conferences/_registration_register.html.haml index ebff97d..d7779bd 100644 --- a/app/views/conferences/_registration_register.html.haml +++ b/app/views/conferences/_registration_register.html.haml @@ -1,7 +1,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 - @conference.registration_form_fields.each do |ff| %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 diff --git a/app/views/workshops/_form.html.haml b/app/views/workshops/_form.html.haml new file mode 100644 index 0000000..1869707 --- /dev/null +++ b/app/views/workshops/_form.html.haml @@ -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' diff --git a/app/views/workshops/edit.html.haml b/app/views/workshops/edit.html.haml new file mode 100644 index 0000000..80890c4 --- /dev/null +++ b/app/views/workshops/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing workshop + += render 'form' + += link_to 'Show', @workshop +\| += link_to 'Back', workshops_path diff --git a/app/views/workshops/index.html.haml b/app/views/workshops/index.html.haml new file mode 100644 index 0000000..1a818ef --- /dev/null +++ b/app/views/workshops/index.html.haml @@ -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 diff --git a/app/views/workshops/new.html.haml b/app/views/workshops/new.html.haml new file mode 100644 index 0000000..2f502b6 --- /dev/null +++ b/app/views/workshops/new.html.haml @@ -0,0 +1,5 @@ +%h1 New workshop + += render 'form' + += link_to 'Back', workshops_path diff --git a/app/views/workshops/show.html.haml b/app/views/workshops/show.html.haml new file mode 100644 index 0000000..fc92193 --- /dev/null +++ b/app/views/workshops/show.html.haml @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 2e373e4..0639d2d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ BikeBike::Application.routes.draw do + resources :workshops + #resources :conference_registration_responses #resources :conference_registrations diff --git a/db/migrate/20140314025647_create_workshops.rb b/db/migrate/20140314025647_create_workshops.rb new file mode 100644 index 0000000..6364339 --- /dev/null +++ b/db/migrate/20140314025647_create_workshops.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index c1cf94c..659a14c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140308173325) do +ActiveRecord::Schema.define(version: 20140314025647) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -228,4 +228,19 @@ ActiveRecord::Schema.define(version: 20140308173325) do t.datetime "updated_at" end + create_table "workshops", force: true 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.datetime "created_at" + t.datetime "updated_at" + end + end diff --git a/test/controllers/workshops_controller_test.rb b/test/controllers/workshops_controller_test.rb new file mode 100644 index 0000000..efd6e97 --- /dev/null +++ b/test/controllers/workshops_controller_test.rb @@ -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 diff --git a/test/factories/workshops.rb b/test/factories/workshops.rb new file mode 100644 index 0000000..95c8b6c --- /dev/null +++ b/test/factories/workshops.rb @@ -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 diff --git a/test/helpers/workshops_helper_test.rb b/test/helpers/workshops_helper_test.rb new file mode 100644 index 0000000..272f968 --- /dev/null +++ b/test/helpers/workshops_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class WorkshopsHelperTest < ActionView::TestCase +end diff --git a/test/models/workshop_test.rb b/test/models/workshop_test.rb new file mode 100644 index 0000000..fe26431 --- /dev/null +++ b/test/models/workshop_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class WorkshopTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 8e26bb1797a3b14c47c9d85412da67aeb333901e Mon Sep 17 00:00:00 2001 From: Godwin Date: Sat, 15 Mar 2014 13:40:38 -0600 Subject: [PATCH 02/15] Workshop and event scaffolds --- app/assets/javascripts/event_types.js.coffee | 3 + app/assets/javascripts/events.js.coffee | 3 + .../workshop_facilitators.js.coffee | 3 + .../workshop_requested_resources.js.coffee | 3 + app/assets/stylesheets/event_types.css.scss | 3 + app/assets/stylesheets/events.css.scss | 3 + .../workshop_facilitators.css.scss | 3 + .../workshop_requested_resources.css.scss | 3 + app/controllers/event_types_controller.rb | 58 +++++++++++++++++++ app/controllers/events_controller.rb | 58 +++++++++++++++++++ .../workshop_facilitators_controller.rb | 58 +++++++++++++++++++ ...workshop_requested_resources_controller.rb | 58 +++++++++++++++++++ app/helpers/event_types_helper.rb | 2 + app/helpers/events_helper.rb | 2 + app/helpers/workshop_facilitators_helper.rb | 2 + .../workshop_requested_resources_helper.rb | 2 + app/models/event.rb | 2 + app/models/event_type.rb | 2 + app/models/workshop_facilitator.rb | 2 + app/models/workshop_requested_resource.rb | 2 + app/views/event_types/_form.html.haml | 16 +++++ app/views/event_types/edit.html.haml | 7 +++ app/views/event_types/index.html.haml | 21 +++++++ app/views/event_types/new.html.haml | 5 ++ app/views/event_types/show.html.haml | 12 ++++ app/views/events/_form.html.haml | 34 +++++++++++ app/views/events/edit.html.haml | 7 +++ app/views/events/index.html.haml | 33 +++++++++++ app/views/events/new.html.haml | 5 ++ app/views/events/show.html.haml | 30 ++++++++++ .../workshop_facilitators/_form.html.haml | 19 ++++++ .../workshop_facilitators/edit.html.haml | 7 +++ .../workshop_facilitators/index.html.haml | 23 ++++++++ app/views/workshop_facilitators/new.html.haml | 5 ++ .../workshop_facilitators/show.html.haml | 15 +++++ .../_form.html.haml | 19 ++++++ .../edit.html.haml | 7 +++ .../index.html.haml | 23 ++++++++ .../new.html.haml | 5 ++ .../show.html.haml | 15 +++++ config/routes.rb | 8 +++ ...0315175914_create_workshop_facilitators.rb | 11 ++++ ...222_create_workshop_requested_resources.rb | 11 ++++ .../20140315183121_create_event_types.rb | 10 ++++ db/migrate/20140315183241_create_events.rb | 16 +++++ db/schema.rb | 18 +++++- .../event_types_controller_test.rb | 49 ++++++++++++++++ test/controllers/events_controller_test.rb | 49 ++++++++++++++++ .../workshop_facilitators_controller_test.rb | 49 ++++++++++++++++ ...hop_requested_resources_controller_test.rb | 49 ++++++++++++++++ test/factories/event_types.rb | 8 +++ test/factories/events.rb | 14 +++++ test/factories/workshop_facilitators.rb | 9 +++ .../factories/workshop_requested_resources.rb | 9 +++ test/helpers/event_types_helper_test.rb | 4 ++ test/helpers/events_helper_test.rb | 4 ++ .../workshop_facilitators_helper_test.rb | 4 ++ ...orkshop_requested_resources_helper_test.rb | 4 ++ test/models/event_test.rb | 7 +++ test/models/event_type_test.rb | 7 +++ test/models/workshop_facilitator_test.rb | 7 +++ .../workshop_requested_resource_test.rb | 7 +++ 62 files changed, 933 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/event_types.js.coffee create mode 100644 app/assets/javascripts/events.js.coffee create mode 100644 app/assets/javascripts/workshop_facilitators.js.coffee create mode 100644 app/assets/javascripts/workshop_requested_resources.js.coffee create mode 100644 app/assets/stylesheets/event_types.css.scss create mode 100644 app/assets/stylesheets/events.css.scss create mode 100644 app/assets/stylesheets/workshop_facilitators.css.scss create mode 100644 app/assets/stylesheets/workshop_requested_resources.css.scss create mode 100644 app/controllers/event_types_controller.rb create mode 100644 app/controllers/events_controller.rb create mode 100644 app/controllers/workshop_facilitators_controller.rb create mode 100644 app/controllers/workshop_requested_resources_controller.rb create mode 100644 app/helpers/event_types_helper.rb create mode 100644 app/helpers/events_helper.rb create mode 100644 app/helpers/workshop_facilitators_helper.rb create mode 100644 app/helpers/workshop_requested_resources_helper.rb create mode 100644 app/models/event.rb create mode 100644 app/models/event_type.rb create mode 100644 app/models/workshop_facilitator.rb create mode 100644 app/models/workshop_requested_resource.rb create mode 100644 app/views/event_types/_form.html.haml create mode 100644 app/views/event_types/edit.html.haml create mode 100644 app/views/event_types/index.html.haml create mode 100644 app/views/event_types/new.html.haml create mode 100644 app/views/event_types/show.html.haml create mode 100644 app/views/events/_form.html.haml create mode 100644 app/views/events/edit.html.haml create mode 100644 app/views/events/index.html.haml create mode 100644 app/views/events/new.html.haml create mode 100644 app/views/events/show.html.haml create mode 100644 app/views/workshop_facilitators/_form.html.haml create mode 100644 app/views/workshop_facilitators/edit.html.haml create mode 100644 app/views/workshop_facilitators/index.html.haml create mode 100644 app/views/workshop_facilitators/new.html.haml create mode 100644 app/views/workshop_facilitators/show.html.haml create mode 100644 app/views/workshop_requested_resources/_form.html.haml create mode 100644 app/views/workshop_requested_resources/edit.html.haml create mode 100644 app/views/workshop_requested_resources/index.html.haml create mode 100644 app/views/workshop_requested_resources/new.html.haml create mode 100644 app/views/workshop_requested_resources/show.html.haml create mode 100644 db/migrate/20140315175914_create_workshop_facilitators.rb create mode 100644 db/migrate/20140315181222_create_workshop_requested_resources.rb create mode 100644 db/migrate/20140315183121_create_event_types.rb create mode 100644 db/migrate/20140315183241_create_events.rb create mode 100644 test/controllers/event_types_controller_test.rb create mode 100644 test/controllers/events_controller_test.rb create mode 100644 test/controllers/workshop_facilitators_controller_test.rb create mode 100644 test/controllers/workshop_requested_resources_controller_test.rb create mode 100644 test/factories/event_types.rb create mode 100644 test/factories/events.rb create mode 100644 test/factories/workshop_facilitators.rb create mode 100644 test/factories/workshop_requested_resources.rb create mode 100644 test/helpers/event_types_helper_test.rb create mode 100644 test/helpers/events_helper_test.rb create mode 100644 test/helpers/workshop_facilitators_helper_test.rb create mode 100644 test/helpers/workshop_requested_resources_helper_test.rb create mode 100644 test/models/event_test.rb create mode 100644 test/models/event_type_test.rb create mode 100644 test/models/workshop_facilitator_test.rb create mode 100644 test/models/workshop_requested_resource_test.rb diff --git a/app/assets/javascripts/event_types.js.coffee b/app/assets/javascripts/event_types.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/event_types.js.coffee @@ -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/ diff --git a/app/assets/javascripts/events.js.coffee b/app/assets/javascripts/events.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/events.js.coffee @@ -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/ diff --git a/app/assets/javascripts/workshop_facilitators.js.coffee b/app/assets/javascripts/workshop_facilitators.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/workshop_facilitators.js.coffee @@ -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/ diff --git a/app/assets/javascripts/workshop_requested_resources.js.coffee b/app/assets/javascripts/workshop_requested_resources.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/workshop_requested_resources.js.coffee @@ -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/ diff --git a/app/assets/stylesheets/event_types.css.scss b/app/assets/stylesheets/event_types.css.scss new file mode 100644 index 0000000..f315e26 --- /dev/null +++ b/app/assets/stylesheets/event_types.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the event_types controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/events.css.scss b/app/assets/stylesheets/events.css.scss new file mode 100644 index 0000000..04d79bd --- /dev/null +++ b/app/assets/stylesheets/events.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the events controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/workshop_facilitators.css.scss b/app/assets/stylesheets/workshop_facilitators.css.scss new file mode 100644 index 0000000..400b70f --- /dev/null +++ b/app/assets/stylesheets/workshop_facilitators.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the workshop_facilitators controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/workshop_requested_resources.css.scss b/app/assets/stylesheets/workshop_requested_resources.css.scss new file mode 100644 index 0000000..f1d8a3b --- /dev/null +++ b/app/assets/stylesheets/workshop_requested_resources.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the workshop_requested_resources controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/event_types_controller.rb b/app/controllers/event_types_controller.rb new file mode 100644 index 0000000..b6f03aa --- /dev/null +++ b/app/controllers/event_types_controller.rb @@ -0,0 +1,58 @@ +class EventTypesController < ApplicationController + before_action :set_event_type, only: [:show, :edit, :update, :destroy] + + # GET /event_types + def index + @event_types = EventType.all + end + + # GET /event_types/1 + def show + end + + # GET /event_types/new + def new + @event_type = EventType.new + end + + # GET /event_types/1/edit + def edit + end + + # POST /event_types + def create + @event_type = EventType.new(event_type_params) + + if @event_type.save + redirect_to @event_type, notice: 'Event type was successfully created.' + else + render action: 'new' + end + end + + # PATCH/PUT /event_types/1 + def update + if @event_type.update(event_type_params) + redirect_to @event_type, notice: 'Event type was successfully updated.' + else + render action: 'edit' + end + end + + # DELETE /event_types/1 + def destroy + @event_type.destroy + redirect_to event_types_url, notice: 'Event type was successfully destroyed.' + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_event_type + @event_type = EventType.find(params[:id]) + end + + # Only allow a trusted parameter "white list" through. + def event_type_params + params.require(:event_type).permit(:slug, :info) + end +end diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb new file mode 100644 index 0000000..96d871a --- /dev/null +++ b/app/controllers/events_controller.rb @@ -0,0 +1,58 @@ +class EventsController < ApplicationController + before_action :set_event, only: [:show, :edit, :update, :destroy] + + # GET /events + def index + @events = Event.all + end + + # GET /events/1 + def show + end + + # GET /events/new + def new + @event = Event.new + end + + # GET /events/1/edit + def edit + end + + # POST /events + def create + @event = Event.new(event_params) + + if @event.save + redirect_to @event, notice: 'Event was successfully created.' + else + render action: 'new' + end + end + + # PATCH/PUT /events/1 + def update + if @event.update(event_params) + redirect_to @event, notice: 'Event was successfully updated.' + else + render action: 'edit' + end + end + + # DELETE /events/1 + def destroy + @event.destroy + redirect_to events_url, notice: 'Event was successfully destroyed.' + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_event + @event = Event.find(params[:id]) + end + + # Only allow a trusted parameter "white list" through. + def event_params + params.require(:event).permit(:title, :slug, :event_type_id, :conference, :info, :location, :start_time, :end_time) + end +end diff --git a/app/controllers/workshop_facilitators_controller.rb b/app/controllers/workshop_facilitators_controller.rb new file mode 100644 index 0000000..057a6e6 --- /dev/null +++ b/app/controllers/workshop_facilitators_controller.rb @@ -0,0 +1,58 @@ +class WorkshopFacilitatorsController < ApplicationController + before_action :set_workshop_facilitator, only: [:show, :edit, :update, :destroy] + + # GET /workshop_facilitators + def index + @workshop_facilitators = WorkshopFacilitator.all + end + + # GET /workshop_facilitators/1 + def show + end + + # GET /workshop_facilitators/new + def new + @workshop_facilitator = WorkshopFacilitator.new + end + + # GET /workshop_facilitators/1/edit + def edit + end + + # POST /workshop_facilitators + def create + @workshop_facilitator = WorkshopFacilitator.new(workshop_facilitator_params) + + if @workshop_facilitator.save + redirect_to @workshop_facilitator, notice: 'Workshop facilitator was successfully created.' + else + render action: 'new' + end + end + + # PATCH/PUT /workshop_facilitators/1 + def update + if @workshop_facilitator.update(workshop_facilitator_params) + redirect_to @workshop_facilitator, notice: 'Workshop facilitator was successfully updated.' + else + render action: 'edit' + end + end + + # DELETE /workshop_facilitators/1 + def destroy + @workshop_facilitator.destroy + redirect_to workshop_facilitators_url, notice: 'Workshop facilitator was successfully destroyed.' + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_workshop_facilitator + @workshop_facilitator = WorkshopFacilitator.find(params[:id]) + end + + # Only allow a trusted parameter "white list" through. + def workshop_facilitator_params + params.require(:workshop_facilitator).permit(:user_id, :workshop_id, :role) + end +end diff --git a/app/controllers/workshop_requested_resources_controller.rb b/app/controllers/workshop_requested_resources_controller.rb new file mode 100644 index 0000000..24a3beb --- /dev/null +++ b/app/controllers/workshop_requested_resources_controller.rb @@ -0,0 +1,58 @@ +class WorkshopRequestedResourcesController < ApplicationController + before_action :set_workshop_requested_resource, only: [:show, :edit, :update, :destroy] + + # GET /workshop_requested_resources + def index + @workshop_requested_resources = WorkshopRequestedResource.all + end + + # GET /workshop_requested_resources/1 + def show + end + + # GET /workshop_requested_resources/new + def new + @workshop_requested_resource = WorkshopRequestedResource.new + end + + # GET /workshop_requested_resources/1/edit + def edit + end + + # POST /workshop_requested_resources + def create + @workshop_requested_resource = WorkshopRequestedResource.new(workshop_requested_resource_params) + + if @workshop_requested_resource.save + redirect_to @workshop_requested_resource, notice: 'Workshop requested resource was successfully created.' + else + render action: 'new' + end + end + + # PATCH/PUT /workshop_requested_resources/1 + def update + if @workshop_requested_resource.update(workshop_requested_resource_params) + redirect_to @workshop_requested_resource, notice: 'Workshop requested resource was successfully updated.' + else + render action: 'edit' + end + end + + # DELETE /workshop_requested_resources/1 + def destroy + @workshop_requested_resource.destroy + redirect_to workshop_requested_resources_url, notice: 'Workshop requested resource was successfully destroyed.' + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_workshop_requested_resource + @workshop_requested_resource = WorkshopRequestedResource.find(params[:id]) + end + + # Only allow a trusted parameter "white list" through. + def workshop_requested_resource_params + params.require(:workshop_requested_resource).permit(:workshop_id, :workshop_resource_id, :status) + end +end diff --git a/app/helpers/event_types_helper.rb b/app/helpers/event_types_helper.rb new file mode 100644 index 0000000..bf74a6e --- /dev/null +++ b/app/helpers/event_types_helper.rb @@ -0,0 +1,2 @@ +module EventTypesHelper +end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb new file mode 100644 index 0000000..8a9a878 --- /dev/null +++ b/app/helpers/events_helper.rb @@ -0,0 +1,2 @@ +module EventsHelper +end diff --git a/app/helpers/workshop_facilitators_helper.rb b/app/helpers/workshop_facilitators_helper.rb new file mode 100644 index 0000000..302508e --- /dev/null +++ b/app/helpers/workshop_facilitators_helper.rb @@ -0,0 +1,2 @@ +module WorkshopFacilitatorsHelper +end diff --git a/app/helpers/workshop_requested_resources_helper.rb b/app/helpers/workshop_requested_resources_helper.rb new file mode 100644 index 0000000..47680fa --- /dev/null +++ b/app/helpers/workshop_requested_resources_helper.rb @@ -0,0 +1,2 @@ +module WorkshopRequestedResourcesHelper +end diff --git a/app/models/event.rb b/app/models/event.rb new file mode 100644 index 0000000..3a829fd --- /dev/null +++ b/app/models/event.rb @@ -0,0 +1,2 @@ +class Event < ActiveRecord::Base +end diff --git a/app/models/event_type.rb b/app/models/event_type.rb new file mode 100644 index 0000000..3c7329a --- /dev/null +++ b/app/models/event_type.rb @@ -0,0 +1,2 @@ +class EventType < ActiveRecord::Base +end diff --git a/app/models/workshop_facilitator.rb b/app/models/workshop_facilitator.rb new file mode 100644 index 0000000..cbd4419 --- /dev/null +++ b/app/models/workshop_facilitator.rb @@ -0,0 +1,2 @@ +class WorkshopFacilitator < ActiveRecord::Base +end diff --git a/app/models/workshop_requested_resource.rb b/app/models/workshop_requested_resource.rb new file mode 100644 index 0000000..317eea9 --- /dev/null +++ b/app/models/workshop_requested_resource.rb @@ -0,0 +1,2 @@ +class WorkshopRequestedResource < ActiveRecord::Base +end diff --git a/app/views/event_types/_form.html.haml b/app/views/event_types/_form.html.haml new file mode 100644 index 0000000..99cb943 --- /dev/null +++ b/app/views/event_types/_form.html.haml @@ -0,0 +1,16 @@ += form_for @event_type do |f| + - if @event_type.errors.any? + #error_explanation + %h2= "#{pluralize(@event_type.errors.count, "error")} prohibited this event_type from being saved:" + %ul + - @event_type.errors.full_messages.each do |msg| + %li= msg + + .field + = f.label :slug + = f.text_field :slug + .field + = f.label :info + = f.text_area :info + .actions + = f.submit 'Save' diff --git a/app/views/event_types/edit.html.haml b/app/views/event_types/edit.html.haml new file mode 100644 index 0000000..4d1d4c1 --- /dev/null +++ b/app/views/event_types/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing event_type + += render 'form' + += link_to 'Show', @event_type +\| += link_to 'Back', event_types_path diff --git a/app/views/event_types/index.html.haml b/app/views/event_types/index.html.haml new file mode 100644 index 0000000..8c75a12 --- /dev/null +++ b/app/views/event_types/index.html.haml @@ -0,0 +1,21 @@ +%h1 Listing event_types + +%table + %tr + %th Slug + %th Info + %th + %th + %th + + - @event_types.each do |event_type| + %tr + %td= event_type.slug + %td= event_type.info + %td= link_to 'Show', event_type + %td= link_to 'Edit', edit_event_type_path(event_type) + %td= link_to 'Destroy', event_type, :method => :delete, :data => { :confirm => 'Are you sure?' } + +%br + += link_to 'New Event type', new_event_type_path diff --git a/app/views/event_types/new.html.haml b/app/views/event_types/new.html.haml new file mode 100644 index 0000000..ff86de1 --- /dev/null +++ b/app/views/event_types/new.html.haml @@ -0,0 +1,5 @@ +%h1 New event_type + += render 'form' + += link_to 'Back', event_types_path diff --git a/app/views/event_types/show.html.haml b/app/views/event_types/show.html.haml new file mode 100644 index 0000000..a37627f --- /dev/null +++ b/app/views/event_types/show.html.haml @@ -0,0 +1,12 @@ +%p#notice= notice + +%p + %b Slug: + = @event_type.slug +%p + %b Info: + = @event_type.info + += link_to 'Edit', edit_event_type_path(@event_type) +\| += link_to 'Back', event_types_path diff --git a/app/views/events/_form.html.haml b/app/views/events/_form.html.haml new file mode 100644 index 0000000..e87849b --- /dev/null +++ b/app/views/events/_form.html.haml @@ -0,0 +1,34 @@ += form_for @event do |f| + - if @event.errors.any? + #error_explanation + %h2= "#{pluralize(@event.errors.count, "error")} prohibited this event from being saved:" + %ul + - @event.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 :event_type_id + = f.number_field :event_type_id + .field + = f.label :conference + = f.text_field :conference + .field + = f.label :info + = f.text_area :info + .field + = f.label :location + = f.text_field :location + .field + = f.label :start_time + = f.datetime_select :start_time + .field + = f.label :end_time + = f.datetime_select :end_time + .actions + = f.submit 'Save' diff --git a/app/views/events/edit.html.haml b/app/views/events/edit.html.haml new file mode 100644 index 0000000..5828e7a --- /dev/null +++ b/app/views/events/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing event + += render 'form' + += link_to 'Show', @event +\| += link_to 'Back', events_path diff --git a/app/views/events/index.html.haml b/app/views/events/index.html.haml new file mode 100644 index 0000000..1f3bc64 --- /dev/null +++ b/app/views/events/index.html.haml @@ -0,0 +1,33 @@ +%h1 Listing events + +%table + %tr + %th Title + %th Slug + %th Event type + %th Conference + %th Info + %th Location + %th Start time + %th End time + %th + %th + %th + + - @events.each do |event| + %tr + %td= event.title + %td= event.slug + %td= event.event_type_id + %td= event.conference + %td= event.info + %td= event.location + %td= event.start_time + %td= event.end_time + %td= link_to 'Show', event + %td= link_to 'Edit', edit_event_path(event) + %td= link_to 'Destroy', event, :method => :delete, :data => { :confirm => 'Are you sure?' } + +%br + += link_to 'New Event', new_event_path diff --git a/app/views/events/new.html.haml b/app/views/events/new.html.haml new file mode 100644 index 0000000..6e0cccf --- /dev/null +++ b/app/views/events/new.html.haml @@ -0,0 +1,5 @@ +%h1 New event + += render 'form' + += link_to 'Back', events_path diff --git a/app/views/events/show.html.haml b/app/views/events/show.html.haml new file mode 100644 index 0000000..7a68a3b --- /dev/null +++ b/app/views/events/show.html.haml @@ -0,0 +1,30 @@ +%p#notice= notice + +%p + %b Title: + = @event.title +%p + %b Slug: + = @event.slug +%p + %b Event type: + = @event.event_type_id +%p + %b Conference: + = @event.conference +%p + %b Info: + = @event.info +%p + %b Location: + = @event.location +%p + %b Start time: + = @event.start_time +%p + %b End time: + = @event.end_time + += link_to 'Edit', edit_event_path(@event) +\| += link_to 'Back', events_path diff --git a/app/views/workshop_facilitators/_form.html.haml b/app/views/workshop_facilitators/_form.html.haml new file mode 100644 index 0000000..d4b8741 --- /dev/null +++ b/app/views/workshop_facilitators/_form.html.haml @@ -0,0 +1,19 @@ += form_for @workshop_facilitator do |f| + - if @workshop_facilitator.errors.any? + #error_explanation + %h2= "#{pluralize(@workshop_facilitator.errors.count, "error")} prohibited this workshop_facilitator from being saved:" + %ul + - @workshop_facilitator.errors.full_messages.each do |msg| + %li= msg + + .field + = f.label :user_id + = f.number_field :user_id + .field + = f.label :workshop_id + = f.number_field :workshop_id + .field + = f.label :role + = f.text_field :role + .actions + = f.submit 'Save' diff --git a/app/views/workshop_facilitators/edit.html.haml b/app/views/workshop_facilitators/edit.html.haml new file mode 100644 index 0000000..0ed8850 --- /dev/null +++ b/app/views/workshop_facilitators/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing workshop_facilitator + += render 'form' + += link_to 'Show', @workshop_facilitator +\| += link_to 'Back', workshop_facilitators_path diff --git a/app/views/workshop_facilitators/index.html.haml b/app/views/workshop_facilitators/index.html.haml new file mode 100644 index 0000000..aaf863a --- /dev/null +++ b/app/views/workshop_facilitators/index.html.haml @@ -0,0 +1,23 @@ +%h1 Listing workshop_facilitators + +%table + %tr + %th User + %th Workshop + %th Role + %th + %th + %th + + - @workshop_facilitators.each do |workshop_facilitator| + %tr + %td= workshop_facilitator.user_id + %td= workshop_facilitator.workshop_id + %td= workshop_facilitator.role + %td= link_to 'Show', workshop_facilitator + %td= link_to 'Edit', edit_workshop_facilitator_path(workshop_facilitator) + %td= link_to 'Destroy', workshop_facilitator, :method => :delete, :data => { :confirm => 'Are you sure?' } + +%br + += link_to 'New Workshop facilitator', new_workshop_facilitator_path diff --git a/app/views/workshop_facilitators/new.html.haml b/app/views/workshop_facilitators/new.html.haml new file mode 100644 index 0000000..fdef139 --- /dev/null +++ b/app/views/workshop_facilitators/new.html.haml @@ -0,0 +1,5 @@ +%h1 New workshop_facilitator + += render 'form' + += link_to 'Back', workshop_facilitators_path diff --git a/app/views/workshop_facilitators/show.html.haml b/app/views/workshop_facilitators/show.html.haml new file mode 100644 index 0000000..f402b93 --- /dev/null +++ b/app/views/workshop_facilitators/show.html.haml @@ -0,0 +1,15 @@ +%p#notice= notice + +%p + %b User: + = @workshop_facilitator.user_id +%p + %b Workshop: + = @workshop_facilitator.workshop_id +%p + %b Role: + = @workshop_facilitator.role + += link_to 'Edit', edit_workshop_facilitator_path(@workshop_facilitator) +\| += link_to 'Back', workshop_facilitators_path diff --git a/app/views/workshop_requested_resources/_form.html.haml b/app/views/workshop_requested_resources/_form.html.haml new file mode 100644 index 0000000..b1b6045 --- /dev/null +++ b/app/views/workshop_requested_resources/_form.html.haml @@ -0,0 +1,19 @@ += form_for @workshop_requested_resource do |f| + - if @workshop_requested_resource.errors.any? + #error_explanation + %h2= "#{pluralize(@workshop_requested_resource.errors.count, "error")} prohibited this workshop_requested_resource from being saved:" + %ul + - @workshop_requested_resource.errors.full_messages.each do |msg| + %li= msg + + .field + = f.label :workshop_id + = f.number_field :workshop_id + .field + = f.label :workshop_resource_id + = f.number_field :workshop_resource_id + .field + = f.label :status + = f.text_field :status + .actions + = f.submit 'Save' diff --git a/app/views/workshop_requested_resources/edit.html.haml b/app/views/workshop_requested_resources/edit.html.haml new file mode 100644 index 0000000..ec78d77 --- /dev/null +++ b/app/views/workshop_requested_resources/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing workshop_requested_resource + += render 'form' + += link_to 'Show', @workshop_requested_resource +\| += link_to 'Back', workshop_requested_resources_path diff --git a/app/views/workshop_requested_resources/index.html.haml b/app/views/workshop_requested_resources/index.html.haml new file mode 100644 index 0000000..10281f0 --- /dev/null +++ b/app/views/workshop_requested_resources/index.html.haml @@ -0,0 +1,23 @@ +%h1 Listing workshop_requested_resources + +%table + %tr + %th Workshop + %th Workshop resource + %th Status + %th + %th + %th + + - @workshop_requested_resources.each do |workshop_requested_resource| + %tr + %td= workshop_requested_resource.workshop_id + %td= workshop_requested_resource.workshop_resource_id + %td= workshop_requested_resource.status + %td= link_to 'Show', workshop_requested_resource + %td= link_to 'Edit', edit_workshop_requested_resource_path(workshop_requested_resource) + %td= link_to 'Destroy', workshop_requested_resource, :method => :delete, :data => { :confirm => 'Are you sure?' } + +%br + += link_to 'New Workshop requested resource', new_workshop_requested_resource_path diff --git a/app/views/workshop_requested_resources/new.html.haml b/app/views/workshop_requested_resources/new.html.haml new file mode 100644 index 0000000..376f258 --- /dev/null +++ b/app/views/workshop_requested_resources/new.html.haml @@ -0,0 +1,5 @@ +%h1 New workshop_requested_resource + += render 'form' + += link_to 'Back', workshop_requested_resources_path diff --git a/app/views/workshop_requested_resources/show.html.haml b/app/views/workshop_requested_resources/show.html.haml new file mode 100644 index 0000000..92982bc --- /dev/null +++ b/app/views/workshop_requested_resources/show.html.haml @@ -0,0 +1,15 @@ +%p#notice= notice + +%p + %b Workshop: + = @workshop_requested_resource.workshop_id +%p + %b Workshop resource: + = @workshop_requested_resource.workshop_resource_id +%p + %b Status: + = @workshop_requested_resource.status + += link_to 'Edit', edit_workshop_requested_resource_path(@workshop_requested_resource) +\| += link_to 'Back', workshop_requested_resources_path diff --git a/config/routes.rb b/config/routes.rb index 0639d2d..f4113aa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,13 @@ BikeBike::Application.routes.draw do + resources :events + + resources :event_types + + resources :workshop_requested_resources + + resources :workshop_facilitators + resources :workshops #resources :conference_registration_responses diff --git a/db/migrate/20140315175914_create_workshop_facilitators.rb b/db/migrate/20140315175914_create_workshop_facilitators.rb new file mode 100644 index 0000000..60fa88c --- /dev/null +++ b/db/migrate/20140315175914_create_workshop_facilitators.rb @@ -0,0 +1,11 @@ +class CreateWorkshopFacilitators < ActiveRecord::Migration + def change + create_table :workshop_facilitators do |t| + t.integer :user_id + t.integer :workshop_id + t.string :role + + t.timestamps + end + end +end diff --git a/db/migrate/20140315181222_create_workshop_requested_resources.rb b/db/migrate/20140315181222_create_workshop_requested_resources.rb new file mode 100644 index 0000000..1a1878c --- /dev/null +++ b/db/migrate/20140315181222_create_workshop_requested_resources.rb @@ -0,0 +1,11 @@ +class CreateWorkshopRequestedResources < ActiveRecord::Migration + def change + create_table :workshop_requested_resources do |t| + t.integer :workshop_id + t.integer :workshop_resource_id + t.string :status + + t.timestamps + end + end +end diff --git a/db/migrate/20140315183121_create_event_types.rb b/db/migrate/20140315183121_create_event_types.rb new file mode 100644 index 0000000..68f2ad6 --- /dev/null +++ b/db/migrate/20140315183121_create_event_types.rb @@ -0,0 +1,10 @@ +class CreateEventTypes < ActiveRecord::Migration + def change + create_table :event_types do |t| + t.string :slug + t.text :info + + t.timestamps + end + end +end diff --git a/db/migrate/20140315183241_create_events.rb b/db/migrate/20140315183241_create_events.rb new file mode 100644 index 0000000..cc6d69b --- /dev/null +++ b/db/migrate/20140315183241_create_events.rb @@ -0,0 +1,16 @@ +class CreateEvents < ActiveRecord::Migration + def change + create_table :events do |t| + t.string :title + t.string :slug + t.integer :event_type_id + t.conference_id :conference + t.text :info + t.location_id :location + t.datetime :start_time + t.datetime :end_time + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 659a14c..cd6a1bd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140314025647) do +ActiveRecord::Schema.define(version: 20140315181222) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -204,6 +204,14 @@ ActiveRecord::Schema.define(version: 20140314025647) do t.text "value" end + create_table "workshop_facilitators", force: true do |t| + t.integer "user_id" + t.integer "workshop_id" + t.string "role" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "workshop_presentation_styles", force: true do |t| t.string "name" t.string "slug" @@ -212,6 +220,14 @@ ActiveRecord::Schema.define(version: 20140314025647) do t.datetime "updated_at" end + create_table "workshop_requested_resources", force: true do |t| + t.integer "workshop_id" + t.integer "workshop_resource_id" + t.string "status" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "workshop_resources", force: true do |t| t.string "name" t.string "slug" diff --git a/test/controllers/event_types_controller_test.rb b/test/controllers/event_types_controller_test.rb new file mode 100644 index 0000000..b0ac75c --- /dev/null +++ b/test/controllers/event_types_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class EventTypesControllerTest < ActionController::TestCase + setup do + @event_type = event_types(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:event_types) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create event_type" do + assert_difference('EventType.count') do + post :create, event_type: { info: @event_type.info, slug: @event_type.slug } + end + + assert_redirected_to event_type_path(assigns(:event_type)) + end + + test "should show event_type" do + get :show, id: @event_type + assert_response :success + end + + test "should get edit" do + get :edit, id: @event_type + assert_response :success + end + + test "should update event_type" do + patch :update, id: @event_type, event_type: { info: @event_type.info, slug: @event_type.slug } + assert_redirected_to event_type_path(assigns(:event_type)) + end + + test "should destroy event_type" do + assert_difference('EventType.count', -1) do + delete :destroy, id: @event_type + end + + assert_redirected_to event_types_path + end +end diff --git a/test/controllers/events_controller_test.rb b/test/controllers/events_controller_test.rb new file mode 100644 index 0000000..eddc1ea --- /dev/null +++ b/test/controllers/events_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class EventsControllerTest < ActionController::TestCase + setup do + @event = events(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:events) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create event" do + assert_difference('Event.count') do + post :create, event: { conference: @event.conference, end_time: @event.end_time, event_type_id: @event.event_type_id, info: @event.info, location: @event.location, slug: @event.slug, start_time: @event.start_time, title: @event.title } + end + + assert_redirected_to event_path(assigns(:event)) + end + + test "should show event" do + get :show, id: @event + assert_response :success + end + + test "should get edit" do + get :edit, id: @event + assert_response :success + end + + test "should update event" do + patch :update, id: @event, event: { conference: @event.conference, end_time: @event.end_time, event_type_id: @event.event_type_id, info: @event.info, location: @event.location, slug: @event.slug, start_time: @event.start_time, title: @event.title } + assert_redirected_to event_path(assigns(:event)) + end + + test "should destroy event" do + assert_difference('Event.count', -1) do + delete :destroy, id: @event + end + + assert_redirected_to events_path + end +end diff --git a/test/controllers/workshop_facilitators_controller_test.rb b/test/controllers/workshop_facilitators_controller_test.rb new file mode 100644 index 0000000..11a4f9c --- /dev/null +++ b/test/controllers/workshop_facilitators_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class WorkshopFacilitatorsControllerTest < ActionController::TestCase + setup do + @workshop_facilitator = workshop_facilitators(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:workshop_facilitators) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create workshop_facilitator" do + assert_difference('WorkshopFacilitator.count') do + post :create, workshop_facilitator: { role: @workshop_facilitator.role, user_id: @workshop_facilitator.user_id, workshop_id: @workshop_facilitator.workshop_id } + end + + assert_redirected_to workshop_facilitator_path(assigns(:workshop_facilitator)) + end + + test "should show workshop_facilitator" do + get :show, id: @workshop_facilitator + assert_response :success + end + + test "should get edit" do + get :edit, id: @workshop_facilitator + assert_response :success + end + + test "should update workshop_facilitator" do + patch :update, id: @workshop_facilitator, workshop_facilitator: { role: @workshop_facilitator.role, user_id: @workshop_facilitator.user_id, workshop_id: @workshop_facilitator.workshop_id } + assert_redirected_to workshop_facilitator_path(assigns(:workshop_facilitator)) + end + + test "should destroy workshop_facilitator" do + assert_difference('WorkshopFacilitator.count', -1) do + delete :destroy, id: @workshop_facilitator + end + + assert_redirected_to workshop_facilitators_path + end +end diff --git a/test/controllers/workshop_requested_resources_controller_test.rb b/test/controllers/workshop_requested_resources_controller_test.rb new file mode 100644 index 0000000..f5c9c89 --- /dev/null +++ b/test/controllers/workshop_requested_resources_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class WorkshopRequestedResourcesControllerTest < ActionController::TestCase + setup do + @workshop_requested_resource = workshop_requested_resources(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:workshop_requested_resources) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create workshop_requested_resource" do + assert_difference('WorkshopRequestedResource.count') do + post :create, workshop_requested_resource: { status: @workshop_requested_resource.status, workshop_id: @workshop_requested_resource.workshop_id, workshop_resource_id: @workshop_requested_resource.workshop_resource_id } + end + + assert_redirected_to workshop_requested_resource_path(assigns(:workshop_requested_resource)) + end + + test "should show workshop_requested_resource" do + get :show, id: @workshop_requested_resource + assert_response :success + end + + test "should get edit" do + get :edit, id: @workshop_requested_resource + assert_response :success + end + + test "should update workshop_requested_resource" do + patch :update, id: @workshop_requested_resource, workshop_requested_resource: { status: @workshop_requested_resource.status, workshop_id: @workshop_requested_resource.workshop_id, workshop_resource_id: @workshop_requested_resource.workshop_resource_id } + assert_redirected_to workshop_requested_resource_path(assigns(:workshop_requested_resource)) + end + + test "should destroy workshop_requested_resource" do + assert_difference('WorkshopRequestedResource.count', -1) do + delete :destroy, id: @workshop_requested_resource + end + + assert_redirected_to workshop_requested_resources_path + end +end diff --git a/test/factories/event_types.rb b/test/factories/event_types.rb new file mode 100644 index 0000000..795e087 --- /dev/null +++ b/test/factories/event_types.rb @@ -0,0 +1,8 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :event_type do + slug "MyString" + info "MyText" + end +end diff --git a/test/factories/events.rb b/test/factories/events.rb new file mode 100644 index 0000000..2504b82 --- /dev/null +++ b/test/factories/events.rb @@ -0,0 +1,14 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :event do + title "MyString" + slug "MyString" + event_type_id 1 + conference "" + info "MyText" + location "" + start_time "2014-03-15 12:32:41" + end_time "2014-03-15 12:32:41" + end +end diff --git a/test/factories/workshop_facilitators.rb b/test/factories/workshop_facilitators.rb new file mode 100644 index 0000000..50db5c7 --- /dev/null +++ b/test/factories/workshop_facilitators.rb @@ -0,0 +1,9 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :workshop_facilitator do + user_id 1 + workshop_id 1 + role "MyString" + end +end diff --git a/test/factories/workshop_requested_resources.rb b/test/factories/workshop_requested_resources.rb new file mode 100644 index 0000000..8abaa5c --- /dev/null +++ b/test/factories/workshop_requested_resources.rb @@ -0,0 +1,9 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :workshop_requested_resource do + workshop_id 1 + workshop_resource_id 1 + status "MyString" + end +end diff --git a/test/helpers/event_types_helper_test.rb b/test/helpers/event_types_helper_test.rb new file mode 100644 index 0000000..e62047a --- /dev/null +++ b/test/helpers/event_types_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class EventTypesHelperTest < ActionView::TestCase +end diff --git a/test/helpers/events_helper_test.rb b/test/helpers/events_helper_test.rb new file mode 100644 index 0000000..2e7567e --- /dev/null +++ b/test/helpers/events_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class EventsHelperTest < ActionView::TestCase +end diff --git a/test/helpers/workshop_facilitators_helper_test.rb b/test/helpers/workshop_facilitators_helper_test.rb new file mode 100644 index 0000000..4dc1d98 --- /dev/null +++ b/test/helpers/workshop_facilitators_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class WorkshopFacilitatorsHelperTest < ActionView::TestCase +end diff --git a/test/helpers/workshop_requested_resources_helper_test.rb b/test/helpers/workshop_requested_resources_helper_test.rb new file mode 100644 index 0000000..425320a --- /dev/null +++ b/test/helpers/workshop_requested_resources_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class WorkshopRequestedResourcesHelperTest < ActionView::TestCase +end diff --git a/test/models/event_test.rb b/test/models/event_test.rb new file mode 100644 index 0000000..c6f1566 --- /dev/null +++ b/test/models/event_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class EventTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/event_type_test.rb b/test/models/event_type_test.rb new file mode 100644 index 0000000..0d42331 --- /dev/null +++ b/test/models/event_type_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class EventTypeTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/workshop_facilitator_test.rb b/test/models/workshop_facilitator_test.rb new file mode 100644 index 0000000..4a15969 --- /dev/null +++ b/test/models/workshop_facilitator_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class WorkshopFacilitatorTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/workshop_requested_resource_test.rb b/test/models/workshop_requested_resource_test.rb new file mode 100644 index 0000000..bce24ce --- /dev/null +++ b/test/models/workshop_requested_resource_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class WorkshopRequestedResourceTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 243c47a6e78cc4ce94f4f3093151990a95a535e5 Mon Sep 17 00:00:00 2001 From: Godwin Date: Sat, 15 Mar 2014 13:46:24 -0600 Subject: [PATCH 03/15] Messed up event migration --- db/migrate/20140315183241_create_events.rb | 4 ++-- db/schema.rb | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/db/migrate/20140315183241_create_events.rb b/db/migrate/20140315183241_create_events.rb index cc6d69b..30dc8ae 100644 --- a/db/migrate/20140315183241_create_events.rb +++ b/db/migrate/20140315183241_create_events.rb @@ -4,9 +4,9 @@ class CreateEvents < ActiveRecord::Migration t.string :title t.string :slug t.integer :event_type_id - t.conference_id :conference + t.integer :conference_id t.text :info - t.location_id :location + t.integer :location_id t.datetime :start_time t.datetime :end_time diff --git a/db/schema.rb b/db/schema.rb index cd6a1bd..6d53cdb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140315181222) do +ActiveRecord::Schema.define(version: 20140315183241) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -92,6 +92,26 @@ ActiveRecord::Schema.define(version: 20140315181222) do t.text "postregistration_info" end + create_table "event_types", force: true do |t| + t.string "slug" + t.text "info" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "events", force: true do |t| + t.string "title" + t.string "slug" + t.integer "event_type_id" + t.integer "conference_id" + t.text "info" + t.integer "location_id" + t.datetime "start_time" + t.datetime "end_time" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "locations", force: true do |t| t.string "title" t.float "latitude" From 55d47180e05592b638e43ad5c10b0e52e396913c Mon Sep 17 00:00:00 2001 From: Godwin Date: Sat, 15 Mar 2014 20:43:16 -0600 Subject: [PATCH 04/15] Fixed some issues with registration --- DB specs.txt | 14 ++-------- Gemfile | 1 - app/assets/javascripts/application.js.coffee | 1 - .../registration_form_fields_controller.rb | 9 ++++--- app/helpers/application_helper.rb | 27 +++++++------------ .../registration_form_fields/_form.html.haml | 3 ++- 6 files changed, 19 insertions(+), 36 deletions(-) diff --git a/DB specs.txt b/DB specs.txt index 1cf838e..aa82ac6 100644 --- a/DB specs.txt +++ b/DB specs.txt @@ -22,7 +22,7 @@ - slug : string - info : text -event +*event - title : string - slug : string - conference : [conference] @@ -66,18 +66,12 @@ event - other_option : *boolean - retired : boolean -request - - comment : text - - object : Nto1[object] - - is_invite : boolean - - state : list(string) - *user_organization_relationship - user : [user] - organization : [organization] - relationship : string -workshop +*workshop - title : string - slug : string - info : text @@ -106,7 +100,3 @@ workshop - slug : string - info : text -rails g scaffold workshop title:string slug:string info:text conference_id:integer workshop_stream_id:integer workshop_presentation_style:integer min_facilitators:integer location_id:integer start_time:datetime end_time:datetime - - - requested_resources : NtoN[workshop_resource] - - facilitators : NtoN[user] \ No newline at end of file diff --git a/Gemfile b/Gemfile index a978330..6bd5e90 100644 --- a/Gemfile +++ b/Gemfile @@ -48,7 +48,6 @@ gem "compass-rails", "~> 1.1.3" gem 'foundation-rails' gem 'turbolinks' gem 'uglifier', '>= 1.3.0' -#gem 'bcrypt-ruby', git: 'https://github.com/codahale/bcrypt-ruby.git' gem 'sorcery', '>= 0.8.1' gem 'oauth2', '~> 0.8.0' gem 'ruby-drupal-hash' diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index d420b72..1313f97 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -113,7 +113,6 @@ updateFormFieldList = () -> (json) -> $('#conference-form').html(json.form) $('#registration-form-field-list').html(json.list) - #console.log json updateFormFieldList() return $('#conference-form .remove-form-field').click () -> diff --git a/app/controllers/registration_form_fields_controller.rb b/app/controllers/registration_form_fields_controller.rb index 335d65d..b6493c2 100644 --- a/app/controllers/registration_form_fields_controller.rb +++ b/app/controllers/registration_form_fields_controller.rb @@ -38,7 +38,10 @@ class RegistrationFormFieldsController < ApplicationController private def ajax_return(success) - @registration_form_fields = RegistrationFormField.all + if params[:conference_id] + @conference = Conference.find(params[:conference_id]) + @registration_form_fields = RegistrationFormField.where(["id NOT IN (?)", @conference.registration_form_fields.map(&:id)]) + end if success @registration_form_field = RegistrationFormField.new end @@ -54,13 +57,11 @@ class RegistrationFormFieldsController < ApplicationController # Only allow a trusted parameter "white list" through. def registration_form_field_params - #type = params[:type] - #allowed = RegistrationFormField::Types[type] - #allowed << 'field_type' rff_params = params.require(:registration_form_field) allowed = RegistrationFormField::GetNonOptionKeys(rff_params[:field_type], rff_params) p = rff_params.send('permit', *allowed)#permit(:title, :help, :required, :field_type, :options, :is_retired) p[:options] = RegistrationFormField::GetOptions(rff_params[:field_type], rff_params).to_json.to_s + p[:field_type] = rff_params[:field_type] p end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2b5cc7f..38dcf23 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -201,7 +201,7 @@ module ApplicationHelper end end - def field(form, name, type = nil, param = nil, html: nil, help: false, attrs: [], classes: nil, label: nil, placeholder: nil, value: nil, checked: nil) + def field(form, name, type = nil, param = nil, html: nil, help: false, attrs: [], classes: nil, label: nil, placeholder: nil, value: nil, checked: nil, required: false) if form.is_a?(Symbol) || form.is_a?(String) param = type @@ -226,7 +226,7 @@ module ApplicationHelper end select_prompt = nil - show_label = true + show_label = !(/^hidden_field/.match(type.to_s)) label_after = true value_attribute = !form @@ -262,7 +262,7 @@ module ApplicationHelper label_html = eval("(" + (form ? 'form.label' : 'label_tag') + " name, '#{label ? CGI.escapeHTML(label) : name}'.html_safe)") end - if label === false + if label === false || !show_label label_html = '' end @@ -354,7 +354,9 @@ module ApplicationHelper end end form_html += (html_options || '') - puts "\n\t" + form_html + "\n" + if required + form_html += ', :required => true' + end form_html = eval(form_html) if root form_html = "<#{root}>" + form_html + "" @@ -474,9 +476,8 @@ module ApplicationHelper def form_field(f, response = nil) id = 'field_' + f.id.to_s - html = p(f, 'title')#'' + html = p(f, 'title') - #options = ActiveSupport::JSON.decode(options)#JSON.parse(f.options) options = JSON.parse(f.options) if f.field_type == 'multiple' if f.help @@ -490,25 +491,17 @@ module ApplicationHelper end val = response ? ActiveSupport::JSON.decode(response.data) : Hash.new - #val = nil if f.repeats? is_array = f.is_array? opts.each do |key, value| - #html += self.send(options['selection_type'] + '_tag', 'field-' + id) - #ActiveSupport::JSON.decode(key) - if is_array - #x - end - html += field((id + (is_array ? ('_' + key) : '')).to_sym, options['selection_type'] + '_tag', label: value, value: is_array ? (val ? val[key] : nil) : key, checked: is_array ? (val[key] == "1" || val[key] == "on") : val.to_s == key.to_s) + html += field((id + (is_array ? ('_' + key) : '')).to_sym, options['selection_type'] + '_tag', label: value, value: is_array ? (val ? val[key] : nil) : key, checked: is_array ? (val[key] == "1" || val[key] == "on") : val.to_s == key.to_s, required: f.required) end else - html += field(id.to_sym, options['selection_type'] + '_tag', opts, value: val) + html += field(id.to_sym, options['selection_type'] + '_tag', opts, value: val, required: f.required) end - #html += collection_check_boxes nil, nil, opts, nil, :key else - #x - html += field(id.to_sym, options['input_type'] + '_tag', label: false, placeholder: f.help, value: response ? ActiveSupport::JSON.decode(response.data) : nil) + html += field(id.to_sym, options['input_type'] + '_tag', label: false, placeholder: f.help, value: response ? ActiveSupport::JSON.decode(response.data) : nil, required: f.required) end html.html_safe diff --git a/app/views/registration_form_fields/_form.html.haml b/app/views/registration_form_fields/_form.html.haml index 3224c87..7ac254a 100644 --- a/app/views/registration_form_fields/_form.html.haml +++ b/app/views/registration_form_fields/_form.html.haml @@ -5,7 +5,8 @@ %ul - @registration_form_field.errors.full_messages.each do |msg| %li= msg - + - if @conference + = field :conference_id, :hidden_field_tag, value: @conference.id = field f, :field_type, :select, RegistrationFormField::Types.keys - RegistrationFormField::Fields.each do |key, value| - classes = RegistrationFormField::TypesForField(key.to_sym).collect{|v| 'field-type-' + v.to_s} From fda5646974830b77d0fc1733293723694e0df7ad Mon Sep 17 00:00:00 2001 From: Godwin Date: Sun, 23 Mar 2014 13:31:08 -0600 Subject: [PATCH 05/15] Testing tests --- Gemfile | 58 +++++----- Gemfile.lock | 22 ---- app/controllers/conferences_controller.rb | 8 +- app/controllers/workshops_controller.rb | 123 ++++++++++++---------- app/helpers/application_helper.rb | 16 ++- app/helpers/workshops_helper.rb | 2 + app/models/conference.rb | 2 + app/models/workshop.rb | 5 + app/views/workshops/_form.html.haml | 63 ++++------- app/views/workshops/edit.html.haml | 9 +- app/views/workshops/index.html.haml | 8 +- app/views/workshops/new.html.haml | 7 +- app/views/workshops/show.html.haml | 60 +++++------ config/environments/development.rb | 9 ++ config/routes.rb | 12 +-- db/schema.rb | 6 +- spec/features/pages_spec.rb | 8 +- 17 files changed, 209 insertions(+), 209 deletions(-) diff --git a/Gemfile b/Gemfile index 6bd5e90..28cf3aa 100644 --- a/Gemfile +++ b/Gemfile @@ -40,8 +40,8 @@ gem 'haml_assets' gem 'handlebars_assets' gem 'i18n-js' gem 'i18n-active_record', - :git => 'git://github.com/svenfuchs/i18n-active_record.git', - :require => 'i18n/active_record' + :git => 'git://github.com/svenfuchs/i18n-active_record.git', + :require => 'i18n/active_record' gem 'jquery-turbolinks' gem 'sass-rails', '~> 4.0.0' gem "compass-rails", "~> 1.1.3" @@ -55,48 +55,48 @@ gem 'redis' gem 'carrierwave' gem 'carrierwave-imageoptimizer' gem 'mini_magick' -gem 'carmen-rails', '~> 1.0.0', github: 'jim/carmen-rails' +#gem 'carmen-rails'#, '~> 1.0.0', github: 'jim/carmen-rails' gem 'nested_form' gem 'acts_as_list' -#gem 'jcrop-rails' -#gem 'rmagick' +##gem 'jcrop-rails' +##gem 'rmagick' gem 'geocoder' gem 'forgery' gem 'paper_trail' group :development, :test do - gem 'debugger' - gem 'delorean' - gem 'factory_girl_rails' - gem 'faker' - gem 'pry' - gem 'pry-rails' + gem 'debugger' + gem 'delorean' + gem 'factory_girl_rails' + #gem 'faker' + gem 'pry' + gem 'pry-rails' end group :development do - #gem 'perftools.rb' - gem 'bullet' - gem 'better_errors' - gem 'binding_of_caller' - gem 'meta_request' - gem 'haml-rails' - gem 'awesome_print' + #gem 'perftools.rb' + gem 'bullet' + gem 'better_errors' + gem 'binding_of_caller' + gem 'meta_request' + gem 'haml-rails' + gem 'awesome_print' end group :test do - gem 'capybara' - gem 'coveralls', require: false - gem 'database_cleaner' - gem 'email_spec' - gem 'launchy' - gem 'rspec' - gem 'rspec-rails' - gem 'selenium-webdriver' - gem 'simplecov', require: false - gem 'webmock', require: false + gem 'capybara' + gem 'coveralls', require: false + gem 'database_cleaner' + gem 'email_spec' + gem 'launchy' + gem 'rspec' + gem 'rspec-rails' + gem 'selenium-webdriver' + gem 'simplecov', require: false + gem 'webmock', require: false end group :staging, :production do - gem 'rails_12factor' + gem 'rails_12factor' end diff --git a/Gemfile.lock b/Gemfile.lock index ac4e465..86ef600 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,11 +1,3 @@ -GIT - remote: git://github.com/jim/carmen-rails.git - revision: 076dd251e075d07408e0b5268f886956ef2a347c - specs: - carmen-rails (1.0.0) - carmen (~> 1.0.0) - rails - GIT remote: git://github.com/svenfuchs/i18n-active_record.git revision: 55507cf59f8f2173d38e07e18df0e90d25b1f0f6 @@ -65,8 +57,6 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - carmen (1.0.0) - unicode_utils (~> 1.4.0) carrierwave (0.9.0) activemodel (>= 3.2.0) activesupport (>= 3.2.0) @@ -118,7 +108,6 @@ GEM launchy (~> 2.1) mail (~> 2.2) erubis (2.7.0) - eventmachine (1.0.3) eventmachine (1.0.3-x86-mingw32) execjs (2.0.2) factory_girl (4.4.0) @@ -126,8 +115,6 @@ GEM factory_girl_rails (4.4.0) factory_girl (~> 4.4.0) railties (>= 3.0.0) - faker (1.2.0) - i18n (~> 0.5) faraday (0.9.0) multipart-post (>= 1.2, < 3) ffi (1.9.3-x86-mingw32) @@ -187,8 +174,6 @@ GEM multi_json (1.8.4) multipart-post (2.0.0) nested_form (0.3.2) - nokogiri (1.6.1) - mini_portile (~> 0.5.0) nokogiri (1.6.1-x86-mingw32) mini_portile (~> 0.5.0) oauth (0.4.7) @@ -203,10 +188,6 @@ GEM activesupport (>= 3.0, < 5.0) pg (0.17.1-x86-mingw32) polyglot (0.3.3) - pry (0.9.12.6) - coderay (~> 1.0) - method_source (~> 0.8) - slop (~> 3.4) pry (0.9.12.6-x86-mingw32) coderay (~> 1.0) method_source (~> 0.8) @@ -310,7 +291,6 @@ GEM uglifier (2.4.0) execjs (>= 0.3.0) json (>= 1.8.0) - unicode_utils (1.4.0) uniform_notifier (1.4.0) webmock (1.17.3) addressable (>= 2.2.7) @@ -330,7 +310,6 @@ DEPENDENCIES binding_of_caller bullet capybara - carmen-rails (~> 1.0.0)! carrierwave carrierwave-imageoptimizer coffee-rails (~> 4.0.0) @@ -341,7 +320,6 @@ DEPENDENCIES delorean email_spec factory_girl_rails - faker forgery foundation-rails geocoder diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index d5b577a..028daa3 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -125,6 +125,12 @@ class ConferencesController < ApplicationController set_conference end + def workshops + set_conference + @workshops = Workshop.where(:conference_id => @conference.id) + render 'workshops/index' + end + # DELETE /conferences/1 def destroy @conference.destroy @@ -134,7 +140,7 @@ class ConferencesController < ApplicationController private # Use callbacks to share common setup or constraints between actions. def set_conference - @conference = Conference.find_by(slug: params[:slug] || params[:conference_slug]) + @conference = Conference.find_by(slug: params[:conference_slug] || params[:slug]) set_conference_registration end diff --git a/app/controllers/workshops_controller.rb b/app/controllers/workshops_controller.rb index 853cbe3..ef4611d 100644 --- a/app/controllers/workshops_controller.rb +++ b/app/controllers/workshops_controller.rb @@ -1,58 +1,69 @@ 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 + before_action :set_workshop, only: [:show, :edit, :update, :destroy] + + # GET /workshops + def index + set_conference + @workshops = Workshop.where(['conference_id = ?', @conference.id]) + end + + # GET /workshops/1 + def show + set_workshop + set_conference + end + + # GET /workshops/new + def new + set_conference + @workshop = Workshop.new + end + + # GET /workshops/1/edit + def edit + set_conference + end + + # POST /workshops + def create + set_conference + @workshop = Workshop.new(workshop_params) + + if @workshop.save + redirect_to conference_workshop_path(@conference, @workshop), notice: 'Workshop was successfully created.' + else + render action: 'new' + end + end + + # PATCH/PUT /workshops/1 + def update + set_conference + if @workshop.update(workshop_params) + redirect_to conference_workshop_path(@conference, @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_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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 38dcf23..08fcbe0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -406,7 +406,18 @@ module ApplicationHelper if params[:action] == tab.to_s c << 'current' end - tab_list += link_to tab, link || object, :class => c + link_html = '' + if tab.is_a?(Hash) + func = tab.keys[0] + val = tab[func] + args = val ? (val.is_a?(Array) ? (val.collect { |v| object[v] } ) : [object[val]] ) : nil + + link_html = link_to func.to_s.gsub(/_path$/, ''), args ? self.send(func, args) : self.send(func), :class => c + else + #x + link_html = link_to tab, link || object, :class => c + end + tab_list += link_html end ('