This commit is contained in:
Gopesh Tulsyan 2014-06-11 10:34:56 +00:00
commit 78d5bd670d
28 changed files with 333 additions and 22 deletions

View file

@ -83,3 +83,17 @@ body {
.top-submitter img {
margin: 0 auto;
}
#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;
}

View file

@ -0,0 +1,23 @@
module Admin
class LodgingsController < ApplicationController
before_filter :verify_organizer
def index
@venue = @conference.venue
end
def show
end
def update
@venue = @conference.venue
if @venue.update_attributes(params[:venue])
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
notice: 'Lodgings were successfully updated.')
else
redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title),
notice: 'Lodgings Updation Failed!')
end
end
end
end

View file

@ -6,13 +6,13 @@ class Admin::VenueController < ApplicationController
def update
@venue = @conference.venue
venue_params = params[:venue]
@venue.name = venue_params[:name]
@venue.address= venue_params[:address]
@venue.website = venue_params[:website]
@venue.description = venue_params[:description]
@venue.save
redirect_to(admin_conference_venue_info_path(:conference_id => @conference.short_title), :notice => 'Venue was successfully updated.')
if @venue.update_attributes!(params[:venue])
redirect_to(admin_conference_venue_info_path(conference_id: @conference.short_title),
notice: 'Venue was successfully updated.')
else
redirect_to(admin_conference_venue_info_path(conference_id: @conference.short_title),
notice: 'Venue Updation Failed!')
end
end
def show

View file

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

10
app/models/lodging.rb Normal file
View file

@ -0,0 +1,10 @@
class Lodging < ActiveRecord::Base
attr_accessible :name, :description, :photo, :website_link
belongs_to :venue
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 }
end

View file

@ -1,7 +1,16 @@
class Venue < ActiveRecord::Base
attr_accessible :name, :description, :website, :address, :photo, :lodgings_attributes
has_many :conferences
has_many :lodgings
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 }
accepts_nested_attributes_for :lodgings, reject_if: proc { |r| r['name'].blank? },
allow_destroy: true
private
def generate_guid

View file

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

View file

@ -0,0 +1,11 @@
<div class="nested-fields">
<%= f.inputs do %>
<%= f.input :name %>
<%= f.input :description, :input_html => {:rows => 2 }, hint: 'Write about the hotel/place,
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

@ -0,0 +1,5 @@
.row
.col-md-8
= semantic_form_for(@venue, :url => admin_conference_lodging_path(@conference.short_title, @conference.venue.lodgings), :html => {:multipart => true}) do |f|
= dynamic_association :lodgings, "Lodgings", f
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}

View file

@ -5,4 +5,7 @@
= f.input :address, :input_html => {:rows => 1}
= f.input :website
= f.input :description, :input_html => { :rows => 10, :cols => 20 }
- if !@venue.photo.blank?
= image_tag @venue.photo(:thumb)
= f.input :photo
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}

View file

@ -0,0 +1,39 @@
= content_for :splash_nav do
%li
%a{ href: '#location' } Location
%div#location
%div.container.text-center
.div.row.col-md-12
- if !@conference.venue.name.blank?
%h1
%strong #{ @conference.venue.name }
- if !@conference.venue.address.blank?
%h2
%strong #{ @conference.venue.address }
- if !@conference.venue.description.blank?
%p
%strong #{ @conference.venue.description }
%ul
- if !@conference.venue.address.blank?
%li
%b
= link_to 'View in Google Maps', "http://maps.google.com/maps?q=#{@conference.venue.address}", target: '_blank'
- if !@conference.venue.website.blank?
%li
%b
= link_to 'Visit Venue Website', @conference.venue.website, target: '_blank'
- if @conference.venue
- unless @conference.venue.lodgings.empty?
= render 'lodging'
:javascript
$(document).ready(function(){
var photo = "#{@conference.venue.photo}";
if(photo)
{
$('#location').css('background-image', 'url('+photo+')');
}
});

View file

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

View file

@ -1,9 +1,23 @@
= content_for :brand do
= link_to @conference.title, conference_url(@conference.short_title), class: 'navbar-brand'
%div#program
= render 'program'
%div#registration
= render 'registration'
%div#callforpapers
= render 'call_for_papers'
%div#location
= render 'location'
:javascript
$(document).ready(function(){
$('#content').removeClass('container');
});

View file

@ -2,4 +2,4 @@
.col-md-12.page-header
%h2.text-center Upcoming Conferences
- @current.each do |conference|
= render :partial => "conference_details", :locals => {:conference => conference}
= render :partial => "conference_details", :locals => {:conference => conference}

View file

@ -45,6 +45,8 @@
%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_lodgings_path(@conference.short_title)) }
= link_to 'Lodgings', admin_conference_lodgings_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

View file

@ -28,6 +28,8 @@ Osem::Application.routes.draw do
resources :tracks, only: [:show, :update, :index]
resources :lodgings, only: [:show, :update, :index]
resources :eventtypes, only: [:show, :index] do
collection do
patch :update

View 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

View file

@ -0,0 +1,14 @@
class CreateLodgings < ActiveRecord::Migration
def change
create_table :lodgings do |t|
t.string :name
t.text :description
t.string :photo_file_name
t.string :photo_content_type
t.integer :photo_file_size
t.datetime :photo_updated_at
t.belongs_to :venue
t.timestamps
end
end
end

View file

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

View file

@ -0,0 +1,5 @@
class AddLodgingDescriptionToConference < ActiveRecord::Migration
def change
add_column :conferences, :lodging_description, :text
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: 20140605125153) do
ActiveRecord::Schema.define(version: 20140606173417) do
create_table "answers", force: true do |t|
t.string "title"
@ -50,15 +50,15 @@ ActiveRecord::Schema.define(version: 20140605125153) 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"
@ -81,6 +81,10 @@ ActiveRecord::Schema.define(version: 20140605125153) do
t.text "description"
t.text "registration_description"
t.text "ticket_description"
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|
@ -186,6 +190,19 @@ ActiveRecord::Schema.define(version: 20140605125153) do
t.integer "event_id"
end
create_table "lodgings", force: true do |t|
t.string "name"
t.text "description"
t.string "photo_file_name"
t.string "photo_content_type"
t.integer "photo_file_size"
t.datetime "photo_updated_at"
t.integer "venue_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "website_link"
end
create_table "people", force: true do |t|
t.string "guid", null: false
t.string "first_name", default: ""
@ -308,9 +325,9 @@ ActiveRecord::Schema.define(version: 20140605125153) do
end
create_table "tracks", force: true do |t|
t.string "guid", null: false
t.string "guid", null: false
t.integer "conference_id"
t.string "name", null: false
t.string "name", null: false
t.text "description"
t.string "color"
t.datetime "created_at"
@ -363,6 +380,10 @@ ActiveRecord::Schema.define(version: 20140605125153) do
t.string "offline_map_bounds"
t.datetime "created_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
create_table "versions", force: true do |t|

View file

@ -9,5 +9,6 @@ FactoryGirl.define do
contact_email 'admin@example.com'
start_date Date.today
end_date Date.tomorrow
venue
end
end

View file

@ -0,0 +1,10 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :lodging do
name 'Example Hotel'
description 'Lorem Ipsum Dolor'
website_link 'http://www.example.com'
venue
end
end

View file

@ -4,5 +4,6 @@ FactoryGirl.define do
name 'Suse Office'
address 'Maxfeldstrasse 5 \n90409 Nuremberg'
website 'www.opensuse.org'
description 'Lorem Ipsum Dolor'
end
end

View file

@ -0,0 +1,59 @@
require 'spec_helper'
feature Lodging do
# It is necessary to use bang version of let to build roles before user
let!(:organizer_role) { create(:organizer_role) }
let!(:participant_role) { create(:participant_role) }
let!(:admin_role) { create(:admin_role) }
shared_examples 'lodgings' do |user|
scenario 'adds and updates lodgings', feature: true, js: true do
path = "#{Rails.root}/app/assets/images/rails.png"
conference = create(:conference)
conference.venue = create(:venue)
sign_in create(user)
visit admin_conference_lodgings_path(
conference_id: conference.short_title)
# Add lodging
click_link 'Add lodging'
expect(page.all('div.nested-fields').count == 1).to be true
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
set('Example Hotel')
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(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
click_link 'Remove lodging'
expect(page.all('div.nested-fields').count == 0).to be true
click_button 'Update Venue'
expect(flash).to eq('Lodgings were successfully updated.')
expect(page.all('div.nested-fields').count == 0).to be true
end
end
describe 'admin' do
it_behaves_like 'lodgings', :admin
end
describe 'organizer' do
it_behaves_like 'lodgings', :organizer
end
end

View file

@ -0,0 +1,5 @@
require 'spec_helper'
describe Lodging do
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -0,0 +1,14 @@
require 'spec_helper'
describe 'admin/lodgings/index' do
it 'renders lodgings list' do
@conference = create(:conference)
@conference.venue = create(:venue)
@conference.venue.lodgings << create(:lodging, venue: @conference.venue)
assign :venue, @conference.venue
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

@ -5,13 +5,15 @@ describe 'conference/show.html.haml' do
registration_start_date: Date.today,
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
end
it 'renders program partial' do
expect(render).to include("#{@conference.description}")
expect(rendered).to include("#{@conference.description}")
expect(view).to render_template(partial: 'conference/_program')
end
@ -21,6 +23,22 @@ describe 'conference/show.html.haml' do
end
it 'renders call_for_papers partial' do
expect(render).to include("#{@conference.call_for_papers.description}")
expect(view).to render_template(partial: 'conference/_call_for_papers')
expect(rendered).to include("#{@conference.call_for_papers.description}")
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
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