diff --git a/app/models/conference.rb b/app/models/conference.rb index b49a901e..1d5caf63 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -10,7 +10,8 @@ class Conference < ActiveRecord::Base :difficulty_levels_attributes, :use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes, :vpositions_attributes, :use_volunteers, :media_id, :media_type, :color, :description, - :registration_description, :ticket_description + :registration_description, :ticket_description, + :lodging_description has_paper_trail diff --git a/app/models/lodging.rb b/app/models/lodging.rb index b7eddb9f..296ff0b1 100644 --- a/app/models/lodging.rb +++ b/app/models/lodging.rb @@ -1,5 +1,5 @@ class Lodging < ActiveRecord::Base - attr_accessible :name, :description, :photo + attr_accessible :name, :description, :photo, :website_link belongs_to :venue has_attached_file :photo, styles: { thumb: '100x100>', large: '300x300>' } diff --git a/app/views/admin/conference/edit.html.haml b/app/views/admin/conference/edit.html.haml index d920ba1f..bb060d4c 100644 --- a/app/views/admin/conference/edit.html.haml +++ b/app/views/admin/conference/edit.html.haml @@ -16,7 +16,7 @@ = 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.input :lodging_description, hint: 'This will appear in the lodging segement of the splash' = f.inputs :name => "Media" do - if !@conference.logo.blank? = image_tag @conference.logo(:thumb) diff --git a/app/views/admin/lodgings/_lodging_fields.html.erb b/app/views/admin/lodgings/_lodging_fields.html.erb index 7f9866d5..83c27724 100644 --- a/app/views/admin/lodgings/_lodging_fields.html.erb +++ b/app/views/admin/lodgings/_lodging_fields.html.erb @@ -5,6 +5,7 @@ of what they are offering, about types of rooms, prices and address' %> <%= image_tag f.object.photo(:thumb) if !f.object.photo.blank? %> <%= f.input :photo %> + <%= f.input :website_link %> <%= remove_association_link :lodging, f %> <% end %> diff --git a/app/views/conference/_location.html.haml b/app/views/conference/_location.html.haml index 754b1253..ce3887d9 100644 --- a/app/views/conference/_location.html.haml +++ b/app/views/conference/_location.html.haml @@ -24,6 +24,9 @@ %li %b = link_to 'Visit Venue Website', @conference.venue.website, target: '_blank' + - if @conference.venue + - unless @conference.venue.lodgings.empty? + = render 'lodging' :javascript diff --git a/app/views/conference/_lodging.html.haml b/app/views/conference/_lodging.html.haml new file mode 100644 index 00000000..9a469536 --- /dev/null +++ b/app/views/conference/_lodging.html.haml @@ -0,0 +1,17 @@ +%div.row.col-md-12 + %h2 Lodgings + -unless @conference.lodging_description.blank? + %p.lead + = @conference.lodging_description + +%div.row + - @conference.venue.lodgings.each do |r| + %div.col-md-3.thumbnail + -unless r.photo.blank? + = image_tag r.photo(:large), class: 'img-responsive' + -unless r.name.blank? + %h4 #{ r.name } + -unless r.description.blank? + %p.text-left #{ r.description } + - unless r.website_link.blank? + = link_to 'Go to Website', r.website_link diff --git a/db/migrate/20140606172312_add_website_link_to_lodging.rb b/db/migrate/20140606172312_add_website_link_to_lodging.rb new file mode 100644 index 00000000..63c37bb3 --- /dev/null +++ b/db/migrate/20140606172312_add_website_link_to_lodging.rb @@ -0,0 +1,5 @@ +class AddWebsiteLinkToLodging < ActiveRecord::Migration + def change + add_column :lodgings, :website_link, :string + end +end diff --git a/db/migrate/20140606173417_add_lodging_description_to_conference.rb b/db/migrate/20140606173417_add_lodging_description_to_conference.rb new file mode 100644 index 00000000..37dd2c30 --- /dev/null +++ b/db/migrate/20140606173417_add_lodging_description_to_conference.rb @@ -0,0 +1,5 @@ +class AddLodgingDescriptionToConference < ActiveRecord::Migration + def change + add_column :conferences, :lodging_description, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 3fdbdada..ea95546a 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: 20140605125153) do +ActiveRecord::Schema.define(version: 20140606173417) do create_table "answers", force: true do |t| t.string "title" @@ -84,6 +84,7 @@ ActiveRecord::Schema.define(version: 20140605125153) do t.string "facebook_url" t.string "google_url" t.string "twitter_url" + t.text "lodging_description" end create_table "conferences_questions", id: false, force: true do |t| @@ -199,6 +200,7 @@ ActiveRecord::Schema.define(version: 20140605125153) do t.integer "venue_id" t.datetime "created_at" t.datetime "updated_at" + t.string "website_link" end create_table "people", force: true do |t| diff --git a/spec/factories/lodgings.rb b/spec/factories/lodgings.rb index d5481b83..efa16bb2 100644 --- a/spec/factories/lodgings.rb +++ b/spec/factories/lodgings.rb @@ -4,6 +4,7 @@ FactoryGirl.define do factory :lodging do name 'Example Hotel' description 'Lorem Ipsum Dolor' + website_link 'http://www.example.com' venue end end diff --git a/spec/features/lodgings_spec.rb b/spec/features/lodgings_spec.rb index 5bb305a5..7b5d3814 100644 --- a/spec/features/lodgings_spec.rb +++ b/spec/features/lodgings_spec.rb @@ -25,7 +25,9 @@ feature Lodging do find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea'). set('Lorem Ipsum Dolor') attach_file 'Photo', path - + page. + find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input'). + set('http://www.example.com') click_button 'Update Venue' # Validations @@ -34,6 +36,8 @@ feature Lodging do value).to eq('Example Hotel') expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea'). value).to eq('Lorem Ipsum Dolor') + expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input'). + value).to eq('http://www.example.com') expect(page).to have_selector("img[src*='rails.png']") # Remove room diff --git a/spec/views/lodgings/index.html.haml_spec.rb b/spec/views/admin/lodgings/index.html.haml_spec.rb similarity index 87% rename from spec/views/lodgings/index.html.haml_spec.rb rename to spec/views/admin/lodgings/index.html.haml_spec.rb index 982942bb..7bc6925a 100644 --- a/spec/views/lodgings/index.html.haml_spec.rb +++ b/spec/views/admin/lodgings/index.html.haml_spec.rb @@ -9,5 +9,6 @@ describe 'admin/lodgings/index' do render expect(rendered).to include('Example Hotel') expect(rendered).to include('Lorem Ipsum Dolor') + expect(rendered).to include('http://www.example.com') end end diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index bd98f9e2..e0a3ec2f 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -6,6 +6,7 @@ describe 'conference/show.html.haml' do registration_end_date: Date.tomorrow, description: 'Lorem Ipsum') @conference.venue = create(:venue) + @conference.venue.lodgings << create(:lodging, venue: @conference.venue) @conference.call_for_papers = create(:call_for_papers, conference: @conference) assign :conference, @conference render @@ -33,4 +34,11 @@ describe 'conference/show.html.haml' do expect(rendered).to include('www.opensuse.org') expect(rendered).to include('Lorem Ipsum Dolor') end + + it 'renders lodging partial' do + expect(view).to render_template(partial: 'conference/_lodging') + expect(rendered).to include('Example Hotel') + expect(rendered).to include('Lorem Ipsum Dolor') + expect(rendered).to include('http://www.example.com') + end end