From abfb0884a11900042c22ffa6340c58f5ee38299f Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Wed, 28 May 2014 18:12:45 +0530 Subject: [PATCH 1/4] Added registration segment to display description, period Controller test for Conference#show houndci fixes Rebased with single entry for navigation branding Conditional rendering of splash navbar --- app/models/conference.rb | 4 ++-- app/views/admin/conference/edit.html.haml | 1 + app/views/conference/_registration.html.haml | 12 ++++++++++++ app/views/conference/show.html.haml | 3 +++ ...842_add_registration_description_to_conference.rb | 5 +++++ spec/views/conference/show.html.haml_spec.rb | 11 +++++++++++ 6 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 app/views/conference/_registration.html.haml create mode 100644 db/migrate/20140528115842_add_registration_description_to_conference.rb diff --git a/app/models/conference.rb b/app/models/conference.rb index fb3e14ae..bc67ffc8 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -9,7 +9,7 @@ class Conference < ActiveRecord::Base :questions_attributes, :question_ids, :answers_attributes, :answer_ids, :difficulty_levels_attributes, :use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes, :vpositions_attributes, :use_volunteers, - :media_id, :media_type, :color, :description + :media_id, :media_type, :color, :description, :registration_description has_paper_trail @@ -74,7 +74,7 @@ class Conference < ActiveRecord::Base # Checks if the user is registered to the conference # # ====Args - # * +user+ -> The user we check for + # * +user+ -> The user we check for # ====Returns # * +nil+ -> If the user doesn't exist # * +false+ -> If the user is registered diff --git a/app/views/admin/conference/edit.html.haml b/app/views/admin/conference/edit.html.haml index 8ad5d0a3..300eefce 100644 --- a/app/views/admin/conference/edit.html.haml +++ b/app/views/admin/conference/edit.html.haml @@ -14,6 +14,7 @@ = f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" } = f.input :registration_start_date, :as => :string, :input_html => { :id => "conference-reg-start-datepicker", :readonly => "readonly" } = f.input :registration_end_date, :as => :string, :input_html => { :id => "conference-reg-end-datepicker", :readonly => "readonly" } + = f.input :registration_description, hint: 'This description will appear in registration segment of the splash' = f.inputs :name => "Media" do - if !@conference.logo.blank? diff --git a/app/views/conference/_registration.html.haml b/app/views/conference/_registration.html.haml new file mode 100644 index 00000000..5a0ba8e3 --- /dev/null +++ b/app/views/conference/_registration.html.haml @@ -0,0 +1,12 @@ += content_for :splash_nav do + %li + %a{ href: '#registration' } Registration +%div.container.text-center + %div.row + %h2 Registration + - if !@conference.registration_description.blank? + %p + = @conference.registration_description + %h4 Registration period #{ date_string(@conference.registration_start_date, @conference.registration_end_date) } + - if @conference.registration_open? + = link_to "Register for #{@conference.short_title}", register_conference_path(@conference.short_title), :class =>"btn btn-success btn-lg", target: '_blank' diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index 319cb460..7489d2a9 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -2,3 +2,6 @@ = link_to @conference.title, conference_url(@conference.short_title), class: 'navbar-brand' %div#program = render 'program' +%div#registration + = render 'registration' + diff --git a/db/migrate/20140528115842_add_registration_description_to_conference.rb b/db/migrate/20140528115842_add_registration_description_to_conference.rb new file mode 100644 index 00000000..b893de72 --- /dev/null +++ b/db/migrate/20140528115842_add_registration_description_to_conference.rb @@ -0,0 +1,5 @@ +class AddRegistrationDescriptionToConference < ActiveRecord::Migration + def change + add_column :conferences, :registration_description, :text + end +end diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index d72a3070..7af548ce 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -7,4 +7,15 @@ describe 'conference/show.html.haml' do expect(render).to include("#{@conference.description}") expect(view).to render_template(partial: 'conference/_program') end + + it 'renders registration partial' do + @conference = create(:conference, registration_description: 'Lorem Ipsum Dolor', + registration_start_date: Date.today, + registration_end_date: Date.tomorrow) + assign :conference, @conference + render + expect(rendered).to include("#{@conference.registration_description}") + expect(rendered).to include("Register for #{@conference.short_title}") + expect(view).to render_template(partial: 'conference/_registration') + end end From e2fd1bbd69a04e3e851064ca7f612605b61343a5 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Thu, 29 May 2014 20:23:33 +0530 Subject: [PATCH 2/4] Add tickets to registration segment --- app/models/conference.rb | 3 ++- app/models/supporter_level.rb | 2 +- app/views/admin/conference/edit.html.haml | 1 + .../_supporter_level_fields.html.erb | 3 +++ app/views/conference/_registration.html.haml | 2 ++ app/views/conference/_tickets.html.haml | 15 +++++++++++++++ app/views/layouts/_admin_sidebar.html.haml | 3 +++ ...133052_add_ticket_description_to_conference.rb | 5 +++++ ...29133228_add_description_to_supporter_level.rb | 5 +++++ ...9133339_add_ticket_price_to_supporter_level.rb | 5 +++++ 10 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 app/views/conference/_tickets.html.haml create mode 100644 db/migrate/20140529133052_add_ticket_description_to_conference.rb create mode 100644 db/migrate/20140529133228_add_description_to_supporter_level.rb create mode 100644 db/migrate/20140529133339_add_ticket_price_to_supporter_level.rb diff --git a/app/models/conference.rb b/app/models/conference.rb index bc67ffc8..edddb909 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -9,7 +9,8 @@ class Conference < ActiveRecord::Base :questions_attributes, :question_ids, :answers_attributes, :answer_ids, :difficulty_levels_attributes, :use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes, :vpositions_attributes, :use_volunteers, - :media_id, :media_type, :color, :description, :registration_description + :media_id, :media_type, :color, :description, + :registration_description, :ticket_description has_paper_trail diff --git a/app/models/supporter_level.rb b/app/models/supporter_level.rb index e51c1be5..02c56f61 100644 --- a/app/models/supporter_level.rb +++ b/app/models/supporter_level.rb @@ -2,5 +2,5 @@ class SupporterLevel < ActiveRecord::Base belongs_to :conference has_many :supporter_registrations - attr_accessible :conference, :title, :url + attr_accessible :conference, :title, :url, :description, :ticket_price end diff --git a/app/views/admin/conference/edit.html.haml b/app/views/admin/conference/edit.html.haml index 300eefce..d920ba1f 100644 --- a/app/views/admin/conference/edit.html.haml +++ b/app/views/admin/conference/edit.html.haml @@ -15,6 +15,7 @@ = f.input :registration_start_date, :as => :string, :input_html => { :id => "conference-reg-start-datepicker", :readonly => "readonly" } = f.input :registration_end_date, :as => :string, :input_html => { :id => "conference-reg-end-datepicker", :readonly => "readonly" } = f.input :registration_description, hint: 'This description will appear in registration segment of the splash' + = f.input :ticket_description, hint: 'This will appear in the Tickets segment of the splash' = f.inputs :name => "Media" do - if !@conference.logo.blank? diff --git a/app/views/admin/supporter_levels/_supporter_level_fields.html.erb b/app/views/admin/supporter_levels/_supporter_level_fields.html.erb index ec793dc7..899efdac 100644 --- a/app/views/admin/supporter_levels/_supporter_level_fields.html.erb +++ b/app/views/admin/supporter_levels/_supporter_level_fields.html.erb @@ -2,6 +2,9 @@ <%= f.inputs do %> <%= f.input :title%> <%= f.input :url %> + <%= f.input :description %> + <%= f.input :ticket_price, hint: 'Please enter price with currency symbol. + For example, $200,₹300' %> <%= remove_association_link :supporter_level, f %> <% end %> diff --git a/app/views/conference/_registration.html.haml b/app/views/conference/_registration.html.haml index 5a0ba8e3..5f52422b 100644 --- a/app/views/conference/_registration.html.haml +++ b/app/views/conference/_registration.html.haml @@ -10,3 +10,5 @@ %h4 Registration period #{ date_string(@conference.registration_start_date, @conference.registration_end_date) } - if @conference.registration_open? = link_to "Register for #{@conference.short_title}", register_conference_path(@conference.short_title), :class =>"btn btn-success btn-lg", target: '_blank' + - if @conference.use_supporter_levels? + = render 'tickets' diff --git a/app/views/conference/_tickets.html.haml b/app/views/conference/_tickets.html.haml new file mode 100644 index 00000000..2fcfbf72 --- /dev/null +++ b/app/views/conference/_tickets.html.haml @@ -0,0 +1,15 @@ +%div.row + %h3 Tickets + -if !@conference.ticket_description.blank? + %p #{ @conference.ticket_description } + - @conference.supporter_levels.each do |s| + %div.col-md-6 + - if !s.title.blank? + %h4 #{ s.title } + -if !s.description.blank? + %p #{ s.description } + - if !s.url.blank? + %div.btn-group + = link_to "Buy Ticket", s.url, class: 'btn btn-success', target: '_blank' + - if !s.ticket_price.blank? + = button_tag "#{s.ticket_price}", class: 'btn btn-success' diff --git a/app/views/layouts/_admin_sidebar.html.haml b/app/views/layouts/_admin_sidebar.html.haml index 11cebd56..3f573ef7 100644 --- a/app/views/layouts/_admin_sidebar.html.haml +++ b/app/views/layouts/_admin_sidebar.html.haml @@ -45,6 +45,9 @@ %ul.nav.nav-stacked.nav-pills.small.collapse.subNav %li{:class=> active_nav_li(admin_conference_rooms_path(@conference.short_title))} = link_to 'Rooms', admin_conference_rooms_path(@conference.short_title) + %li{ class: active_nav_li(admin_conference_supporter_levels_path(@conference.short_title)) } + = link_to(admin_conference_supporter_levels_path(@conference.short_title)) do + Supporter Levels %li{:class=> active_nav_li(admin_conference_emails_path(@conference.short_title))} = link_to(admin_conference_emails_path(@conference.short_title)) do %span.glyphicon.glyphicon-envelope diff --git a/db/migrate/20140529133052_add_ticket_description_to_conference.rb b/db/migrate/20140529133052_add_ticket_description_to_conference.rb new file mode 100644 index 00000000..ccb610d9 --- /dev/null +++ b/db/migrate/20140529133052_add_ticket_description_to_conference.rb @@ -0,0 +1,5 @@ +class AddTicketDescriptionToConference < ActiveRecord::Migration + def change + add_column :conferences, :ticket_description, :text + end +end diff --git a/db/migrate/20140529133228_add_description_to_supporter_level.rb b/db/migrate/20140529133228_add_description_to_supporter_level.rb new file mode 100644 index 00000000..4473c851 --- /dev/null +++ b/db/migrate/20140529133228_add_description_to_supporter_level.rb @@ -0,0 +1,5 @@ +class AddDescriptionToSupporterLevel < ActiveRecord::Migration + def change + add_column :supporter_levels, :description, :text + end +end diff --git a/db/migrate/20140529133339_add_ticket_price_to_supporter_level.rb b/db/migrate/20140529133339_add_ticket_price_to_supporter_level.rb new file mode 100644 index 00000000..c7ac5002 --- /dev/null +++ b/db/migrate/20140529133339_add_ticket_price_to_supporter_level.rb @@ -0,0 +1,5 @@ +class AddTicketPriceToSupporterLevel < ActiveRecord::Migration + def change + add_column :supporter_levels, :ticket_price, :string + end +end From 2d87610a97e9bf504c82a067a961ba71bd695710 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 30 May 2014 00:54:45 +0530 Subject: [PATCH 3/4] Fixed view specs, passing --- spec/views/conference/show.html.haml_spec.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index 7af548ce..c1d5b43a 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -1,21 +1,20 @@ require 'spec_helper' describe 'conference/show.html.haml' do - it 'renders program partial' do - @conference = create(:conference, description: 'Lorem Ipsum') + before(:each) do + @conference = create(:conference, registration_description: 'Lorem Ipsum Dolor', + registration_start_date: Date.today, + registration_end_date: Date.tomorrow, + description: 'Lorem Ipsum') assign :conference, @conference render + end + it 'renders program partial' do expect(render).to include("#{@conference.description}") expect(view).to render_template(partial: 'conference/_program') end it 'renders registration partial' do - @conference = create(:conference, registration_description: 'Lorem Ipsum Dolor', - registration_start_date: Date.today, - registration_end_date: Date.tomorrow) - assign :conference, @conference - render expect(rendered).to include("#{@conference.registration_description}") - expect(rendered).to include("Register for #{@conference.short_title}") expect(view).to render_template(partial: 'conference/_registration') end end From 9de6678f95e51dc6b3ee252324ccb2bffb7da12d Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 30 May 2014 01:21:17 +0530 Subject: [PATCH 4/4] updated db/schema.rb --- db/schema.rb | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 56dd290d..2950e7e3 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: 20140528072939) do +ActiveRecord::Schema.define(version: 20140529133339) do create_table "answers", force: true do |t| t.string "title" @@ -51,15 +51,15 @@ ActiveRecord::Schema.define(version: 20140528072939) do add_index "comments", ["user_id"], name: "index_comments_on_user_id" create_table "conferences", force: true do |t| - t.string "guid", null: false - t.string "title", null: false - t.string "short_title", null: false + t.string "guid", null: false + t.string "title", null: false + t.string "short_title", null: false t.string "social_tag" - t.string "contact_email", null: false - t.string "timezone", null: false + t.string "contact_email", null: false + t.string "timezone", null: false t.string "html_export_path" - t.date "start_date", null: false - t.date "end_date", null: false + t.date "start_date", null: false + t.date "end_date", null: false t.integer "venue_id" t.datetime "created_at" t.datetime "updated_at" @@ -69,16 +69,19 @@ ActiveRecord::Schema.define(version: 20140528072939) do t.string "logo_content_type" t.integer "logo_file_size" t.datetime "logo_updated_at" - t.boolean "use_dietary_choices", default: false - t.boolean "use_supporter_levels", default: false + t.boolean "use_dietary_choices", default: false + t.boolean "use_supporter_levels", default: false t.integer "revision" - t.boolean "use_vpositions", default: false - t.boolean "use_vdays", default: false - t.boolean "use_difficulty_levels", default: false + t.boolean "use_vpositions", default: false + t.boolean "use_vdays", default: false + t.boolean "use_difficulty_levels", default: false t.boolean "use_volunteers" t.string "media_id" t.string "media_type" - t.string "color", default: "#000000" + t.string "color", default: "#000000" + t.text "description" + t.text "registration_description" + t.text "ticket_description" end create_table "conferences_questions", id: false, force: true do |t| @@ -290,6 +293,8 @@ ActiveRecord::Schema.define(version: 20140528072939) do t.integer "conference_id" t.string "title", null: false t.string "url" + t.text "description" + t.string "ticket_price" end create_table "supporter_registrations", force: true do |t|