diff --git a/app/assets/stylesheets/osem.css b/app/assets/stylesheets/osem.css index 396957dd..d8f42961 100644 --- a/app/assets/stylesheets/osem.css +++ b/app/assets/stylesheets/osem.css @@ -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; +} diff --git a/app/controllers/admin/lodgings_controller.rb b/app/controllers/admin/lodgings_controller.rb new file mode 100644 index 00000000..554c8107 --- /dev/null +++ b/app/controllers/admin/lodgings_controller.rb @@ -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 diff --git a/app/controllers/admin/venue_controller.rb b/app/controllers/admin/venue_controller.rb index 15156217..4c8696d6 100644 --- a/app/controllers/admin/venue_controller.rb +++ b/app/controllers/admin/venue_controller.rb @@ -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 diff --git a/app/models/conference.rb b/app/models/conference.rb index 8ba0e73e..96742bf8 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 new file mode 100644 index 00000000..296ff0b1 --- /dev/null +++ b/app/models/lodging.rb @@ -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 diff --git a/app/models/venue.rb b/app/models/venue.rb index e0251f7c..3b4ad51c 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -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 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 new file mode 100644 index 00000000..83c27724 --- /dev/null +++ b/app/views/admin/lodgings/_lodging_fields.html.erb @@ -0,0 +1,11 @@ +
+ <%= 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 %> +
diff --git a/app/views/admin/lodgings/index.html.haml b/app/views/admin/lodgings/index.html.haml new file mode 100644 index 00000000..7dc8426a --- /dev/null +++ b/app/views/admin/lodgings/index.html.haml @@ -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"} diff --git a/app/views/admin/venue/venue_info.html.haml b/app/views/admin/venue/venue_info.html.haml index af339af2..c576612c 100644 --- a/app/views/admin/venue/venue_info.html.haml +++ b/app/views/admin/venue/venue_info.html.haml @@ -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"} diff --git a/app/views/conference/_location.html.haml b/app/views/conference/_location.html.haml new file mode 100644 index 00000000..ce3887d9 --- /dev/null +++ b/app/views/conference/_location.html.haml @@ -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+')'); + } + }); 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/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index cbadd6d3..9d2d9702 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -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'); + }); diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index f9b27f71..2df959ce 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -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} \ No newline at end of file + = render :partial => "conference_details", :locals => {:conference => conference} diff --git a/app/views/layouts/_admin_sidebar.html.haml b/app/views/layouts/_admin_sidebar.html.haml index 7e7c238d..290f9b32 100644 --- a/app/views/layouts/_admin_sidebar.html.haml +++ b/app/views/layouts/_admin_sidebar.html.haml @@ -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 diff --git a/config/routes.rb b/config/routes.rb index e34d7e52..5b3bac38 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/db/migrate/20140602140203_add_photo_to_venue.rb b/db/migrate/20140602140203_add_photo_to_venue.rb new file mode 100644 index 00000000..c2d0454c --- /dev/null +++ b/db/migrate/20140602140203_add_photo_to_venue.rb @@ -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 diff --git a/db/migrate/20140604061951_create_lodgings.rb b/db/migrate/20140604061951_create_lodgings.rb new file mode 100644 index 00000000..45412bcc --- /dev/null +++ b/db/migrate/20140604061951_create_lodgings.rb @@ -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 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 2ef5c751..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" @@ -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| diff --git a/spec/factories/conferences.rb b/spec/factories/conferences.rb index 8fdbe34d..47596648 100644 --- a/spec/factories/conferences.rb +++ b/spec/factories/conferences.rb @@ -9,5 +9,6 @@ FactoryGirl.define do contact_email 'admin@example.com' start_date Date.today end_date Date.tomorrow + venue end end diff --git a/spec/factories/lodgings.rb b/spec/factories/lodgings.rb new file mode 100644 index 00000000..efa16bb2 --- /dev/null +++ b/spec/factories/lodgings.rb @@ -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 diff --git a/spec/factories/venues.rb b/spec/factories/venues.rb index fca4e1f5..69eb863b 100644 --- a/spec/factories/venues.rb +++ b/spec/factories/venues.rb @@ -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 diff --git a/spec/features/lodgings_spec.rb b/spec/features/lodgings_spec.rb new file mode 100644 index 00000000..7b5d3814 --- /dev/null +++ b/spec/features/lodgings_spec.rb @@ -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 diff --git a/spec/models/lodging_spec.rb b/spec/models/lodging_spec.rb new file mode 100644 index 00000000..b246e664 --- /dev/null +++ b/spec/models/lodging_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Lodging do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/admin/lodgings/index.html.haml_spec.rb b/spec/views/admin/lodgings/index.html.haml_spec.rb new file mode 100644 index 00000000..7bc6925a --- /dev/null +++ b/spec/views/admin/lodgings/index.html.haml_spec.rb @@ -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 diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index 8e32e586..e0a3ec2f 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -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