diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5e4ca356..42419769 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -72,4 +72,8 @@ class ApplicationController < ActionController::Base redirect_to root_path, :alert => exception.message end helper_method :organizer_or_admin? + + def not_found + raise ActionController::RoutingError.new('Not Found') + end end diff --git a/app/controllers/conference_controller.rb b/app/controllers/conference_controller.rb index 7a872c26..2bfeee3c 100644 --- a/app/controllers/conference_controller.rb +++ b/app/controllers/conference_controller.rb @@ -1,5 +1,6 @@ class ConferenceController < ApplicationController def show @conference = Conference.find_by_short_title(params[:id]) + not_found unless @conference.make_conference_public? end end diff --git a/app/models/conference.rb b/app/models/conference.rb index 54ea9f33..0858cf7b 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -19,7 +19,8 @@ class Conference < ActiveRecord::Base :lodging_description, :include_registrations_in_splash, :include_sponsors_in_splash, :include_tracks_in_splash, :include_tickets_in_splash, :include_social_media_in_splash, - :include_program_in_splash + :include_program_in_splash, :make_conference_public + has_paper_trail @@ -282,6 +283,7 @@ class Conference < ActiveRecord::Base result['tracks'] = tracks_set? result['event_types'] = event_types_set? result['difficulty_levels'] = difficulty_levels_set? + result['make_conference_public'] = make_conference_public? result['process'] = calculate_setup_progress(result) result['short_title'] = short_title result diff --git a/app/views/admin/conference/_todo_list.html.haml b/app/views/admin/conference/_todo_list.html.haml index db6cf8db..3f87ecbd 100644 --- a/app/views/admin/conference/_todo_list.html.haml +++ b/app/views/admin/conference/_todo_list.html.haml @@ -27,3 +27,6 @@ %li{'class'=>class_for_todo(conference_progress['difficulty_levels'])} %span{'class'=>icon_for_todo(conference_progress['difficulty_levels'])} = link_to 'Add difficulty levels', admin_conference_difficulty_levels_path(conference_progress['short_title']) + %li{class: class_for_todo(conference_progress['make_conference_public'])} + %span{'class'=>icon_for_todo(conference_progress['make_conference_public'])} + = link_to 'Make Splash Page Public for Visitors', edit_admin_conference_path(conference_progress['short_title']) diff --git a/app/views/admin/conference/edit.html.haml b/app/views/admin/conference/edit.html.haml index d3b6f166..330ccbe6 100644 --- a/app/views/admin/conference/edit.html.haml +++ b/app/views/admin/conference/edit.html.haml @@ -1,6 +1,8 @@ .row .col-md-8 = semantic_form_for(@conference, :url => admin_conference_path(@conference.short_title),:html => {:multipart => true}) do |f| + + = f.input :make_conference_public, hint: 'This will enable the visitors to view the splash page(the "View Conference" button will be visible now on the home page), it is recommended to enable this after you have finished setting up all the components for display' = f.input :include_program_in_splash, hint: 'On setting this true you will enable the program component to be displayed on the splash page.This component includes tracks, keynote speakers and the schedule' = f.input :title, :hint => "The full name of the conference, such as 'OpenSUSE Conference 2013'" = f.input :short_title, :hint => "A short title, such as 'osc2013', to be used in URLs" diff --git a/app/views/home/_conference_details.html.haml b/app/views/home/_conference_details.html.haml index 335b25ed..25320002 100644 --- a/app/views/home/_conference_details.html.haml +++ b/app/views/home/_conference_details.html.haml @@ -21,7 +21,8 @@ .col-md-2 .btn-group-vertical - if !@conference || @conference != conference - = link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default" + - if conference.make_conference_public? + = link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default" - if conference.registration_open? - if conference.user_registered?(current_user) = link_to "Modify Registration", register_conference_path(conference.short_title), :class =>"btn btn-default" @@ -31,4 +32,4 @@ - if !current_user.nil? && current_user.person.proposal_count(conference) > 0 = link_to "View My Proposals", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default" - elsif conference.cfp_open? - = link_to "Submit Proposal", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default" \ No newline at end of file + = link_to "Submit Proposal", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default" diff --git a/db/migrate/20140616131731_add_make_conference_public_to_conference.rb b/db/migrate/20140616131731_add_make_conference_public_to_conference.rb new file mode 100644 index 00000000..9cf9195b --- /dev/null +++ b/db/migrate/20140616131731_add_make_conference_public_to_conference.rb @@ -0,0 +1,5 @@ +class AddMakeConferencePublicToConference < ActiveRecord::Migration + def change + add_column :conferences, :make_conference_public, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 8e5a3c61..71258bb0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -94,6 +94,7 @@ ActiveRecord::Schema.define(version: 20140618062623) do t.boolean "include_tickets_in_splash", default: false t.boolean "include_social_media_in_splash", default: false t.boolean "include_program_in_splash", default: false + t.boolean "make_conference_public", default: false end create_table "conferences_questions", id: false, force: true do |t| diff --git a/spec/controllers/conference_controller_spec.rb b/spec/controllers/conference_controller_spec.rb index 15ff4989..b6ad2b80 100644 --- a/spec/controllers/conference_controller_spec.rb +++ b/spec/controllers/conference_controller_spec.rb @@ -3,14 +3,24 @@ require 'spec_helper' describe ConferenceController do let(:conference) { create(:conference) } describe 'GET #show' do - it 'assigns the requested conference to conference' do - get :show, id: conference.short_title - expect(assigns(:conference)).to eq conference - end + context 'conference made public' do + it 'assigns the requested conference to conference' do + get :show, id: conference.short_title + expect(assigns(:conference)).to eq conference + end - it 'renders the show template' do - get :show, id: conference.short_title - expect(response).to render_template :show + it 'renders the show template' do + get :show, id: conference.short_title + expect(response).to render_template :show + end + end + context 'conference is not public' do + it 'raises routing error' do + # rendered as 404 NOT FOUND in production environment + conference.update_attribute(:make_conference_public, false) + expect { get :show, id: conference.short_title }. + to raise_error(ActionController::RoutingError) + end end end end diff --git a/spec/factories/conferences.rb b/spec/factories/conferences.rb index 47596648..3b07782c 100644 --- a/spec/factories/conferences.rb +++ b/spec/factories/conferences.rb @@ -9,6 +9,7 @@ FactoryGirl.define do contact_email 'admin@example.com' start_date Date.today end_date Date.tomorrow + make_conference_public true venue end end diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb index 31948ee9..13aad3c2 100644 --- a/spec/models/conference_spec.rb +++ b/spec/models/conference_spec.rb @@ -594,6 +594,7 @@ describe Conference do @result['tracks'] = true @result['event_types'] = true @result['difficulty_levels'] = true + @result['make_conference_public'] = true # Setup negative result hash @result_false = Hash.new @@ -613,6 +614,7 @@ describe Conference do subject.tracks = [] subject.event_types = [] subject.difficulty_levels = [] + subject.make_conference_public = false expect(subject.get_status).to eq(@result_false) end @@ -625,9 +627,10 @@ describe Conference do subject.tracks = [] subject.event_types = [] subject.difficulty_levels = [] + subject.make_conference_public = false @result_false['registration'] = true - @result_false['process'] = 14.to_s + @result_false['process'] = 13.to_s expect(subject.get_status).to eq(@result_false) end @@ -640,10 +643,11 @@ describe Conference do subject.tracks = [] subject.event_types = [] subject.difficulty_levels = [] + subject.make_conference_public = false @result_false['cfp'] = true @result_false['registration'] = true - @result_false['process'] = 29.to_s + @result_false['process'] = 25.to_s expect(subject.get_status).to eq(@result_false) end @@ -657,11 +661,12 @@ describe Conference do subject.tracks = [] subject.event_types = [] subject.difficulty_levels = [] + subject.make_conference_public = false @result_false['cfp'] = true @result_false['registration'] = true @result_false['venue'] = true - @result_false['process'] = 43.to_s + @result_false['process'] = 38.to_s expect(subject.get_status).to eq(@result_false) end @@ -675,12 +680,13 @@ describe Conference do subject.tracks = [] subject.event_types = [] subject.difficulty_levels = [] + subject.make_conference_public = false @result_false['cfp'] = true @result_false['registration'] = true @result_false['venue'] = true @result_false['rooms'] = true - @result_false['process'] = 57.to_s + @result_false['process'] = 50.to_s expect(subject.get_status).to eq(@result_false) end @@ -694,13 +700,14 @@ describe Conference do subject.venue = create(:venue) subject.event_types = [] subject.difficulty_levels = [] + subject.make_conference_public = false @result_false['cfp'] = true @result_false['registration'] = true @result_false['venue'] = true @result_false['rooms'] = true @result_false['tracks'] = true - @result_false['process'] = 71.to_s + @result_false['process'] = 63.to_s expect(subject.get_status).to eq(@result_false) end @@ -715,6 +722,7 @@ describe Conference do subject.call_for_papers = create(:call_for_papers) subject.venue = create(:venue) subject.difficulty_levels = [] + subject.make_conference_public = false @result_false['cfp'] = true @result_false['registration'] = true @@ -722,7 +730,7 @@ describe Conference do @result_false['rooms'] = true @result_false['tracks'] = true @result_false['event_types'] = true - @result_false['process'] = 86.to_s + @result_false['process'] = 75.to_s expect(subject.get_status).to eq(@result_false) end @@ -737,6 +745,7 @@ describe Conference do subject.venue = create(:venue) subject.call_for_papers = create(:call_for_papers) subject.venue = create(:venue) + subject.make_conference_public = true expect(subject.get_status).to eq(@result) end