From d2709f0570679ded9817932486235922c0ea6c78 Mon Sep 17 00:00:00 2001 From: differentreality Date: Fri, 12 Jul 2013 08:44:20 +0300 Subject: [PATCH 1/9] admin adds new user/person and registration --- app/controllers/admin/users_controller.rb | 40 ++++++++++++++++++++ app/views/admin/registrations/show.html.haml | 1 + app/views/admin/users/new.html.haml | 16 ++++++++ config/routes.rb | 1 + 4 files changed, 58 insertions(+) create mode 100644 app/views/admin/users/new.html.haml diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index a3126ab6..ac804a73 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -16,4 +16,44 @@ class Admin::UsersController < ApplicationController user.update_attributes!(params[:user]) redirect_to admin_users_path, :notice => "Updated #{user.email}" end + + def new + @user = User.new + @person = Person.where("user_id =?", @user.id) + @conferences = Conference.where("end_date >= ?", Time.now) + @conference = Conference.find_all_by_short_title(params[:format]).first + end + + def create + @conference = Conference.find_all_by_short_title(params[:id]).first + + if params[:user][:people][:first_name].blank? || params[:user][:people][:last_name].blank? + redirect_to(:back, :alert => "Please fill in your first and last name before registering.") + return + end + + params[:user][:conferences].shift + if !params[:user][:conferences].empty? + user = User.new + user.email = params[:user][:email] + user.password = params[:user][:password] + begin + user.save! + user.skip_confirmation! + person = Person.where("user_id = ?", user.id).first + person.update_attributes(params[:user][:people]) + redirect_to admin_conference_registrations_path(@conference.short_title) + flash[:notice] = "Successfully created new registration for #{person.email}." + rescue Exception => e + redirect_to(:back, :alert => e.message) + return + end + params[:user][:conferences].each do |r| + registration = person.registrations.new(:conference_id => r) + registration.save! + end + else + redirect_to(:back, :alert => "Please select at least one conference to register.") + end + end end diff --git a/app/views/admin/registrations/show.html.haml b/app/views/admin/registrations/show.html.haml index 4ba9f67b..9e88fe84 100644 --- a/app/views/admin/registrations/show.html.haml +++ b/app/views/admin/registrations/show.html.haml @@ -1,6 +1,7 @@ .row-fluid .span12 .pull-right{:style=>"margin-top:20px; margin-bottom:20px;"} + = link_to "New", admin_users_new_path(@conference.short_title), :class => "btn btn-primary" = link_to "Export PDF", admin_conference_registrations_path(@conference.short_title, :format => :pdf), :class => "btn btn-success" .row-fluid .span12 diff --git a/app/views/admin/users/new.html.haml b/app/views/admin/users/new.html.haml new file mode 100644 index 00000000..0fae3385 --- /dev/null +++ b/app/views/admin/users/new.html.haml @@ -0,0 +1,16 @@ +.row + .span12 + %h3 + Create new account and registration +.row + .span12 + = semantic_form_for(@user, :url => admin_users_new_path(:id => @conference.short_title), :html => { :method => :put }) do |f| + = f.inputs "Account Information" do + = f.input :email + = f.input :password, :hint => "Password must be at least 6 characters" + = f.inputs "Personal Information" do + = f.fields_for :people do |p| + = p.input :first_name + = p.input :last_name + = f.input :conferences, :as => :check_boxes, :label => true, :collection => @conferences + = f.action :submit, :button_html => { :value => "Create", :class => "btn btn-primary"} diff --git a/config/routes.rb b/config/routes.rb index 4fc2797d..f21d1781 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,7 @@ Osem::Application.routes.draw do devise_for :users, :controllers => { :registrations => :registrations }, :path => 'accounts' namespace :admin do + put "/users/new" => "users#create" resources :users resources :people resources :conference do From f42b7eae57a9401094fee433dbbbfc13ed0b6ea9 Mon Sep 17 00:00:00 2001 From: differentreality Date: Fri, 12 Jul 2013 09:10:33 +0300 Subject: [PATCH 2/9] add nick and affiliation --- app/views/admin/users/new.html.haml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/admin/users/new.html.haml b/app/views/admin/users/new.html.haml index 0fae3385..cddf0c1c 100644 --- a/app/views/admin/users/new.html.haml +++ b/app/views/admin/users/new.html.haml @@ -12,5 +12,9 @@ = f.fields_for :people do |p| = p.input :first_name = p.input :last_name + = p.label :Nickname + = p.text_field :irc_nickname + = p.label :Affiliation + = p.text_field :company, :placeholder => "Company/User Group/nothing" = f.input :conferences, :as => :check_boxes, :label => true, :collection => @conferences = f.action :submit, :button_html => { :value => "Create", :class => "btn btn-primary"} From 949cbd6a6cbbc316fa5c0609cab833dc78a76576 Mon Sep 17 00:00:00 2001 From: differentreality Date: Fri, 12 Jul 2013 09:21:38 +0300 Subject: [PATCH 3/9] error messages --- app/controllers/admin/users_controller.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index ac804a73..0e2c1eeb 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -42,15 +42,20 @@ class Admin::UsersController < ApplicationController user.skip_confirmation! person = Person.where("user_id = ?", user.id).first person.update_attributes(params[:user][:people]) - redirect_to admin_conference_registrations_path(@conference.short_title) - flash[:notice] = "Successfully created new registration for #{person.email}." - rescue Exception => e - redirect_to(:back, :alert => e.message) + begin + params[:user][:conferences].each do |r| + registration = person.registrations.new(:conference_id => r) + registration.save! + end + redirect_to admin_conference_registrations_path(@conference.short_title) + flash[:notice] = "Successfully created new registration for #{person.email}." + rescue Exception => e + redirect_to(:back, :alert => "Did not create registration. #{e.message}") + return + end + rescue Exception => e + redirect_to(:back, :alert => "Did not create new user/person. #{e.message}") return - end - params[:user][:conferences].each do |r| - registration = person.registrations.new(:conference_id => r) - registration.save! end else redirect_to(:back, :alert => "Please select at least one conference to register.") From 5437cd522621a9974341776b99b3c9c29de892bb Mon Sep 17 00:00:00 2001 From: differentreality Date: Fri, 12 Jul 2013 10:24:51 +0300 Subject: [PATCH 4/9] attended field as true in new registrations created by admin --- app/controllers/admin/users_controller.rb | 4 ++-- app/models/registration.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 0e2c1eeb..124bc5eb 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -44,7 +44,7 @@ class Admin::UsersController < ApplicationController person.update_attributes(params[:user][:people]) begin params[:user][:conferences].each do |r| - registration = person.registrations.new(:conference_id => r) + registration = person.registrations.new(:conference_id => r, :attended => 't') registration.save! end redirect_to admin_conference_registrations_path(@conference.short_title) @@ -61,4 +61,4 @@ class Admin::UsersController < ApplicationController redirect_to(:back, :alert => "Please select at least one conference to register.") end end -end +end \ No newline at end of file diff --git a/app/models/registration.rb b/app/models/registration.rb index ca0c5f67..adfa244b 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -10,9 +10,9 @@ class Registration < ActiveRecord::Base 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, :social_event_ids, :other_special_needs, - :event_ids + :event_ids, :attended accepts_nested_attributes_for :person accepts_nested_attributes_for :supporter_registration accepts_nested_attributes_for :social_events -end \ No newline at end of file +end From 3ec39444060e57ed7bded018cced0e20fc06a0be Mon Sep 17 00:00:00 2001 From: differentreality Date: Fri, 12 Jul 2013 10:28:08 +0300 Subject: [PATCH 5/9] create migration for adding field 'attended' in registrations table --- db/migrate/20130712072609_add_attended_to_registrations.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/migrate/20130712072609_add_attended_to_registrations.rb diff --git a/db/migrate/20130712072609_add_attended_to_registrations.rb b/db/migrate/20130712072609_add_attended_to_registrations.rb new file mode 100644 index 00000000..c7420f04 --- /dev/null +++ b/db/migrate/20130712072609_add_attended_to_registrations.rb @@ -0,0 +1,5 @@ +class AddAttendedToRegistrations < ActiveRecord::Migration + def change + add_column :registrations, :attended, :boolean, :default => 0 + end +end From f53af55a741830718967a2928d0d36b5b557baa6 Mon Sep 17 00:00:00 2001 From: differentreality Date: Fri, 12 Jul 2013 10:45:40 +0300 Subject: [PATCH 6/9] add pagination, re-arrange view --- .../admin/registrations_controller.rb | 18 +++++- app/models/registration.rb | 7 ++- app/views/admin/registrations/show.html.haml | 60 +++++++++---------- config/routes.rb | 1 + 4 files changed, 53 insertions(+), 33 deletions(-) diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index cfd795c5..a0768411 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -5,11 +5,27 @@ class Admin::RegistrationsController < ApplicationController session[:return_to] ||= request.referer @pdf_filename = "#{@conference.title}.pdf" @registrations = @conference.registrations.all(:joins => :person, - :order => "people.last_name ASC", + :order => "registrations.created_at ASC", :select => "registrations.*, people.last_name AS last_name, people.first_name AS first_name, people.public_name AS public_name, people.email AS email") + + @attended = @conference.registrations.where("attended = ?", true) + @headers = %w[attended name email social_events attending_with_partner need_access other_needs arrival departure] + end + + def change_field + @registration = Registration.find(params[:id]) + field = params[:view_field] + if @registration.send(field.to_sym) + @registration.update_attribute(:"#{field}",0) + else + @registration.update_attribute(:"#{field}",1) + end + + redirect_to admin_conference_registrations_path(@conference.short_title, @registration) + flash[:notice] = "Updated '#{params[:view_field]}' for #{(Person.where("id = ?", @registration.person_id).first).email}" end end \ No newline at end of file diff --git a/app/models/registration.rb b/app/models/registration.rb index adfa244b..3c65d6c8 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -15,4 +15,9 @@ class Registration < ActiveRecord::Base accepts_nested_attributes_for :person accepts_nested_attributes_for :supporter_registration accepts_nested_attributes_for :social_events -end + + alias_attribute :with_partner, :attending_with_partner + alias_attribute :social_events, :attending_social_events + alias_attribute :need_access, :handicapped_access_required + alias_attribute :other_needs, :other_special_needs +end \ No newline at end of file diff --git a/app/views/admin/registrations/show.html.haml b/app/views/admin/registrations/show.html.haml index 9e88fe84..cb2535bc 100644 --- a/app/views/admin/registrations/show.html.haml +++ b/app/views/admin/registrations/show.html.haml @@ -9,45 +9,43 @@ Registrations - if @registrations = "(#{@registrations.length})" - %table.table.table-striped.table-bordered.table-hover + - if @attended + = " - Attended (#{@attended.length})" + %table.table.table-striped.table-bordered.table-hover#registrations %thead %th - %b Last Name - %th - %b First Name - %th - %b Public Name - %th - %b Email - %th - %b Attending Social Events - %th - %b Attending With Partner - %th - %b Arrival Date - %th - %b Departure Date + No + - @headers.each do |h| + - h = h.gsub("_", " ") + %th + = h.capitalize %th %th + - counter = 0 - @registrations.each do |registration| %tr %td - = registration.last_name - %td - = registration.first_name - %td - = registration.public_name - %td - = registration.email - %td - = registration.attending_social_events - %td - = registration.attending_with_partner - %td - = registration.arrival - %td - = registration.departure + = counter +=1 + - @headers.each do |field| + %td + - if field == "name" + #{registration.last_name} #{registration.first_name} (#{registration.public_name}) + + -elsif (registration.send(field.to_sym).class == TrueClass || registration.send(field.to_sym).class == FalseClass) + = link_to "#{registration.send(field.to_sym)}", admin_conference_registrations_change_field_path(@conference.short_title, :id => registration.id, :view_field => "#{field}"), :method => :put, ":#{field}" => registration.send(field.to_sym) + - elsif field == 'arrival' || field == 'departure' + = registration.send(field.to_sym).strftime("%d %b %H:%M") if registration.send(field.to_sym) + - else + = registration.send(field.to_sym) %td = link_to "Edit", "#", :class => "btn btn-primary" %td = link_to "Delete", "#", :class => "btn btn-danger", :confirm => "Really delete registration for #{registration.public_name}?" + +:javascript + $(document).ready(function() { + $('#registrations').dataTable( { + "bPaginate": false, + "bLengthChange": false + } ); + } ); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f21d1781..3713964d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,7 @@ Osem::Application.routes.draw do get "/schedule" => "schedule#show" put "/schedule" => "schedule#update" get "/registrations" => "registrations#show" + put "/registrations/change_field" => "registrations#change_field" get "/emailsettings" => "emails#show", :as => "email_settings" put "/emailsettings" => "emails#update", :as => "email_settings" get "/supporter_levels" => "SupporterLevels#show" From 6879ca28e52c7bb2dcc237c312466b33f4da6744 Mon Sep 17 00:00:00 2001 From: differentreality Date: Fri, 12 Jul 2013 10:54:59 +0300 Subject: [PATCH 7/9] add option to delete registration --- app/controllers/admin/registrations_controller.rb | 14 ++++++++++++++ app/views/admin/registrations/show.html.haml | 2 +- config/routes.rb | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index a0768411..f5d48f4b 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -28,4 +28,18 @@ class Admin::RegistrationsController < ApplicationController redirect_to admin_conference_registrations_path(@conference.short_title, @registration) flash[:notice] = "Updated '#{params[:view_field]}' for #{(Person.where("id = ?", @registration.person_id).first).email}" end + + def delete + registration = @conference.registrations.where(:id => params[:id]).first + person = Person.where("id = ?", registration.person_id).first + + begin registration.destroy + redirect_to admin_conference_registrations_path + flash[:notice] = "Deleted registration for #{person.public_name} #{person.email}" + rescue Exception => e + Rails.logger.debug e.backtrace.join("\n") + redirect_to(admin_conference_registrations_path(@conference.short_title), :alert => 'Failed to delete registration:' + e.message) + return + end + end end \ No newline at end of file diff --git a/app/views/admin/registrations/show.html.haml b/app/views/admin/registrations/show.html.haml index cb2535bc..136a286d 100644 --- a/app/views/admin/registrations/show.html.haml +++ b/app/views/admin/registrations/show.html.haml @@ -40,7 +40,7 @@ %td = link_to "Edit", "#", :class => "btn btn-primary" %td - = link_to "Delete", "#", :class => "btn btn-danger", :confirm => "Really delete registration for #{registration.public_name}?" + = link_to "Delete", admin_conference_registrations_path(@conference.short_title, :id => registration.id), :method => :delete, :class => "btn btn-danger", :confirm => "Really delete registration for #{registration.public_name} #{registration.email}?" :javascript $(document).ready(function() { diff --git a/config/routes.rb b/config/routes.rb index 3713964d..38074bfa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,6 +11,7 @@ Osem::Application.routes.draw do put "/schedule" => "schedule#update" get "/registrations" => "registrations#show" put "/registrations/change_field" => "registrations#change_field" + delete "/registrations" => "registrations#delete" get "/emailsettings" => "emails#show", :as => "email_settings" put "/emailsettings" => "emails#update", :as => "email_settings" get "/supporter_levels" => "SupporterLevels#show" From 463430b3e8fac2131ad96d163c47fff71d045488 Mon Sep 17 00:00:00 2001 From: differentreality Date: Fri, 12 Jul 2013 11:06:16 +0300 Subject: [PATCH 8/9] Allow delete of registration only to admins (not organizers) --- .../admin/registrations_controller.rb | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index f5d48f4b..b948e960 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -30,16 +30,20 @@ class Admin::RegistrationsController < ApplicationController end def delete - registration = @conference.registrations.where(:id => params[:id]).first - person = Person.where("id = ?", registration.person_id).first + if has_role?(current_user, "Admin") + registration = @conference.registrations.where(:id => params[:id]).first + person = Person.where("id = ?", registration.person_id).first - begin registration.destroy - redirect_to admin_conference_registrations_path - flash[:notice] = "Deleted registration for #{person.public_name} #{person.email}" - rescue Exception => e - Rails.logger.debug e.backtrace.join("\n") - redirect_to(admin_conference_registrations_path(@conference.short_title), :alert => 'Failed to delete registration:' + e.message) - return + begin registration.destroy + redirect_to admin_conference_registrations_path + flash[:notice] = "Deleted registration for #{person.public_name} #{person.email}" + rescue Exception => e + Rails.logger.debug e.backtrace.join("\n") + redirect_to(admin_conference_registrations_path(@conference.short_title), :alert => 'Failed to delete registration:' + e.message) + return + end + else + redirect_to(admin_conference_registrations_path(@conference.short_title), :alert => 'You must be an admin to delete a registration.') end end end \ No newline at end of file From 19b11a79ff9820d2f1e1b869efe35addb5e21428 Mon Sep 17 00:00:00 2001 From: differentreality Date: Fri, 12 Jul 2013 11:43:31 +0300 Subject: [PATCH 9/9] Edit registration for admin --- .../admin/registrations_controller.rb | 24 ++++++++ app/views/admin/registrations/edit.html.haml | 25 ++++++++ app/views/admin/registrations/show.html.haml | 3 +- .../shared/_conference_registration.html.haml | 59 +++++++++++++++++++ config/routes.rb | 4 +- 5 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 app/views/admin/registrations/edit.html.haml create mode 100644 app/views/shared/_conference_registration.html.haml diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index b948e960..3a5fd03c 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -29,6 +29,30 @@ class Admin::RegistrationsController < ApplicationController flash[:notice] = "Updated '#{params[:view_field]}' for #{(Person.where("id = ?", @registration.person_id).first).email}" end + def edit + @registration = @conference.registrations.where("id = ?", params[:id]).first + @person = Person.where("id = ?", @registration.person_id).first + end + + def update + reg_id = params[:format] + @registration = @conference.registrations.where("id = ?", reg_id).first + @person = Person.where("id = ?", @registration.person_id).first + begin + @person.update_attributes!(params[:registration][:person_attributes]) + params[:registration].delete :person_attributes + @registration.supporter_registration = @conference.supporter_registrations.new(params[:registration][:supporter_registration_attributes]) + params[:registration].delete :supporter_registration_attributes + @registration.update_attributes!(params[:registration]) + flash[:notice] = "Successfully updated Registration for #{@person.public_name} #{@person.email}" + redirect_to(admin_conference_registrations_path(@conference.short_title)) + rescue Exception => e + Rails.logger.debug e.backtrace.join("\n") + redirect_to(admin_conference_registrations_path(@conference.short_title), :alert => 'Failed to update registration:' + e.message) + return + end + end + def delete if has_role?(current_user, "Admin") registration = @conference.registrations.where(:id => params[:id]).first diff --git a/app/views/admin/registrations/edit.html.haml b/app/views/admin/registrations/edit.html.haml new file mode 100644 index 00000000..bc06d775 --- /dev/null +++ b/app/views/admin/registrations/edit.html.haml @@ -0,0 +1,25 @@ +.container-fluid + .row-fluid + .span12 + %h3 + Edit registration of #{@person.public_name} for #{@conference.title} + %br + .row-fluid + .span12 + = semantic_form_for(@registration, :url => admin_conference_registrations_edit_path(@conference.short_title, @registration.id), :html => { :method => :put }) do |f| + .span6 + = f.inputs :name => "Personal Data" do + = f.fields_for :person do |p| + = p.label :first_name + = p.text_field :first_name + = p.label :last_name + = p.text_field :last_name + = p.label :email + = p.text_field :email + = p.label :affiliation + = p.text_field :company + = p.label :Nickname + = p.text_field :irc_nickname + = render :partial => 'shared/conference_registration', :locals => { :f => f } + + = f.action :submit, :button_html => { :value => "Edit Registration", :class => "btn btn-primary" } diff --git a/app/views/admin/registrations/show.html.haml b/app/views/admin/registrations/show.html.haml index 136a286d..7a395458 100644 --- a/app/views/admin/registrations/show.html.haml +++ b/app/views/admin/registrations/show.html.haml @@ -38,7 +38,8 @@ - else = registration.send(field.to_sym) %td - = link_to "Edit", "#", :class => "btn btn-primary" + = link_to "Edit", admin_conference_registrations_edit_path(@conference.short_title, :id => registration.id), :method => :get, :class => "btn btn-primary" + %td = link_to "Delete", admin_conference_registrations_path(@conference.short_title, :id => registration.id), :method => :delete, :class => "btn btn-danger", :confirm => "Really delete registration for #{registration.public_name} #{registration.email}?" diff --git a/app/views/shared/_conference_registration.html.haml b/app/views/shared/_conference_registration.html.haml new file mode 100644 index 00000000..424a9def --- /dev/null +++ b/app/views/shared/_conference_registration.html.haml @@ -0,0 +1,59 @@ += f.inputs :name => "Your Details" do + %br + Your public name (required) + %br + = f.fields_for :person do |p| + = p.text_field :public_name, :for => :person + - if @conference.use_supporter_levels? + = f.semantic_fields_for :supporter_registration do |reg| + = reg.input :supporter_level, :as => :select, :collection => @conference.supporter_levels + = reg.input :code, :label => "Confirmation or registration code (if applicable)" + %span#supporter-link.help-block + + = f.input :attending_with_partner, :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, :class => "span6"} += f.inputs "Travel Info" do + = 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.departure.nil?), :id => "registration-departure-datepicker", :readonly => "readonly" } +- if @conference.social_events.count > 0 + = f.inputs "Are you planning to attend any of the parties?" do + %br Yes, I'll be attending... + %br + = f.input :social_events, :as => :check_boxes, :label => false, :collection => @conference.social_events +- if @conference.use_dietary_choices? + = f.inputs "Food" do + = f.input :dietary_choice, :collection => [["None", nil]] + @conference.dietary_choices.map {|x| [x.title, x.id]}, + :include_blank => false, :label => "Special Dietary Restriction" + = f.input :other_dietary_choice, :input_html => {:rows => "2", :class => "span6"}, :label => "Other Dietary Restictions (please describe)" + +:javascript + $("#registration_supporter_registration_attributes_supporter_level_id").change(function () { + var str = ""; + #{generate_supporter_level_js @conference} + $("#supporter-link").html(str); + }) + .trigger('change'); + + $("#registration-arrival-datepicker").datetimepicker({ + dateFormat: "yy-mm-dd", + timeFormat: "HH:mm", + showSecond: false, + numberOfMonths: 1, + defaultDate: '#{@conference.start_date.yesterday.strftime('%Y-%m-%d')}', + onSelect: function(selected) { + $("#registration-departure-datepicker").datepicker("option","minDate", selected) + } + }); + + $("#registration-departure-datepicker").datetimepicker({ + dateFormat: "yy-mm-dd", + timeFormat: "HH:mm", + showSecond: false, + numberOfMonths: 1, + defaultDate: '#{@conference.end_date.tomorrow.strftime('%Y-%m-%d')}', + onSelect: function(selected) { + $("#registration-arrival-datepicker").datepicker("option","maxDate", selected) + } + }); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 38074bfa..2ad20c78 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,8 +10,10 @@ Osem::Application.routes.draw do get "/schedule" => "schedule#show" put "/schedule" => "schedule#update" get "/registrations" => "registrations#show" - put "/registrations/change_field" => "registrations#change_field" + get "/registrations/edit" => "registrations#edit" + put "/registrations/edit" => "registrations#update" delete "/registrations" => "registrations#delete" + put "/registrations/change_field" => "registrations#change_field" get "/emailsettings" => "emails#show", :as => "email_settings" put "/emailsettings" => "emails#update", :as => "email_settings" get "/supporter_levels" => "SupporterLevels#show"