Merge pull request #241 from gopesht/adds_lodgings_splash_view

Adds lodgings splash view
This commit is contained in:
Gopesh Tulsyan 2014-06-16 23:23:12 +05:30
commit ccf2d2361b
15 changed files with 70 additions and 12 deletions

View file

@ -16,7 +16,7 @@ module Admin
notice: 'Lodgings were successfully updated.')
else
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
notice: 'Lodgings Updation Failed!')
notice: 'Updating lodgings failed!')
end
end
end

View file

@ -15,7 +15,8 @@ class Conference < ActiveRecord::Base
:registration_description, :ticket_description,
:sponsorship_levels_attributes,
:sponsors_attributes, :facebook_url,
:google_url, :twitter_url, :sponsor_description, :sponsor_email
:google_url, :twitter_url, :sponsor_description, :sponsor_email,
:lodging_description
has_paper_trail

View file

@ -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>' }

View file

@ -18,6 +18,7 @@
= f.input :ticket_description, hint: 'This will appear in the Tickets segment of the splash'
= f.input :sponsor_description, hint: 'This will appear in the sponsor segment of the splash'
= f.input :sponsor_email, hint: 'This will appear in the sponsor segment of the splash for the sponsors to contact to the organizers'
= f.input :lodging_description, hint: 'This will appear in the lodging segment of the splash'
= f.inputs :name => "Media" do
- if !@conference.logo.blank?

View file

@ -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 %>
</div>

View file

@ -25,11 +25,12 @@
= link_to 'Visit Venue Website', @conference.venue.website, target: '_blank'
:javascript
$(document).ready(function(){
var photo = "#{@conference.venue.photo}";
if(photo)
{
$('#location').css('background-image', 'url('+photo+')');
}
});
- unless @conference.venue.photo.blank?
:javascript
$(document).ready(function(){
var photo = "#{@conference.venue.photo}";
if(photo)
{
$('#location').css('background-image', 'url('+photo+')');
}
});

View file

@ -0,0 +1,18 @@
%div.row.col-md-12.text-center
%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.text-center #{ r.name }
-unless r.description.blank?
%p.text-left #{ r.description }
- unless r.website_link.blank?
.text-center
= link_to 'Go to Website', r.website_link

View file

@ -13,6 +13,9 @@
-unless @conference.venue.blank?
%div#location
= render 'location'
- if @conference.venue
- unless @conference.venue.lodgings.empty?
= render 'lodging'
%div#sponsors
= render 'sponsor'
%div#social-media

View file

@ -0,0 +1,5 @@
class AddLodgingDescriptionToConference < ActiveRecord::Migration
def change
add_column :conferences, :lodging_description, :text
end
end

View file

@ -0,0 +1,5 @@
class AddWebsiteLinkToLodging < ActiveRecord::Migration
def change
add_column :lodgings, :website_link, :string
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140613083115) do
ActiveRecord::Schema.define(version: 20140614174354) do
create_table "answers", force: true do |t|
t.string "title"
@ -86,6 +86,7 @@ ActiveRecord::Schema.define(version: 20140613083115) do
t.string "google_url"
t.text "sponsor_description"
t.string "sponsor_email"
t.text "lodging_description"
end
create_table "conferences_questions", id: false, force: true do |t|
@ -202,6 +203,7 @@ ActiveRecord::Schema.define(version: 20140613083115) 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|

View file

@ -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

View file

@ -24,18 +24,29 @@ feature Lodging do
page.
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
expect(flash).to eq('Lodgings were successfully updated.')
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
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(page).to have_selector("img[src*='rails.png']")
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input').
value).to eq('http://www.example.com')
# Remove room
click_link 'Remove lodging'
expect(page.all('div.nested-fields').count == 0).to be true

View file

@ -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

View file

@ -17,6 +17,7 @@ describe 'conference/show.html.haml' do
@sponsorship_level.sponsors << create(:sponsor, sponsorship_level: @sponsorship_level,
conference: @conference)
@conference.venue = create(:venue)
@conference.venue.lodgings << create(:lodging, venue: @conference.venue)
assign :conference, @conference
render
end
@ -60,4 +61,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