Merge pull request #186 from gopesht/location_component
Location component
This commit is contained in:
commit
6e08d637be
11 changed files with 93 additions and 9 deletions
|
|
@ -91,3 +91,17 @@ body {
|
||||||
#submissions {
|
#submissions {
|
||||||
padding-bottom: 20px;
|
padding-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#location{
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center center;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 500px;
|
||||||
|
background-size: cover;
|
||||||
|
-webkit-background-size:cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
#location li{
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 2em;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,13 @@ class Admin::VenueController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@venue = @conference.venue
|
@venue = @conference.venue
|
||||||
venue_params = params[:venue]
|
if @venue.update_attributes!(params[:venue])
|
||||||
@venue.name = venue_params[:name]
|
redirect_to(admin_conference_venue_info_path(conference_id: @conference.short_title),
|
||||||
@venue.address= venue_params[:address]
|
notice: 'Venue was successfully updated.')
|
||||||
@venue.website = venue_params[:website]
|
else
|
||||||
@venue.description = venue_params[:description]
|
redirect_to(admin_conference_venue_info_path(conference_id: @conference.short_title),
|
||||||
@venue.save
|
notice: 'Venue Updation Failed!')
|
||||||
redirect_to(admin_conference_venue_info_path(:conference_id => @conference.short_title), :notice => 'Venue was successfully updated.')
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,13 @@
|
||||||
class Venue < ActiveRecord::Base
|
class Venue < ActiveRecord::Base
|
||||||
|
attr_accessible :name, :description, :website, :address, :photo
|
||||||
has_many :conferences
|
has_many :conferences
|
||||||
before_create :generate_guid
|
before_create :generate_guid
|
||||||
|
has_attached_file :photo,
|
||||||
|
styles: { thumb: '100x100>', large: '300x300>' }
|
||||||
|
|
||||||
|
validates_attachment_content_type :photo,
|
||||||
|
content_type: [/jpg/, /jpeg/, /png/, /gif/],
|
||||||
|
size: { in: 0..500.kilobytes }
|
||||||
private
|
private
|
||||||
|
|
||||||
def generate_guid
|
def generate_guid
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,7 @@
|
||||||
= f.input :address, :input_html => {:rows => 1}
|
= f.input :address, :input_html => {:rows => 1}
|
||||||
= f.input :website
|
= f.input :website
|
||||||
= f.input :description, :input_html => { :rows => 10, :cols => 20 }
|
= f.input :description, :input_html => { :rows => 10, :cols => 20 }
|
||||||
|
- unless @venue.photo.blank?
|
||||||
|
= image_tag @venue.photo(:thumb)
|
||||||
|
= f.input :photo
|
||||||
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
|
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
|
||||||
|
|
|
||||||
35
app/views/conference/_location.html.haml
Normal file
35
app/views/conference/_location.html.haml
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
= content_for :splash_nav do
|
||||||
|
%li
|
||||||
|
%a{ href: '#location' } Location
|
||||||
|
|
||||||
|
|
||||||
|
%div.container.text-center
|
||||||
|
.div.row.col-md-12
|
||||||
|
- unless @conference.venue.name.blank?
|
||||||
|
%h1
|
||||||
|
%strong #{ @conference.venue.name }
|
||||||
|
- unless @conference.venue.address.blank?
|
||||||
|
%h2
|
||||||
|
%strong #{ @conference.venue.address }
|
||||||
|
- unless @conference.venue.description.blank?
|
||||||
|
%p
|
||||||
|
%strong #{ @conference.venue.description }
|
||||||
|
%ul
|
||||||
|
- unless @conference.venue.address.blank?
|
||||||
|
%li
|
||||||
|
%b
|
||||||
|
= link_to 'View in Google Maps', "http://maps.google.com/maps?q=#{@conference.venue.address}", target: '_blank'
|
||||||
|
- unless @conference.venue.website.blank?
|
||||||
|
%li
|
||||||
|
%b
|
||||||
|
= 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+')');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -10,7 +10,10 @@
|
||||||
-unless @conference.call_for_papers.blank?
|
-unless @conference.call_for_papers.blank?
|
||||||
%div#callforpapers
|
%div#callforpapers
|
||||||
= render 'call_for_papers'
|
= render 'call_for_papers'
|
||||||
|
-unless @conference.venue.blank?
|
||||||
|
%div#location
|
||||||
|
= render 'location'
|
||||||
%div#sponsors
|
%div#sponsors
|
||||||
= render 'sponsor'
|
= render 'sponsor'
|
||||||
%div#social-media
|
%div#social-media
|
||||||
= render 'social_media'
|
= render 'social_media'
|
||||||
|
|
|
||||||
8
db/migrate/20140613083115_add_photo_to_venue.rb
Normal file
8
db/migrate/20140613083115_add_photo_to_venue.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
class AddPhotoToVenue < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :venues, :photo_file_name, :string
|
||||||
|
add_column :venues, :photo_content_type, :string
|
||||||
|
add_column :venues, :photo_file_size, :integer
|
||||||
|
add_column :venues, :photo_updated_at, :datetime
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20140612181230) do
|
ActiveRecord::Schema.define(version: 20140613083115) do
|
||||||
|
|
||||||
create_table "answers", force: true do |t|
|
create_table "answers", force: true do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
|
|
@ -390,6 +390,10 @@ ActiveRecord::Schema.define(version: 20140612181230) do
|
||||||
t.string "offline_map_bounds"
|
t.string "offline_map_bounds"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
t.string "photo_file_name"
|
||||||
|
t.string "photo_content_type"
|
||||||
|
t.integer "photo_file_size"
|
||||||
|
t.datetime "photo_updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "versions", force: true do |t|
|
create_table "versions", force: true do |t|
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,6 @@ FactoryGirl.define do
|
||||||
contact_email 'admin@example.com'
|
contact_email 'admin@example.com'
|
||||||
start_date Date.today
|
start_date Date.today
|
||||||
end_date Date.tomorrow
|
end_date Date.tomorrow
|
||||||
|
venue
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,6 @@ FactoryGirl.define do
|
||||||
name 'Suse Office'
|
name 'Suse Office'
|
||||||
address 'Maxfeldstrasse 5 \n90409 Nuremberg'
|
address 'Maxfeldstrasse 5 \n90409 Nuremberg'
|
||||||
website 'www.opensuse.org'
|
website 'www.opensuse.org'
|
||||||
|
description 'Lorem Ipsum Dolor'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ describe 'conference/show.html.haml' do
|
||||||
@sponsorship_level = @conference.sponsorship_levels.first
|
@sponsorship_level = @conference.sponsorship_levels.first
|
||||||
@sponsorship_level.sponsors << create(:sponsor, sponsorship_level: @sponsorship_level,
|
@sponsorship_level.sponsors << create(:sponsor, sponsorship_level: @sponsorship_level,
|
||||||
conference: @conference)
|
conference: @conference)
|
||||||
|
@conference.venue = create(:venue)
|
||||||
assign :conference, @conference
|
assign :conference, @conference
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
@ -51,4 +52,12 @@ describe 'conference/show.html.haml' do
|
||||||
expect(rendered).to include('http://www.google-example.com')
|
expect(rendered).to include('http://www.google-example.com')
|
||||||
expect(rendered).to include('http://youtu.be/rtyutut')
|
expect(rendered).to include('http://youtu.be/rtyutut')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'renders location partial' do
|
||||||
|
expect(view).to render_template(partial: 'conference/_location')
|
||||||
|
expect(rendered).to include('Suse Office')
|
||||||
|
expect(rendered).to include('Maxfeldstrasse 5 \n90409 Nuremberg')
|
||||||
|
expect(rendered).to include('www.opensuse.org')
|
||||||
|
expect(rendered).to include('Lorem Ipsum Dolor')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue