From 0ac5d18ef27e5658aa290e1ec80f3d03fb0f90a5 Mon Sep 17 00:00:00 2001 From: shlok007 Date: Sat, 22 Jul 2017 12:34:48 +0530 Subject: [PATCH 1/7] route to conference#show for custom domain --- app/controllers/conferences_controller.rb | 9 ++++++++- config/initializers/domain_constraint.rb | 6 ++++++ config/routes.rb | 4 ++++ ...0170721184810_add_custom_domain_to_conferences.rb | 5 +++++ db/schema.rb | 12 +++++++----- 5 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 config/initializers/domain_constraint.rb create mode 100644 db/migrate/20170721184810_add_custom_domain_to_conferences.rb diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 53e5bd6d..15a59a0c 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -9,10 +9,17 @@ class ConferencesController < ApplicationController @antiquated = @conferences - @current end - def show; end + def show + # have to change "localhost" to ENV['OSEM_HOSTNAME'] in production + check_custom_domain if request.host != 'localhost' + end private + def check_custom_domain + @conference = @conference.custom_domain.present? ? Conference.find_by(custom_domain: request.domain) : @conference + end + def respond_to_options respond_to do |format| format.html { head :ok } diff --git a/config/initializers/domain_constraint.rb b/config/initializers/domain_constraint.rb new file mode 100644 index 00000000..67e19a75 --- /dev/null +++ b/config/initializers/domain_constraint.rb @@ -0,0 +1,6 @@ +class DomainConstraint + def self.matches?(request) + @domains = Conference.pluck(:custom_domain).compact + @domains.include?(request.domain) + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 3b955953..c4a5f6ce 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,9 @@ Osem::Application.routes.draw do + constraints DomainConstraint do + get '/', to: 'conferences#show' + end + if ENV['OSEM_ICHAIN_ENABLED'] == 'true' devise_for :users, controllers: { registrations: :registrations } else diff --git a/db/migrate/20170721184810_add_custom_domain_to_conferences.rb b/db/migrate/20170721184810_add_custom_domain_to_conferences.rb new file mode 100644 index 00000000..d5aef4fd --- /dev/null +++ b/db/migrate/20170721184810_add_custom_domain_to_conferences.rb @@ -0,0 +1,5 @@ +class AddCustomDomainToConferences < ActiveRecord::Migration + def change + add_column :conferences, :custom_domain, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 83499b33..d9949b1e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,10 +11,10 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170807092805) do +ActiveRecord::Schema.define(version: 20170816203325) do create_table "ahoy_events", force: :cascade do |t| - t.integer "visit_id" + t.uuid "visit_id", limit: 16 t.integer "user_id" t.string "name" t.text "properties" @@ -127,6 +127,7 @@ ActiveRecord::Schema.define(version: 20170807092805) do t.integer "end_hour", default: 20 t.integer "organization_id" t.integer "ticket_layout", default: 0 + t.string "custom_domain" t.integer "booth_limit", default: 0 end @@ -511,10 +512,10 @@ ActiveRecord::Schema.define(version: 20170807092805) do create_table "tickets", force: :cascade do |t| t.integer "conference_id" - t.string "title", null: false + t.string "title", null: false t.text "description" - t.integer "price_cents", default: 0, null: false - t.string "price_currency", default: "USD", null: false + t.integer "price_cents", default: 0, null: false + t.string "price_currency", default: "USD", null: false t.boolean "registration_ticket", default: false end @@ -572,6 +573,7 @@ ActiveRecord::Schema.define(version: 20170807092805) do t.boolean "is_admin", default: false t.string "username" t.boolean "is_disabled", default: false + t.string "token" end add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true From f4775f8e6ab31a05d83fafdb6eba7e025c7db826 Mon Sep 17 00:00:00 2001 From: shlok007 Date: Tue, 25 Jul 2017 07:42:50 +0530 Subject: [PATCH 2/7] fix access denied error for program in custom domains --- app/controllers/conferences_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 15a59a0c..6e5dd5dd 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -2,7 +2,6 @@ class ConferencesController < ApplicationController protect_from_forgery with: :null_session before_action :respond_to_options load_and_authorize_resource find_by: :short_title - load_resource :program, through: :conference, singleton: true, except: :index def index @current = Conference.where('end_date >= ?', Date.current).reorder(start_date: :asc) @@ -10,14 +9,15 @@ class ConferencesController < ApplicationController end def show - # have to change "localhost" to ENV['OSEM_HOSTNAME'] in production + # have to change "localhost" to ENV['OSEM_HOSTNAME'] in production check_custom_domain if request.host != 'localhost' + @program = @conference.program end private def check_custom_domain - @conference = @conference.custom_domain.present? ? Conference.find_by(custom_domain: request.domain) : @conference + @conference = @conference.nil? ? Conference.find_by(custom_domain: request.domain) : @conference end def respond_to_options From 66b48be968a0cb9d6519278fcba5c55117127c03 Mon Sep 17 00:00:00 2001 From: shlok007 Date: Wed, 26 Jul 2017 09:04:07 +0530 Subject: [PATCH 3/7] controller tests for custom domain --- spec/controllers/conferences_controller_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/controllers/conferences_controller_spec.rb b/spec/controllers/conferences_controller_spec.rb index 6479eb34..dffae77a 100644 --- a/spec/controllers/conferences_controller_spec.rb +++ b/spec/controllers/conferences_controller_spec.rb @@ -23,6 +23,15 @@ describe ConferencesController do get :show, id: conference.short_title expect(response).to render_template :show end + + it 'assigns correct conference from a custom domain' do + conference.update_attribute(:custom_domain, 'lvh.me') + @request.host = 'lvh.me' + + get :show + expect(response).to render_template :show + expect(assigns(:conference)).to eq conference + end end end From 835859e350ab41d4a93b077412c84cf2b0c37010 Mon Sep 17 00:00:00 2001 From: shlok007 Date: Wed, 2 Aug 2017 20:16:50 +0530 Subject: [PATCH 4/7] refactored DomainConstraint and conference_controller_spec use params id instead of OSEM_HOSTNAME to load conference --- app/controllers/conferences_controller.rb | 14 +++++++++----- config/initializers/domain_constraint.rb | 6 +++--- spec/controllers/conferences_controller_spec.rb | 7 ++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 6e5dd5dd..f141529d 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -1,7 +1,7 @@ class ConferencesController < ApplicationController protect_from_forgery with: :null_session before_action :respond_to_options - load_and_authorize_resource find_by: :short_title + load_and_authorize_resource find_by: :short_title, except: :show def index @current = Conference.where('end_date >= ?', Date.current).reorder(start_date: :asc) @@ -9,15 +9,19 @@ class ConferencesController < ApplicationController end def show - # have to change "localhost" to ENV['OSEM_HOSTNAME'] in production - check_custom_domain if request.host != 'localhost' + @conference = if params[:id] + Conference.find_by_short_title(params[:id]) + else + load_conference_by_domain + end + authorize! :show, @conference @program = @conference.program end private - def check_custom_domain - @conference = @conference.nil? ? Conference.find_by(custom_domain: request.domain) : @conference + def load_conference_by_domain + Conference.find_by(custom_domain: request.domain) end def respond_to_options diff --git a/config/initializers/domain_constraint.rb b/config/initializers/domain_constraint.rb index 67e19a75..5b35e5c7 100644 --- a/config/initializers/domain_constraint.rb +++ b/config/initializers/domain_constraint.rb @@ -1,6 +1,6 @@ class DomainConstraint def self.matches?(request) - @domains = Conference.pluck(:custom_domain).compact - @domains.include?(request.domain) + domains = Conference.where.not(custom_domain: nil).pluck(:custom_domain) + domains.include?(request.domain) end -end \ No newline at end of file +end diff --git a/spec/controllers/conferences_controller_spec.rb b/spec/controllers/conferences_controller_spec.rb index dffae77a..cdbebf9f 100644 --- a/spec/controllers/conferences_controller_spec.rb +++ b/spec/controllers/conferences_controller_spec.rb @@ -23,12 +23,17 @@ describe ConferencesController do get :show, id: conference.short_title expect(response).to render_template :show end + end - it 'assigns correct conference from a custom domain' do + context 'accessing conference via custom domain' do + before do conference.update_attribute(:custom_domain, 'lvh.me') @request.host = 'lvh.me' + end + it 'assigns correct conference' do get :show + expect(response).to render_template :show expect(assigns(:conference)).to eq conference end From 834e9d96e4ac60a3c28455722d05ad2c6f2f6fda Mon Sep 17 00:00:00 2001 From: nasia Date: Fri, 11 Aug 2017 15:14:22 +0300 Subject: [PATCH 5/7] Add booths to admin sidebar --- app/controllers/admin/booths_controller.rb | 4 ++++ app/views/admin/booths/_change_state_dropdown.html.haml | 5 +++++ app/views/layouts/_admin_sidebar.html.haml | 6 +++++- config/routes.rb | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/booths_controller.rb b/app/controllers/admin/booths_controller.rb index a200e42e..a65de090 100644 --- a/app/controllers/admin/booths_controller.rb +++ b/app/controllers/admin/booths_controller.rb @@ -90,6 +90,10 @@ module Admin update_state(:cancel, 'Booth is canceled') end + def confirm + update_state(:confirm, 'Booth successfully confirmed') + end + private def update_state(transition, notice) diff --git a/app/views/admin/booths/_change_state_dropdown.html.haml b/app/views/admin/booths/_change_state_dropdown.html.haml index 12b982df..338e43f7 100644 --- a/app/views/admin/booths/_change_state_dropdown.html.haml +++ b/app/views/admin/booths/_change_state_dropdown.html.haml @@ -42,3 +42,8 @@ %li= link_to 'Cancel booth', cancel_admin_conference_booth_path(@conference.short_title, booth), method: :patch, id: "cancel_booth_#{booth.id}" + +- if booth.transition_possible? :confirm + %li= link_to 'Confirm booth', + confirm_admin_conference_booth_path(@conference.short_title, booth), + method: :patch, id: "confirm_booth_#{booth.id}" diff --git a/app/views/layouts/_admin_sidebar.html.haml b/app/views/layouts/_admin_sidebar.html.haml index 28ef62e2..1f8bf6b5 100644 --- a/app/views/layouts/_admin_sidebar.html.haml +++ b/app/views/layouts/_admin_sidebar.html.haml @@ -116,7 +116,11 @@ - if can? :update, @conference.tickets.build %li{class: active_nav_li(admin_conference_tickets_path(@conference.short_title)) } = link_to 'Tickets', admin_conference_tickets_path(@conference.short_title) - + - if can? :manage, @conference.booths + %li + = link_to admin_conference_booths_path(@conference.short_title) do + %span.fa.fa-shopping-bag + Booths - if (can? :manage, @conference.targets.build) || (can? :manage, @conference.campaigns.build) %li %a diff --git a/config/routes.rb b/config/routes.rb index c4a5f6ce..1e26807c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -57,6 +57,7 @@ Osem::Application.routes.draw do patch :reset patch :to_reject patch :cancel + patch :confirm end end From bc45531efda66c367e88e674fae6eb4576d46e9d Mon Sep 17 00:00:00 2001 From: nasia Date: Tue, 15 Aug 2017 15:46:33 +0300 Subject: [PATCH 6/7] Add My Booth Requests to user menu --- .haml-lint_todo.yml | 1 + app/views/layouts/_admin_sidebar.html.haml | 2 +- app/views/layouts/_user_menu.html.haml | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.haml-lint_todo.yml b/.haml-lint_todo.yml index 25ccb622..49feab3d 100644 --- a/.haml-lint_todo.yml +++ b/.haml-lint_todo.yml @@ -153,6 +153,7 @@ linters: - "app/views/layouts/_admin_sidebar_index.html.haml" - "app/views/layouts/_messages.html.haml" - "app/views/layouts/_navigation.html.haml" + - "app/views/layouts/_user_menu.html.haml" - "app/views/layouts/application.html.haml" - "app/views/organizations/index.html.haml" - "app/views/payments/_payment.html.haml" diff --git a/app/views/layouts/_admin_sidebar.html.haml b/app/views/layouts/_admin_sidebar.html.haml index 1f8bf6b5..e8f1ccd9 100644 --- a/app/views/layouts/_admin_sidebar.html.haml +++ b/app/views/layouts/_admin_sidebar.html.haml @@ -116,7 +116,7 @@ - if can? :update, @conference.tickets.build %li{class: active_nav_li(admin_conference_tickets_path(@conference.short_title)) } = link_to 'Tickets', admin_conference_tickets_path(@conference.short_title) - - if can? :manage, @conference.booths + - if can? :manage, @conference.booths.build %li = link_to admin_conference_booths_path(@conference.short_title) do %span.fa.fa-shopping-bag diff --git a/app/views/layouts/_user_menu.html.haml b/app/views/layouts/_user_menu.html.haml index fe1e9a35..bad4c16d 100644 --- a/app/views/layouts/_user_menu.html.haml +++ b/app/views/layouts/_user_menu.html.haml @@ -16,6 +16,11 @@ = link_to(conference_program_tracks_path(@conference.short_title)) do %span.fa.fa-road My Tracks +-if @conference && @conference.program && (@conference.program.cfps.for_booths.try(:open?) || current_user.booths.where(conference_id: @conference.id).count > 0) + %li + = link_to (conference_booths_path(@conference.short_title)) do + %span.fa.fa-shopping-bag + My Booth Requests %li - if ENV['OSEM_ICHAIN_ENABLED'] == 'true' = link_to(destroy_user_ichain_session_path, method: 'delete') do From 7af712f49211fd12b1fb55b555b16d1628429148 Mon Sep 17 00:00:00 2001 From: divyanshumehta Date: Wed, 10 May 2017 16:24:20 +0530 Subject: [PATCH 7/7] Made lodging cards of same height w.r.t. to its row. Fixes #1456. --- app/views/conferences/_lodging.html.haml | 34 +++++++++++++----------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/app/views/conferences/_lodging.html.haml b/app/views/conferences/_lodging.html.haml index e94286a4..561e2421 100644 --- a/app/views/conferences/_lodging.html.haml +++ b/app/views/conferences/_lodging.html.haml @@ -12,22 +12,26 @@ = @conference.venue.city %p.lead We recommend these affordable lodging accommodations for your visit. - - @conference.lodgings.each_slice(3) do |slice| - .row.row-centered - - slice.each do |lodging| - .col-md-4.col-sm-4.ticket.col-centered.col-top - .thumbnail - - unless lodging.picture? - %p.text-center - %i.fa.fa-home.fa-5x + + .row.row-centered{ style:"display: flex; flex-wrap: wrap" } + - @conference.lodgings.each do |lodging| + .col-md-4.col-sm-4.col-centered.col-top{ style:"display:flex;" } + .thumbnail + - if lodging.picture? + -if lodging.website_link.present? + = link_to(lodging.website_link, class: 'thumbnail') do + = image_tag lodging.picture.large.url, class: 'img-responsive img-lodging' - else + = image_tag lodging.picture.large.url, class: 'img-responsive img-lodging' + - else + %p.text-center -if lodging.website_link.present? = link_to(lodging.website_link, class: 'thumbnail') do - = image_tag lodging.picture.large.url, class: 'img-responsive img-lodging' + %i.fa.fa-home.fa-5x - else - = image_tag lodging.picture.large.url, class: 'img-responsive img-lodging' - .caption - %h3.text-center - = lodging.name - -if lodging.description.present? - = markdown(lodging.description) + %i.fa.fa-home.fa-5x + .caption + %h3.text-center + = lodging.name + -if lodging.description.present? + = markdown(lodging.description)