From 3933e89a9cf3853897ffaf8a4da8802ce91c48e9 Mon Sep 17 00:00:00 2001 From: Matt Barringer Date: Sat, 16 Feb 2013 13:30:53 +0100 Subject: [PATCH] Adding social events, which can be used on the registration page --- .../admin/social_events_controller.rb | 18 ++++++++++++++++++ app/models/conference.rb | 4 +++- app/models/registration.rb | 4 +++- app/models/social_event.rb | 6 ++++++ app/views/admin/conference/_sidebar.html.haml | 4 ++++ .../_social_event_fields.html.erb | 7 +++++++ .../social_events/social_events_list.html.haml | 8 ++++++++ .../conference_registration/register.html.haml | 10 ++++++++-- config/routes.rb | 2 ++ ...0130216070725_create_social_events_table.rb | 14 ++++++++++++++ ...create_registrations_social_events_table.rb | 11 +++++++++++ ...22155_set_registration_defaults_to_false.rb | 8 ++++++++ ...add_special_needs_field_to_registrations.rb | 5 +++++ db/schema.rb | 17 +++++++++++++++-- 14 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 app/controllers/admin/social_events_controller.rb create mode 100644 app/models/social_event.rb create mode 100644 app/views/admin/social_events/_social_event_fields.html.erb create mode 100644 app/views/admin/social_events/social_events_list.html.haml create mode 100644 db/migrate/20130216070725_create_social_events_table.rb create mode 100644 db/migrate/20130216120112_create_registrations_social_events_table.rb create mode 100644 db/migrate/20130216122155_set_registration_defaults_to_false.rb create mode 100644 db/migrate/20130216122417_add_special_needs_field_to_registrations.rb diff --git a/app/controllers/admin/social_events_controller.rb b/app/controllers/admin/social_events_controller.rb new file mode 100644 index 00000000..322d6225 --- /dev/null +++ b/app/controllers/admin/social_events_controller.rb @@ -0,0 +1,18 @@ +class Admin::SocialEventsController < ApplicationController + before_filter :verify_organizer + layout "admin" + + def show + render :social_events_list + end + + def update + if @conference.update_attributes(params[:conference]) + redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events were successfully updated.') + else + redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events update failed.') + end + + end + +end diff --git a/app/models/conference.rb b/app/models/conference.rb index 1b74c274..d1be19fb 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -1,13 +1,14 @@ class Conference < ActiveRecord::Base attr_accessible :title, :short_title, :social_tag, :contact_email, :timezone, :html_export_path, :start_date, :end_date, :rooms_attributes, :tracks_attributes, :dietary_choices_attributes, - :use_dietary_choices, :use_supporter_levels, :supporter_levels_attributes, + :use_dietary_choices, :use_supporter_levels, :supporter_levels_attributes, :social_events_attributes, :event_types_attributes, :registration_start_date, :registration_end_date, :logo has_paper_trail has_one :email_settings, :dependent => :destroy has_one :call_for_papers, :dependent => :destroy + has_many :social_events, :dependent => :destroy has_many :supporter_registrations, :dependent => :destroy has_many :supporter_levels, :dependent => :destroy has_many :dietary_choices, :dependent => :destroy @@ -21,6 +22,7 @@ class Conference < ActiveRecord::Base accepts_nested_attributes_for :rooms, :reject_if => proc {|r| r["name"].blank?}, :allow_destroy => true accepts_nested_attributes_for :tracks, :reject_if => proc {|r| r["name"].blank?}, :allow_destroy => true + accepts_nested_attributes_for :social_events, :allow_destroy => true accepts_nested_attributes_for :venue accepts_nested_attributes_for :dietary_choices, :allow_destroy => true accepts_nested_attributes_for :supporter_levels, :allow_destroy => true diff --git a/app/models/registration.rb b/app/models/registration.rb index 4f5c231e..9f09da59 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -4,11 +4,13 @@ class Registration < ActiveRecord::Base belongs_to :dietary_choice has_one :supporter_registration + has_and_belongs_to_many :social_events attr_accessible :person_id, :conference_id, :attending_social_events, :attending_with_partner, :using_affiliated_lodging, :arrival, :departure, :person_attributes, :other_dietary_choice, :dietary_choice_id, - :handicapped_access_required, :supporter_registration_attributes + :handicapped_access_required, :supporter_registration_attributes, :social_event_ids, :other_special_needs accepts_nested_attributes_for :person accepts_nested_attributes_for :supporter_registration + accepts_nested_attributes_for :social_events end \ No newline at end of file diff --git a/app/models/social_event.rb b/app/models/social_event.rb new file mode 100644 index 00000000..db5ac590 --- /dev/null +++ b/app/models/social_event.rb @@ -0,0 +1,6 @@ +class SocialEvent < ActiveRecord::Base + attr_accessible :title, :description, :date + + belongs_to :conference + has_and_belongs_to_many :registrations +end \ No newline at end of file diff --git a/app/views/admin/conference/_sidebar.html.haml b/app/views/admin/conference/_sidebar.html.haml index 8538a073..d1be9836 100644 --- a/app/views/admin/conference/_sidebar.html.haml +++ b/app/views/admin/conference/_sidebar.html.haml @@ -28,6 +28,10 @@ %li.active= link_to "Event Types", "#" - else %li= link_to "Event Types", admin_conference_eventtype_list_path(@conference.short_title) + - if activated == "Social Events" + %li.active= link_to "Social Events", "#" + - else + %li= link_to "Social Events", admin_conference_social_events_path(@conference.short_title) - if activated == "Emails" %li.active= link_to "Emails", "#" - else diff --git a/app/views/admin/social_events/_social_event_fields.html.erb b/app/views/admin/social_events/_social_event_fields.html.erb new file mode 100644 index 00000000..540aa4a8 --- /dev/null +++ b/app/views/admin/social_events/_social_event_fields.html.erb @@ -0,0 +1,7 @@ +
+ <%= f.inputs do %> + <%= f.input :title %> + <%= f.input :description, :input_html => {:rows => 5} %> + <%= remove_association_link :social_event, f %> + <% end %> +
diff --git a/app/views/admin/social_events/social_events_list.html.haml b/app/views/admin/social_events/social_events_list.html.haml new file mode 100644 index 00000000..c2b8a762 --- /dev/null +++ b/app/views/admin/social_events/social_events_list.html.haml @@ -0,0 +1,8 @@ +.container-fluid + .row-fluid + .span3 + = render 'admin/conference/sidebar', :activated => "Social Events" + .span9 + = semantic_form_for(@conference, :url => admin_conference_social_events_path(@conference.short_title)) do |f| + = dynamic_association :social_events, "Social Events", f + = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} \ No newline at end of file diff --git a/app/views/conference_registration/register.html.haml b/app/views/conference_registration/register.html.haml index dad44b20..276f39bc 100644 --- a/app/views/conference_registration/register.html.haml +++ b/app/views/conference_registration/register.html.haml @@ -12,14 +12,20 @@ .row-fluid .span12 = semantic_form_for(@registration, :url => register_conference_path(@conference.short_title), :html => { :method => :put }) do |f| + Public Name + %br = f.fields_for :person do |p| = p.text_field :public_name, :for => :person = f.input :attending_with_partner, :label => false - = f.input :attending_social_events, :label => false + -# = f.input :attending_social_events, :label => false = f.input :using_affiliated_lodging, :label => false = f.input :handicapped_access_required, :label => false + = f.input :other_special_needs, :label => "Any other special needs?", :input_html => {:rows => 2} = f.input :arrival, :as => :string, :input_html => {:value => (f.object.arrival.to_formatted_s(:db_without_seconds) unless f.object.arrival.nil?), :id => "registration-arrival-datepicker", :readonly => "readonly" } - = f.input :departure, :as => :string, :input_html => {:value => (f.object.departure.to_formatted_s(:db_without_seconds) unless f.object.arrival.nil?), :id => "registration-departure-datepicker", :readonly => "readonly" } + = f.input :departure, :as => :string, :input_html => {:value => (f.object.departure.to_formatted_s(:db_without_seconds) unless f.object.departure.nil?), :id => "registration-departure-datepicker", :readonly => "readonly" } + - if @conference.social_events.count > 0 + Do you plan on attending any of the parties? + = f.input :social_events, :as => :check_boxes, :label => false - if @conference.use_dietary_choices? = f.input :dietary_choice, :collection => [["None", nil]] + @conference.dietary_choices.map {|x| [x.title, x.id]}, :include_blank => false, :label => "Special Dietary Restriction" diff --git a/config/routes.rb b/config/routes.rb index 935973bb..a7761cf3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,6 +15,8 @@ Osem::Application.routes.draw do put "/supporter_levels" => "SupporterLevels#update" get "/venue" => "venue#show", :as => "venue_info" put "/venue" => "venue#update", :as => "venue_update" + get "/social_events" => "SocialEvents#show", :as => "social_events" + put "/social_events" => "SocialEvents#update", :as => "social_events" get "/rooms" => "rooms#show", :as => "rooms_list" put "/rooms" => "rooms#update", :as => "rooms_update" get "/tracks" => "tracks#show", :as => "tracks_list" diff --git a/db/migrate/20130216070725_create_social_events_table.rb b/db/migrate/20130216070725_create_social_events_table.rb new file mode 100644 index 00000000..52ebaa06 --- /dev/null +++ b/db/migrate/20130216070725_create_social_events_table.rb @@ -0,0 +1,14 @@ +class CreateSocialEventsTable < ActiveRecord::Migration + def up + create_table :social_events do |t| + t.references :conference + t.string :title + t.text :description + t.date :date + end + end + + def down + drop_table :social_events + end +end diff --git a/db/migrate/20130216120112_create_registrations_social_events_table.rb b/db/migrate/20130216120112_create_registrations_social_events_table.rb new file mode 100644 index 00000000..df245ed0 --- /dev/null +++ b/db/migrate/20130216120112_create_registrations_social_events_table.rb @@ -0,0 +1,11 @@ +class CreateRegistrationsSocialEventsTable < ActiveRecord::Migration + def up + create_table :registrations_social_events, :id => false do |t| + t.references :registration, :social_event + end + end + + def down + drop_table :registrations_social_events + end +end diff --git a/db/migrate/20130216122155_set_registration_defaults_to_false.rb b/db/migrate/20130216122155_set_registration_defaults_to_false.rb new file mode 100644 index 00000000..b8bdce04 --- /dev/null +++ b/db/migrate/20130216122155_set_registration_defaults_to_false.rb @@ -0,0 +1,8 @@ +class SetRegistrationDefaultsToFalse < ActiveRecord::Migration + def up + change_column :registrations, :using_affiliated_lodging, :boolean, :default => false + end + + def down + end +end diff --git a/db/migrate/20130216122417_add_special_needs_field_to_registrations.rb b/db/migrate/20130216122417_add_special_needs_field_to_registrations.rb new file mode 100644 index 00000000..9d438e54 --- /dev/null +++ b/db/migrate/20130216122417_add_special_needs_field_to_registrations.rb @@ -0,0 +1,5 @@ +class AddSpecialNeedsFieldToRegistrations < ActiveRecord::Migration + def change + add_column :registrations, :other_special_needs, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 61601c24..413929c1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130211170728) do +ActiveRecord::Schema.define(:version => 20130216122417) do create_table "call_for_papers", :force => true do |t| t.date "start_date", :null => false @@ -168,7 +168,7 @@ ActiveRecord::Schema.define(:version => 20130211170728) do t.integer "conference_id" t.boolean "attending_social_events", :default => true t.boolean "attending_with_partner", :default => false - t.boolean "using_affiliated_lodging", :default => true + t.boolean "using_affiliated_lodging", :default => false t.datetime "arrival" t.datetime "departure" t.text "additional_speakers" @@ -177,6 +177,12 @@ ActiveRecord::Schema.define(:version => 20130211170728) do t.integer "dietary_choice_id" t.text "other_dietary_choice" t.boolean "handicapped_access_required", :default => false + t.text "other_special_needs" + end + + create_table "registrations_social_events", :id => false, :force => true do |t| + t.integer "registration_id" + t.integer "social_event_id" end create_table "roles", :force => true do |t| @@ -198,6 +204,13 @@ ActiveRecord::Schema.define(:version => 20130211170728) do t.boolean "public", :default => true end + create_table "social_events", :force => true do |t| + t.integer "conference_id" + t.string "title" + t.text "description" + t.date "date" + end + create_table "supporter_levels", :force => true do |t| t.integer "conference_id" t.string "title", :null => false