From fedb0753bffd5f49c2d7775c5ea0df86c5af6a29 Mon Sep 17 00:00:00 2001 From: Chrisbr Date: Sat, 30 Aug 2014 12:08:24 +0200 Subject: [PATCH] Extracted Splashpage from Conference #418 --- .../admin/splashpages_controller.rb | 49 ++++++++ app/controllers/commercials_controller.rb | 4 +- app/models/ability.rb | 3 +- app/models/conference.rb | 19 +-- app/models/splashpage.rb | 15 +++ .../admin/conference/_edit_form.html.haml | 12 -- .../admin/conference/_edit_show.html.haml | 24 ---- .../admin/conference/_todo_list.html.haml | 8 +- app/views/admin/conference/edit.html.haml | 1 + app/views/admin/contacts/_form.html.haml | 1 - app/views/admin/contacts/show.html.haml | 26 ---- app/views/admin/emails/_help.html.haml | 2 +- app/views/admin/lodgings/index.html.haml | 1 - .../registration_periods/_form.html.haml | 1 - .../admin/registration_periods/show.html.haml | 5 - app/views/admin/splashpages/_form.html.haml | 27 +++++ app/views/admin/splashpages/show.html.haml | 113 ++++++++++++++++++ app/views/admin/sponsors/index.html.haml | 1 - app/views/admin/tracks/index.html.haml | 1 - app/views/admin/venue/venue_info.html.haml | 1 - app/views/conference/_lodging.html.haml | 4 +- app/views/conference/_program.html.haml | 2 +- app/views/conference/_registration.html.haml | 6 +- app/views/conference/_sponsor.html.haml | 4 +- app/views/conference/_tickets.html.haml | 6 +- app/views/conference/show.html.haml | 101 ++++++++-------- app/views/home/_conference_details.html.haml | 4 +- app/views/layouts/_admin_sidebar.html.haml | 5 + config/routes.rb | 2 + .../20140825091222_create_splashpages.rb | 30 +++++ ...ttributes_from_conference_to_splashpage.rb | 89 ++++++++++++++ db/schema.rb | 46 +++---- .../registration_periods_controller_spec.rb | 20 ++-- .../controllers/conference_controller_spec.rb | 14 +-- spec/factories/conferences.rb | 1 - spec/factories/registration_periods.rb | 1 - spec/factories/splashpages.rb | 7 ++ spec/features/registration_periods_spec.rb | 2 - spec/features/splashpage_spec.rb | 94 +++++++++++++++ spec/models/ability_spec.rb | 8 +- spec/models/conference_spec.rb | 18 +-- spec/views/conference/show.html.haml_spec.rb | 36 +++--- 42 files changed, 578 insertions(+), 236 deletions(-) create mode 100644 app/controllers/admin/splashpages_controller.rb create mode 100644 app/models/splashpage.rb delete mode 100644 app/views/admin/contacts/show.html.haml create mode 100644 app/views/admin/splashpages/_form.html.haml create mode 100644 app/views/admin/splashpages/show.html.haml create mode 100644 db/migrate/20140825091222_create_splashpages.rb create mode 100644 db/migrate/20140825093132_move_splashpage_attributes_from_conference_to_splashpage.rb create mode 100644 spec/factories/splashpages.rb create mode 100644 spec/features/splashpage_spec.rb diff --git a/app/controllers/admin/splashpages_controller.rb b/app/controllers/admin/splashpages_controller.rb new file mode 100644 index 00000000..20295865 --- /dev/null +++ b/app/controllers/admin/splashpages_controller.rb @@ -0,0 +1,49 @@ +module Admin + class SplashpagesController < Admin::BaseController + load_and_authorize_resource :conference, find_by: :short_title + load_and_authorize_resource through: :conference, singleton: true + + def show; end + + def new + @splashpage = @conference.build_splashpage + end + + def edit; end + + def create + @splashpage = @conference.build_splashpage(splashpage_params) + + if @splashpage.save + redirect_to admin_conference_splashpage_path, + notice: 'Splashpage successfully created.' + else + render :new + end + end + + def update + if @splashpage.update_attributes(splashpage_params) + redirect_to admin_conference_splashpage_path, + notice: 'Splashpage successfully updated.' + else + render :edit + end + end + + def destroy + if @splashpage.destroy + redirect_to admin_conference_splashpage_path, notice: 'Splashpage was successfully destroyed.' + else + redirect_to admin_conference_splashpage_path, alert: "A error prohibited this Splashpage from being destroyed: "\ + "#{@splashpage.errors.full_messages.join('. ')}." + end + end + + private + + def splashpage_params + params[:splashpage] + end + end +end diff --git a/app/controllers/commercials_controller.rb b/app/controllers/commercials_controller.rb index 79a87f30..38bd2eb7 100644 --- a/app/controllers/commercials_controller.rb +++ b/app/controllers/commercials_controller.rb @@ -1,7 +1,7 @@ class CommercialsController < ApplicationController - load_and_authorize_resource :conference, find_by: :short_title + load_resource :conference, find_by: :short_title before_action :set_event - load_and_authorize_resource through: @event, except: [:new, :create] + load_and_authorize_resource through: :event def new @commercial = @event.commercials.build diff --git a/app/models/ability.rb b/app/models/ability.rb index 34734a53..5e4819ba 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -107,12 +107,13 @@ class Ability can :manage, Campaign, conference_id: conf_ids_for_organizer can :manage, Photo, conference_id: conf_ids_for_organizer can :manage, RegistrationPeriod, conference_id: conf_ids_for_organizer + can :manage, Splashpage, conference_id: conf_ids_for_organizer end def guest ## Abilities for everyone, even guests (not logged in users) can [:show, :gallery_photos], Conference do |conference| - conference.make_conference_public == true + conference.splashpage && conference.splashpage.public == true end # see commercials too diff --git a/app/models/conference.rb b/app/models/conference.rb index 460fab37..eea4e83f 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -14,20 +14,15 @@ class Conference < ActiveRecord::Base :question_ids, :answers_attributes, :answer_ids, :difficulty_levels_attributes, :use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes, :vpositions_attributes, :use_volunteers, :color, - :description, :ticket_description, :sponsorship_levels_attributes, :sponsors_attributes, - :sponsor_description, :sponsor_email, :lodging_description, - :include_registrations_in_splash, :include_sponsors_in_splash, - :include_tracks_in_splash, :include_tickets_in_splash, - :include_program_in_splash, - :make_conference_public, :photos_attributes, :banner_photo, - :include_banner_in_splash, :targets, :targets_attributes, :campaigns, - :campaigns_attributes + :sponsor_email, :photos_attributes, :targets, :targets_attributes, + :campaigns, :campaigns_attributes has_paper_trail has_many :questions + has_one :splashpage, dependent: :destroy has_one :contact, dependent: :destroy has_one :registration_period, dependent: :destroy has_one :email_settings, dependent: :destroy @@ -94,12 +89,6 @@ class Conference < ActiveRecord::Base content_type: [/jpg/, /jpeg/, /png/, /gif/], size: { in: 0..500.kilobytes } - has_attached_file :banner_photo, - styles: { thumb: '100x100>', large: '1300x700>' } - - validates_attachment_content_type :banner_photo, - content_type: [/jpg/, /jpeg/, /png/, /gif/], - size: { in: 0..500.kilobytes } validates_presence_of :title, :short_title, :start_date, @@ -325,7 +314,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['splashpage'] = splashpage && splashpage.public? result['process'] = calculate_setup_progress(result) result['short_title'] = short_title result diff --git a/app/models/splashpage.rb b/app/models/splashpage.rb new file mode 100644 index 00000000..da698015 --- /dev/null +++ b/app/models/splashpage.rb @@ -0,0 +1,15 @@ +class Splashpage < ActiveRecord::Base + belongs_to :conference + + attr_accessible :banner_description, :ticket_description, :sponsor_description, :lodging_description, + :registration_description, :include_registrations, :include_sponsors, + :include_tracks, :include_tickets, :include_program, :public, :banner_photo, :include_banner, + :include_social_media, :include_lodgings, :include_venue, :lodging_description + + has_attached_file :banner_photo, + styles: { thumb: '100x100>', large: '1300x700>' } + + validates_attachment_content_type :banner_photo, + content_type: [/jpg/, /jpeg/, /png/, /gif/], + size: { in: 0..500.kilobytes } +end diff --git a/app/views/admin/conference/_edit_form.html.haml b/app/views/admin/conference/_edit_form.html.haml index 010a8b48..e69695d0 100644 --- a/app/views/admin/conference/_edit_form.html.haml +++ b/app/views/admin/conference/_edit_form.html.haml @@ -1,27 +1,15 @@ .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" = f.input :color, :hint => "The color will be used eg for the dashboard.", :input_html => {:size => 6, :type => "color"} - if !@conference.logo.blank? = image_tag @conference.logo(:thumb) = f.input :logo, :label => "Conference Logo", :hint => "This will be displayed on the front page." - = f.inputs name: 'Banner for Splash' do - = f.input :include_banner_in_splash, hint: 'This enable the Banner Photo with description to be displayed on the splash' - = f.input :banner_photo, hint: 'This will be the top most component of the splash.This background cover will contain start_date and end_date of the conference and the description' - = f.input :description, hint: markdown_hint("This description will be shown at the bottom of the banner photo of the Splash."), input_html: { rows: 5, data: { provide: "markdown-editable" } } - = f.inputs :name => "Scheduling" do = f.input :timezone, :as => :time_zone, :hint => "The conference time zone" = f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" } = f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" } - = f.inputs name: 'Registration' do - = f.input :include_registrations_in_splash, hint: 'On setting this true you will enable the registrations to be displayed on the splash page' - = f.input :ticket_description, hint: markdown_hint("This will appear in the Tickets segment of the splash."), input_html: { rows: 5, data: { provide: "markdown-editable" } } - = f.input :sponsor_description, hint: markdown_hint("This will appear in the sponsor segment of the splash."), input_html: { rows: 5, data: { provide: "markdown-editable" } } = f.input :sponsor_email, hint: 'This will appear in the sponsor segment of the splash for the sponsors to contact to the organizers' - = f.input :lodging_description, hint: markdown_hint("This will appear in the lodging segment of the splash."), input_html: { rows: 5, data: { provide: "markdown-editable" } } = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/admin/conference/_edit_show.html.haml b/app/views/admin/conference/_edit_show.html.haml index ab08dbca..22446f6e 100644 --- a/app/views/admin/conference/_edit_show.html.haml +++ b/app/views/admin/conference/_edit_show.html.haml @@ -9,13 +9,6 @@ Short Title %dd = @conference.short_title - %dt - Description - %dd - - unless @conference.description.blank? - = markdown(@conference.description) - - else - Not set! %dt Date %dd @@ -42,20 +35,3 @@ -else %h4.text-center Not set! - .col-md-4 - .thumbnail.flex-col - %h3.text-center - Conference Banner - - if @conference.banner_photo? - = image_tag(@conference.banner_photo(:large), class: 'img-responsive') - .caption.flex-grow - .caption - %p - %dl.dl-horizontal - %dt - Filename - %dd - = @conference.banner_photo_file_name - - else - %h4.text-center - Not set! diff --git a/app/views/admin/conference/_todo_list.html.haml b/app/views/admin/conference/_todo_list.html.haml index ffb4d096..deb78a77 100644 --- a/app/views/admin/conference/_todo_list.html.haml +++ b/app/views/admin/conference/_todo_list.html.haml @@ -48,9 +48,9 @@ = link_to 'Add difficulty levels', admin_conference_difficulty_levels_path(conference_progress['short_title']) - else Add difficulty levels - %li{class: class_for_todo(conference_progress['make_conference_public'])} - %span{'class'=>icon_for_todo(conference_progress['make_conference_public'])} + %li{class: class_for_todo(conference_progress['splashpage'])} + %span{'class'=>icon_for_todo(conference_progress['splashpage'])} - if can? :update, @conference - = link_to 'Make Splash Page Public for Visitors', edit_admin_conference_path(conference_progress['short_title']) + = link_to 'Set up a Splashpage', admin_conference_splashpage_path(conference_progress['short_title']) - else - Make Splash Page Public for Visitors + Set up a Splashpage diff --git a/app/views/admin/conference/edit.html.haml b/app/views/admin/conference/edit.html.haml index 14b86e1c..76bf58cb 100644 --- a/app/views/admin/conference/edit.html.haml +++ b/app/views/admin/conference/edit.html.haml @@ -7,6 +7,7 @@ %li %a{'href'=> '#edit', 'role'=>'tab', 'data-toggle'=>'tab'} Edit +%br .row .col-md-12 .tab-content diff --git a/app/views/admin/contacts/_form.html.haml b/app/views/admin/contacts/_form.html.haml index 2963b9b9..6d077891 100644 --- a/app/views/admin/contacts/_form.html.haml +++ b/app/views/admin/contacts/_form.html.haml @@ -9,5 +9,4 @@ = f.input :googleplus, label: 'Google+ Url', hint: 'This will appear in the social media section as the link to the Google+ Page of your Conference' = f.input :twitter, hint: 'This will appear in the social media section as the link to the Twitter Page of your Conference' = f.input :instagram, hint: 'This will appear in the social media section as the link to the Instagram Page of your Conference' - = f.input :public, hint: 'On setting this true you will enable the social media links to be displayed on the splash page' = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } diff --git a/app/views/admin/contacts/show.html.haml b/app/views/admin/contacts/show.html.haml deleted file mode 100644 index d73f904f..00000000 --- a/app/views/admin/contacts/show.html.haml +++ /dev/null @@ -1,26 +0,0 @@ -%p#notice= notice - -%p - %b Social tag: - = @contact.social_tag -%p - %b Email: - = @contact.email -%p - %b Facebook: - = @contact.facebook -%p - %b Googleplus: - = @contact.googleplus -%p - %b Twitter: - = @contact.twitter -%p - %b Instagram: - = @contact.instagram -%p - %b Public: - = @contact.public - -= link_to 'Edit', edit_admin_conference_contact_path - diff --git a/app/views/admin/emails/_help.html.haml b/app/views/admin/emails/_help.html.haml index 587056ef..66014197 100644 --- a/app/views/admin/emails/_help.html.haml +++ b/app/views/admin/emails/_help.html.haml @@ -51,7 +51,7 @@ -if @conference.call_for_papers.schedule_public %td {schedule_link} %td The link to complete schedule of the conference - - if @conference.make_conference_public + - if @conference.splashpage && @conference.splashpage.public %tr %td {conference_splash_link} %td The link to conference splash page diff --git a/app/views/admin/lodgings/index.html.haml b/app/views/admin/lodgings/index.html.haml index 2141ff2d..7dc8426a 100644 --- a/app/views/admin/lodgings/index.html.haml +++ b/app/views/admin/lodgings/index.html.haml @@ -1,6 +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| - = f.input :include_lodgings_in_splash, hint: 'On setting this true you will enable the lodgings to be displayed on the splash page' = dynamic_association :lodgings, "Lodgings", f = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/admin/registration_periods/_form.html.haml b/app/views/admin/registration_periods/_form.html.haml index a724c7ae..a8dbc9f3 100644 --- a/app/views/admin/registration_periods/_form.html.haml +++ b/app/views/admin/registration_periods/_form.html.haml @@ -4,5 +4,4 @@ = semantic_form_for(@registration_period, url: admin_conference_registration_period_path(@conference.short_title)) do |f| = f.input :start_date, as: :string, input_html: { id: 'registration-period-start-datepicker', readonly: 'readonly' } = f.input :end_date, as: :string, input_html: { id: 'registration-period-end-datepicker', readonly: 'readonly' } - = f.input :description, hint: markdown_hint('This will appear in the Tickets segment of the splash.'), input_html: { rows: 5, data: { provide: 'markdown-editable' } } = f.submit 'Save Registration Period', class: 'btn btn-primary' diff --git a/app/views/admin/registration_periods/show.html.haml b/app/views/admin/registration_periods/show.html.haml index c828a095..bf2e2157 100644 --- a/app/views/admin/registration_periods/show.html.haml +++ b/app/views/admin/registration_periods/show.html.haml @@ -11,11 +11,6 @@ End Date %dd = @registration_period.end_date - %dt - Description - %dd - - if !@conference.registration_period.description.blank? - = markdown(@conference.registration_period.description) - if can? :update, @registration_period = link_to 'Edit', edit_admin_conference_registration_period_path, class: 'btn btn-primary' diff --git a/app/views/admin/splashpages/_form.html.haml b/app/views/admin/splashpages/_form.html.haml new file mode 100644 index 00000000..5585a5f9 --- /dev/null +++ b/app/views/admin/splashpages/_form.html.haml @@ -0,0 +1,27 @@ +%h1 Splashpage +.row + .col-md-8 + = semantic_form_for(@splashpage, url: admin_conference_splashpage_path(@conference.short_title)) do |f| + = f.inputs name: 'Banner' do + = f.input :banner_photo, hint: 'This will be the top most component of the splash. This background cover will contain start_date and end_date of the conference and the description.' + = f.input :banner_description, hint: markdown_hint('This description will be shown at the bottom of the banner photo of the Splashpage.'), input_html: { rows: 5, data: { provide: 'markdown-editable' } } + = f.input :include_banner, label: 'Display banner on the splashpage?' + = f.inputs name: 'Components' do + = f.input :ticket_description, hint: markdown_hint('This will appear in the Tickets segment of the splash.'), input_html: { rows: 5, data: { provide: 'markdown-editable' } } + = f.input :include_tickets, label: 'Display tickets on the splashpage?' + %br + = f.input :sponsor_description, hint: markdown_hint('This will appear in the Sponsors segment of the splash.'), input_html: { rows: 5, data: { provide: 'markdown-editable' } } + = f.input :include_sponsors, label: 'Display sponsors on the splashpage?' + %br + = f.input :registration_description, hint: markdown_hint(''), input_html: { rows: 5, data: { provide: 'markdown-editable' } } + = f.input :include_registrations, label: 'Display the registration period on the splashpage?' + %br + = f.input :lodging_description, hint: markdown_hint('This will appear in the Lodgings segment of the splash.'), input_html: { rows: 5, data: { provide: 'markdown-editable' } } + = f.input :include_lodgings, label: 'Display the lodgings on the splashpage?' + %br + = f.input :include_tracks, label: 'Display tracks on the splashpage?' + = f.input :include_program, label: 'Display program on the splashpage?' + = f.input :include_social_media, label: 'Display social media on the splashpage?' + = f.input :include_venue, label: 'Display venue on the splashpage?' + = f.input :public, label: 'Make splash page public! (Attention: Please do this only after you have finished the configuration of the conference!)' + = f.submit 'Save Splashpage', class: 'btn btn-primary' diff --git a/app/views/admin/splashpages/show.html.haml b/app/views/admin/splashpages/show.html.haml new file mode 100644 index 00000000..2c7addc0 --- /dev/null +++ b/app/views/admin/splashpages/show.html.haml @@ -0,0 +1,113 @@ +%h1 Splashpage +%br +- if @splashpage + .row + .col-md-8 + %dl.dl-horizontal + %dt + Ticket: + %dd + - unless @splashpage.ticket_description.blank? + = markdown(@splashpage.ticket_description) + %dt + Include Tickets: + %dd + - if @splashpage.include_tickets + Yes + - else + No + %dt + Sponsor: + %dd + - unless @splashpage.sponsor_description.blank? + = markdown(@splashpage.sponsor_description) + %dt + Include Sponsors: + %dd + - if @splashpage.include_sponsors + Yes + - else + No + %dt + Registration: + %dd + - unless @splashpage.registration_description.blank? + = markdown(@splashpage.registration_description) + %dt + Include Registrations: + %dd + - if @splashpage.include_registrations + Yes + - else + No + %dt + Lodging: + %dd + - unless @splashpage.lodging_description.blank? + = markdown(@splashpage.lodging_description) + %dt + Include Tracks: + %dd + - if @splashpage.include_tracks + Yes + - else + No + %dt + Include Program: + %dd + - if @splashpage.include_program + Yes + - else + No + %dt + Include Social Media: + %dd + - if @splashpage.include_social_media + Yes + - else + No + %dt + Public + %dd + - if @splashpage.public + Yes + - else + No + + .row.row-flex.row-flex-wrap + .col-md-4 + .thumbnail.flex-col + %h3.text-center + Conference Banner + - if @splashpage.banner_photo? + = image_tag(@splashpage.banner_photo(:large), class: 'img-responsive') + .caption.flex-grow + .caption + %p + %dl.dl-horizontal + %dt + Filename + %dd + = @splashpage.banner_photo_file_name + %dt Description + %dd + - unless @splashpage.banner_description.blank? + = markdown(@splashpage.banner_description) + %dt Included + %dd + - if @splashpage.include_banner + Yes + - else + No + - else + %h4.text-center + Not set! + %br + - if can? :update, @splashpage + = link_to 'Edit', edit_admin_conference_splashpage_path, class: 'btn btn-primary' + - if can? :destroy, @splashpage + = link_to 'Delete', admin_conference_splashpage_path, + method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' +- else + - if can? :create, @conference + = link_to 'Create Splashpage', new_admin_conference_splashpage_path, class: 'btn btn-primary' diff --git a/app/views/admin/sponsors/index.html.haml b/app/views/admin/sponsors/index.html.haml index 84a97c98..bd36c6a9 100644 --- a/app/views/admin/sponsors/index.html.haml +++ b/app/views/admin/sponsors/index.html.haml @@ -1,6 +1,5 @@ .row .col-md-8 = semantic_form_for(@conference, :url => admin_conference_sponsor_path(@conference.short_title, @conference.sponsors)) do |f| - = f.input :include_sponsors_in_splash, hint: 'On setting this true you will enable the sponsors to be displayed on the splash page' = dynamic_association :sponsors, "Sponsors", f = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/admin/tracks/index.html.haml b/app/views/admin/tracks/index.html.haml index c570a549..27bdedde 100644 --- a/app/views/admin/tracks/index.html.haml +++ b/app/views/admin/tracks/index.html.haml @@ -1,6 +1,5 @@ .row .col-md-8 = semantic_form_for(@conference, :url => admin_conference_track_path(@conference.short_title, @conference.tracks)) do |f| - = f.input :include_tracks_in_splash, hint: 'On setting this true you will enable the tracks to be displayed on the splash page' = dynamic_association :tracks, "Tracks", 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 f747bad6..54c8ee70 100644 --- a/app/views/admin/venue/venue_info.html.haml +++ b/app/views/admin/venue/venue_info.html.haml @@ -1,7 +1,6 @@ .row .col-md-8 = semantic_form_for(@venue, :url => admin_conference_venue_update_path(@conference.short_title),:html => {:multipart => true}) do |f| - = f.input :include_venue_in_splash, hint: 'On setting this true you will enable the venue to be displayed on the splash page' = f.input :name, :input_html => {:rows => 1} = f.input :address, :input_html => {:rows => 1} = f.input :website diff --git a/app/views/conference/_lodging.html.haml b/app/views/conference/_lodging.html.haml index ac50fe92..efd0d09c 100644 --- a/app/views/conference/_lodging.html.haml +++ b/app/views/conference/_lodging.html.haml @@ -1,8 +1,8 @@ %div.container.text-center %h2 Lodgings - -unless @conference.lodging_description.blank? + -unless @conference.splashpage.lodging_description.blank? .lead - = markdown(@conference.lodging_description) + = markdown(@conference.splashpage.lodging_description) %div.row.text-center - @conference.venue.lodgings.each do |r| diff --git a/app/views/conference/_program.html.haml b/app/views/conference/_program.html.haml index b69ae782..20468a0d 100644 --- a/app/views/conference/_program.html.haml +++ b/app/views/conference/_program.html.haml @@ -13,6 +13,6 @@ - else %span The schedule is not ready yet. Stay tuned! -unless @conference.tracks.blank? - - if @conference.include_tracks_in_splash? + - if @conference.splashpage.include_tracks = render 'tracks' diff --git a/app/views/conference/_registration.html.haml b/app/views/conference/_registration.html.haml index f9816397..ed536310 100644 --- a/app/views/conference/_registration.html.haml +++ b/app/views/conference/_registration.html.haml @@ -4,9 +4,9 @@ %div.container.text-center %div.row %h1 Registration - - if @conference.registration_period && !@conference.registration_period.description.blank? + - if !@conference.splashpage.registration_description.blank? .lead - = markdown(@conference.registration_period.description) + = markdown(@conference.splashpage.registration_description) - if @conference.registration_dates_given? -if @conference.registration_period.end_date >= Date.today %h4 Registration period #{ date_string(@conference.registration_period.start_date, @conference.registration_period.end_date) } @@ -18,5 +18,5 @@ - else = link_to "Register for #{@conference.short_title}", new_conference_conference_registrations_path(@conference.short_title), class: "btn btn-success btn-lg", target: '_blank' - if @conference.tickets.any? - - if @conference.include_tickets_in_splash? + - if @conference.splashpage.include_tickets = render 'tickets' diff --git a/app/views/conference/_sponsor.html.haml b/app/views/conference/_sponsor.html.haml index 9ad6e262..6ee72f44 100644 --- a/app/views/conference/_sponsor.html.haml +++ b/app/views/conference/_sponsor.html.haml @@ -5,9 +5,9 @@ %div.row %div.col-md-12 %h2 Sponsors - -if !@conference.sponsor_description.blank? + -if !@conference.splashpage.sponsor_description.blank? .lead - = markdown(@conference.sponsor_description) + = markdown(@conference.splashpage.sponsor_description) -if !@conference.sponsor_email.blank? %h3= mail_to "#{ @conference.sponsor_email }", 'Become a Sponsor' - if !@conference.sponsorship_levels.blank? diff --git a/app/views/conference/_tickets.html.haml b/app/views/conference/_tickets.html.haml index 82f17408..b77b9962 100644 --- a/app/views/conference/_tickets.html.haml +++ b/app/views/conference/_tickets.html.haml @@ -1,9 +1,9 @@ %div.row %h3 Tickets - -if @conference.ticket_description.present? + -if @conference.splashpage.ticket_description.present? .lead - = markdown(@conference.ticket_description) - - @conference.tickets.each do |ticket| + = markdown(@conference.splashpage.ticket_description) + - @conference.tickets.each do |s| %div.col-md-6 - if ticket.title.present? %h4 #{ ticket.title } diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index 500feb3c..731616c8 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -1,59 +1,60 @@ = content_for :splash do - .splash - - if @conference.include_banner_in_splash? - %section{ id: 'splash-banner' } - %div.banner-disp{ style: ("background-image: url(#{@conference.banner_photo})" unless @conference.banner_photo.blank?), class:('with-background' unless @conference.banner_photo.blank?) } - %div.container.text-center.banner-text - .row - %h1 - = @conference.title - - if @conference.start_date && @conference.end_date + - if @conference.splashpage + .splash + - if @conference.splashpage.include_banner? + %section{ id: 'splash-banner' } + %div.banner-disp{ style: ("background-image: url(#{@conference.splashpage.banner_photo})" unless @conference.splashpage.banner_photo.blank?), class:('with-background' unless @conference.splashpage.banner_photo.blank?) } + %div.container.text-center.banner-text .row - %h3 - = date_string(@conference.start_date, @conference.end_date) + %h1 + = @conference.title + - if @conference.start_date && @conference.end_date + .row + %h3 + = date_string(@conference.start_date, @conference.end_date) - - unless @conference.description.blank? - .row-fluid - .col-md-12.lead - .lead - = markdown(@conference.description) - -unless @conference.photos.blank? - = link_to 'Gallery', gallery_photos_conference_path(@conference.short_title), class: 'btn btn-primary btn-lg', id: 'gallery-btn', remote: true - = render 'gallery' - - if @conference.include_program_in_splash? - %section{ id: 'program' } - .pad - = render 'program' - - - if @conference.include_registrations_in_splash? - %section{ id: 'registration' } - .pad - = render 'registration' - - - -unless @conference.call_for_papers.blank? - - if @conference.call_for_papers.include_cfp_in_splash? - %section{ id:'callforpapers' } + - unless @conference.splashpage.banner_description.blank? + .row-fluid + .col-md-12.lead + .lead + = markdown(@conference.splashpage.banner_description) + -unless @conference.photos.blank? + = link_to 'Gallery', gallery_photos_conference_path(@conference.short_title), class: 'btn btn-primary btn-lg', id: 'gallery-btn', remote: true + = render 'gallery' + - if @conference.splashpage.include_program + %section{ id: 'program' } .pad - = render 'call_for_papers' + = render 'program' - -unless @conference.venue.blank? - - if @conference.venue.include_venue_in_splash? - %section{ id: 'location' } + - if @conference.splashpage.include_registrations + %section{ id: 'registration' } .pad - = render 'location' - - unless @conference.venue.lodgings.empty? - - if @conference.venue.include_lodgings_in_splash? - = render 'lodging' + = render 'registration' - - if @conference.include_sponsors_in_splash? - %section{ id: 'sponsors' } - .pad - = render 'sponsor' - - if @conference.contact.public? - %section{ id: 'social-media' } - .pad - = render 'social_media' + -unless @conference.call_for_papers.blank? + - if @conference.call_for_papers.include_cfp_in_splash? + %section{ id:'callforpapers' } + .pad + = render 'call_for_papers' - = render 'footer' + -unless @conference.venue.blank? + - if @conference.splashpage.include_venue + %section{ id: 'location' } + .pad + = render 'location' + - unless @conference.venue.lodgings.empty? + - if @conference.splashpage.include_lodgings + = render 'lodging' + + - if @conference.splashpage.include_sponsors + %section{ id: 'sponsors' } + .pad + = render 'sponsor' + + - if @conference.splashpage.include_social_media + %section{ id: 'social-media' } + .pad + = render 'social_media' + + = render 'footer' diff --git a/app/views/home/_conference_details.html.haml b/app/views/home/_conference_details.html.haml index 3188bc9b..e6670eb5 100644 --- a/app/views/home/_conference_details.html.haml +++ b/app/views/home/_conference_details.html.haml @@ -27,7 +27,7 @@ = link_to "Subscribe", subscription_conference_path(conference.short_title), method: "PATCH", class: "btn btn-info btn-group-vertical" - if !@conference || @conference != conference - - if conference.make_conference_public? + - if conference.splashpage && conference.splashpage.public = link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default" - if conference.registration_open? - if conference.user_registered?(current_user) @@ -40,4 +40,4 @@ - elsif conference.cfp_open? = link_to "Submit Proposal", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default" - if !current_user.nil? && conference.tickets.any? - = link_to 'Support', conference_tickets_path(conference.short_title), class: 'btn btn-default' \ No newline at end of file + = link_to 'Support', conference_tickets_path(conference.short_title), class: 'btn btn-default' diff --git a/app/views/layouts/_admin_sidebar.html.haml b/app/views/layouts/_admin_sidebar.html.haml index a9abb5ca..3f3bcc22 100644 --- a/app/views/layouts/_admin_sidebar.html.haml +++ b/app/views/layouts/_admin_sidebar.html.haml @@ -53,6 +53,11 @@ = link_to( admin_conference_registration_period_path (@conference.short_title)) do %span.fa.fa-male Registration Period + - if can? :update, @conference + %li{:class=> active_nav_li( admin_conference_splashpage_path (@conference.short_title))} + = link_to( admin_conference_splashpage_path (@conference.short_title)) do + %span.fa.fa-globe + Splashpage - if can? :update, @conference.events.build %li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))} = link_to(admin_conference_events_path(@conference.short_title)) do diff --git a/config/routes.rb b/config/routes.rb index bdec1b12..3d3b98f3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,6 +32,8 @@ Osem::Application.routes.draw do resource :registration_period + resource :splashpage + resources :difficulty_levels, only: [:show, :update, :index] resources :rooms, only: [:show, :update, :index] diff --git a/db/migrate/20140825091222_create_splashpages.rb b/db/migrate/20140825091222_create_splashpages.rb new file mode 100644 index 00000000..0c9ca9b6 --- /dev/null +++ b/db/migrate/20140825091222_create_splashpages.rb @@ -0,0 +1,30 @@ +class CreateSplashpages < ActiveRecord::Migration + def change + create_table :splashpages do |t| + t.integer :conference_id + + t.boolean :public + t.boolean :include_tracks + t.boolean :include_program + t.boolean :include_social_media + t.boolean :include_banner + t.boolean :include_venue + t.boolean :include_tickets + t.text :ticket_description + t.boolean :include_registrations + t.text :registration_description + t.boolean :include_sponsors + t.text :sponsor_description + t.boolean :include_lodgings + t.text :lodging_description + + t.text :banner_description + t.string :banner_photo_file_name + t.string :banner_photo_content_type + t.integer :banner_photo_file_size + t.datetime :banner_photo_updated_at + + t.timestamps + end + end +end diff --git a/db/migrate/20140825093132_move_splashpage_attributes_from_conference_to_splashpage.rb b/db/migrate/20140825093132_move_splashpage_attributes_from_conference_to_splashpage.rb new file mode 100644 index 00000000..9beac068 --- /dev/null +++ b/db/migrate/20140825093132_move_splashpage_attributes_from_conference_to_splashpage.rb @@ -0,0 +1,89 @@ +class MoveSplashpageAttributesFromConferenceToSplashpage < ActiveRecord::Migration + class TempConference < ActiveRecord::Base + self.table_name = 'conferences' + end + + class TempRegistrationPeriod < ActiveRecord::Base + self.table_name = 'registration_periods' + end + + class TempContact < ActiveRecord::Base + self.table_name = 'contacts' + end + + class TempVenue < ActiveRecord::Base + self.table_name = 'venues' + end + + class TempSplashpage < ActiveRecord::Base + self.table_name = 'splashpages' + attr_accessible :conference_id, :public, :include_registrations, :include_tracks, :include_program, + :include_social_media, :include_banner, :include_tickets, :ticket_description, :include_sponsors, + :sponsor_description, :lodging_description, :banner_photo_file_name, :banner_photo_content_type, + :banner_photo_file_size, :banner_photo_updated_at, :banner_description + end + + def change + # Copy values to splashpage + TempConference.all.each do |conference| + unless TempSplashpage.exists?(conference_id: conference.id) + splash = TempSplashpage.create(conference_id: conference.id, + public: conference.make_conference_public, + include_registrations: conference.include_registrations_in_splash, + include_tracks: conference.include_tracks_in_splash, + include_program: conference.include_program_in_splash, + include_banner: conference.include_banner_in_splash, + include_tickets: conference.include_tickets_in_splash, + ticket_description: conference.ticket_description, + include_sponsors: conference.include_sponsors_in_splash, + sponsor_description: conference.sponsor_description, + lodging_description: conference.lodging_description, + banner_description: conference.description, + banner_photo_file_name: conference.banner_photo_file_name, + banner_photo_content_type: conference.banner_photo_content_type, + banner_photo_file_size: conference.banner_photo_file_size, + banner_photo_updated_at: conference.banner_photo_updated_at) + + contact = TempContact.find_by(conference_id: conference.id) + if contact + splash.include_social_media = contact.public + splash.save + end + + registration = TempRegistrationPeriod.find_by(conference_id: conference.id) + if registration + splash.registration_description = registration.description + splash.save + end + + venue = TempVenue.find_by(id: conference.venue_id) + if venue + splash.include_lodgings = venue.include_lodgings_in_splash + splash.include_venue = venue.include_venue_in_splash + splash.save + end + end + end + + # Remove columns + remove_column :contacts, :public + remove_column :registration_periods, :description + remove_column :venues, :include_lodgings_in_splash + remove_column :venues, :include_venue_in_splash + remove_column :conferences, :ticket_description + remove_column :conferences, :sponsor_description + remove_column :conferences, :lodging_description + remove_column :conferences, :make_conference_public + remove_column :conferences, :include_registrations_in_splash + remove_column :conferences, :include_sponsors_in_splash + remove_column :conferences, :include_tracks_in_splash + remove_column :conferences, :include_tickets_in_splash + remove_column :conferences, :include_program_in_splash + remove_column :conferences, :banner_photo_file_name + remove_column :conferences, :banner_photo_content_type + remove_column :conferences, :banner_photo_file_size + remove_column :conferences, :banner_photo_updated_at + remove_column :conferences, :include_banner_in_splash + remove_column :conferences, :description + end +end diff --git a/db/schema.rb b/db/schema.rb index eed1ea9c..d2451810 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: 20140821103643) do +ActiveRecord::Schema.define(version: 20140825093132) do create_table "ahoy_events", force: true do |t| t.uuid "visit_id" @@ -105,22 +105,7 @@ ActiveRecord::Schema.define(version: 20140821103643) do t.boolean "use_difficulty_levels", default: false t.boolean "use_volunteers" t.string "color" - t.text "description" - t.text "ticket_description" - t.text "sponsor_description" t.string "sponsor_email" - t.text "lodging_description" - t.boolean "include_registrations_in_splash", default: false - t.boolean "include_sponsors_in_splash", default: false - t.boolean "include_tracks_in_splash", default: false - t.boolean "include_tickets_in_splash", default: false - t.boolean "include_program_in_splash", default: false - t.boolean "make_conference_public", default: false - t.string "banner_photo_file_name" - t.string "banner_photo_content_type" - t.integer "banner_photo_file_size" - t.datetime "banner_photo_updated_at" - t.boolean "include_banner_in_splash", default: false t.text "events_per_week" end @@ -136,7 +121,6 @@ ActiveRecord::Schema.define(version: 20140821103643) do t.string "googleplus" t.string "twitter" t.string "instagram" - t.boolean "public" t.integer "conference_id" t.datetime "created_at" t.datetime "updated_at" @@ -332,7 +316,6 @@ ActiveRecord::Schema.define(version: 20140821103643) do t.integer "conference_id" t.date "start_date" t.date "end_date" - t.text "description" t.datetime "created_at" t.datetime "updated_at" end @@ -400,6 +383,31 @@ ActiveRecord::Schema.define(version: 20140821103643) do t.date "date" end + create_table "splashpages", force: true do |t| + t.integer "conference_id" + t.boolean "public" + t.boolean "include_tracks" + t.boolean "include_program" + t.boolean "include_social_media" + t.boolean "include_banner" + t.boolean "include_venue" + t.boolean "include_tickets" + t.text "ticket_description" + t.boolean "include_registrations" + t.text "registration_description" + t.boolean "include_sponsors" + t.text "sponsor_description" + t.boolean "include_lodgings" + t.text "lodging_description" + t.text "banner_description" + t.string "banner_photo_file_name" + t.string "banner_photo_content_type" + t.integer "banner_photo_file_size" + t.datetime "banner_photo_updated_at" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "sponsors", force: true do |t| t.string "name" t.text "description" @@ -529,8 +537,6 @@ ActiveRecord::Schema.define(version: 20140821103643) do t.string "photo_content_type" t.integer "photo_file_size" t.datetime "photo_updated_at" - t.boolean "include_venue_in_splash", default: false - t.boolean "include_lodgings_in_splash", default: false end create_table "versions", force: true do |t| diff --git a/spec/controllers/admin/registration_periods_controller_spec.rb b/spec/controllers/admin/registration_periods_controller_spec.rb index 53d6be38..a95064e0 100644 --- a/spec/controllers/admin/registration_periods_controller_spec.rb +++ b/spec/controllers/admin/registration_periods_controller_spec.rb @@ -21,21 +21,21 @@ describe Admin::RegistrationPeriodsController do context 'valid attributes' do - it 'locates the requested audience object' do + it 'locates the requested registration period object' do patch :update, conference_id: conference.short_title, conference: attributes_for(:registration_period) expect(assigns(:registration_period)).to eq(conference.registration_period) end - it 'changes audience attributes' do + it 'changes registration period attributes' do + the_date = 10.days.from_now.to_date patch :update, conference_id: conference.short_title, registration_period: - attributes_for(:registration_period, - description: 'Test') + attributes_for(:registration_period, start_date: the_date) conference.reload - expect(conference.registration_period.description).to eq('Test') + expect(conference.registration_period.start_date.to_s).to eq(the_date.to_s) end - it 'redirects to the updated conference' do + it 'redirects to the updated registration period' do patch :update, conference_id: conference.short_title, registration_period: attributes_for(:registration_period) conference.reload @@ -83,7 +83,7 @@ describe Admin::RegistrationPeriodsController do end context 'with invalid attributes' do - it 'does not save the conference to the database' do + it 'does not save the registration period to the database' do expected = expect do post :create, conference_id: conference.short_title, @@ -106,7 +106,7 @@ describe Admin::RegistrationPeriodsController do end describe 'GET #edit' do - it 'assigns the requested conference to conference' do + it 'assigns the requested registration period to @registration_period' do get :edit, conference_id: conference.short_title expect(assigns(:registration_period)).to eq conference.registration_period end @@ -118,7 +118,7 @@ describe Admin::RegistrationPeriodsController do end describe 'GET #show' do - it 'assigns the requested registration period to registration period' do + it 'assigns the requested registration period to @registration_period' do get :show, conference_id: conference.short_title expect(assigns(:registration_period)).to eq conference.registration_period end @@ -130,7 +130,7 @@ describe Admin::RegistrationPeriodsController do end describe 'GET #new' do - it 'assigns a new conference to conference' do + it 'assigns a new registration period to @registration_period' do get :new, conference_id: conference.short_title expect(assigns(:registration_period)).to be_a_new(RegistrationPeriod) end diff --git a/spec/controllers/conference_controller_spec.rb b/spec/controllers/conference_controller_spec.rb index 90747dd3..b30cdcba 100644 --- a/spec/controllers/conference_controller_spec.rb +++ b/spec/controllers/conference_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe ConferenceController do - let(:conference) { create(:conference, make_conference_public: true) } + let(:conference) { create(:conference, splashpage: create(:splashpage, public: true)) } describe 'GET #show' do context 'conference made public' do @@ -15,19 +15,7 @@ describe ConferenceController do expect(response).to render_template :show end end - context 'conference is not public' do - before(:each) { conference.update_attribute(:make_conference_public, false) } - it 'redirects to root path' do - get :show, id: conference.short_title - expect(response).to redirect_to root_path - end - - it 'renders flash saying conference not ready' do - get :show, id: conference.short_title - expect(flash[:alert]).to eq('You are not authorized to access this page.') - end - end context 'gallery photos for splash' do it 'return conference photos' do xhr :get, :gallery_photos, id: conference.short_title diff --git a/spec/factories/conferences.rb b/spec/factories/conferences.rb index 97f7348e..349b1ad4 100644 --- a/spec/factories/conferences.rb +++ b/spec/factories/conferences.rb @@ -7,7 +7,6 @@ FactoryGirl.define do timezone 'Amsterdam' start_date { Date.today } end_date { 6.days.from_now } - make_conference_public true venue end end diff --git a/spec/factories/registration_periods.rb b/spec/factories/registration_periods.rb index afd2e9ad..e8cd96f9 100644 --- a/spec/factories/registration_periods.rb +++ b/spec/factories/registration_periods.rb @@ -4,6 +4,5 @@ FactoryGirl.define do factory :registration_period do start_date { 3.days.from_now } end_date { 5.days.from_now } - description 'Lorem ipsum dolorem ...' end end diff --git a/spec/factories/splashpages.rb b/spec/factories/splashpages.rb new file mode 100644 index 00000000..92c46960 --- /dev/null +++ b/spec/factories/splashpages.rb @@ -0,0 +1,7 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :splashpage do + public true + end +end diff --git a/spec/features/registration_periods_spec.rb b/spec/features/registration_periods_spec.rb index c904a33f..e26b6dd2 100644 --- a/spec/features/registration_periods_spec.rb +++ b/spec/features/registration_periods_spec.rb @@ -14,7 +14,6 @@ feature RegistrationPeriod do conference_id: conference.short_title) click_link 'New Registration Period' - fill_in 'registration_period_description', with: 'The description' click_button 'Save Registration Period' expect(flash). @@ -37,7 +36,6 @@ feature RegistrationPeriod do registration_period.reload expect(registration_period.start_date).to eq(Date.today) expect(registration_period.end_date).to eq(Date.today + 7) - expect(registration_period.description).to eq('The description') end end diff --git a/spec/features/splashpage_spec.rb b/spec/features/splashpage_spec.rb new file mode 100644 index 00000000..f6f7ffc4 --- /dev/null +++ b/spec/features/splashpage_spec.rb @@ -0,0 +1,94 @@ +require 'spec_helper' + +feature Splashpage do + + # It is necessary to use bang version of let to build roles before user + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) } + let!(:participant) { create(:user, biography: '') } + + scenario 'create a valid splashpage', js: true do + sign_in organizer + visit admin_conference_splashpage_path(conference.short_title) + + click_link 'Create Splashpage' + + fill_in 'splashpage_banner_description', with: 'banner description' + fill_in 'splashpage_ticket_description', with: 'ticket description' + fill_in 'splashpage_sponsor_description', with: 'sponsor description' + fill_in 'splashpage_registration_description', with: 'registration description' + fill_in 'splashpage_lodging_description', with: 'lodging description' + + click_button 'Save Splashpage' + + expect(flash).to eq('Splashpage successfully created.') + expect(current_path).to eq(admin_conference_splashpage_path(conference.short_title)) + + splashpage = Splashpage.find_by(conference_id: conference.id) + splashpage.reload + expect(splashpage.banner_description).to eq('banner description') + expect(splashpage.ticket_description).to eq('ticket description') + expect(splashpage.sponsor_description).to eq('sponsor description') + expect(splashpage.registration_description).to eq('registration description') + expect(splashpage.lodging_description).to eq('lodging description') + end + + context 'splashpage already created' do + # before(:each) do + # @splashpage = create(:splashpage) + # conference.splashpage = @splashpage + # end + # + let!(:splashpage) { create(:splashpage, conference: conference, public: false)} + + scenario 'update a valid splashpage', js: true do + sign_in organizer + visit admin_conference_splashpage_path(conference.short_title) + + click_link 'Edit' + + fill_in 'splashpage_banner_description', with: 'banner description' + fill_in 'splashpage_ticket_description', with: 'ticket description' + fill_in 'splashpage_sponsor_description', with: 'sponsor description' + fill_in 'splashpage_registration_description', with: 'registration description' + fill_in 'splashpage_lodging_description', with: 'lodging description' + + click_button 'Save Splashpage' + + expect(flash).to eq('Splashpage successfully updated.') + expect(current_path).to eq(admin_conference_splashpage_path(conference.short_title)) + + splashpage.reload + expect(splashpage.banner_description).to eq('banner description') + expect(splashpage.ticket_description).to eq('ticket description') + expect(splashpage.sponsor_description).to eq('sponsor description') + expect(splashpage.registration_description).to eq('registration description') + expect(splashpage.lodging_description).to eq('lodging description') + end + + scenario 'delete the splashpage', js: true do + sign_in organizer + visit admin_conference_splashpage_path(conference.short_title) + click_link 'Delete' + + expect(current_path).to eq(admin_conference_splashpage_path(conference.short_title)) + expect(flash).to eq('Splashpage was successfully destroyed.') + expect(Splashpage.count).to eq(0) + end + + scenario 'splashpage is accessible for organizers if it is not public' do + sign_in organizer + visit conference_path(conference.short_title) + expect(current_path).to eq(conference_path(conference.short_title)) + end + + scenario 'splashpage is not accessible for participants if it is not public' do + sign_in participant + visit conference_path(conference.short_title) + + expect(flash).to eq('You are not authorized to access this page.') + expect(current_path).to eq(root_path) + end + end +end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index a95613ba..161ee60e 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -6,8 +6,8 @@ describe 'User' do subject(:ability){ Ability.new(user) } let!(:first_user) { create(:user) } # automatically becomes admin let(:user){ nil } - let(:conference_not_public) { create(:conference, make_conference_public: false) } - let(:conference_public) { create(:conference, make_conference_public: true)} + let(:conference_not_public) { create(:conference, splashpage: create(:splashpage, public: false)) } + let(:conference_public) { create(:conference, splashpage: create(:splashpage, public: true)) } let(:event_confirmed) { create(:event, state: 'confirmed') } let(:someevent) { create(:event) } @@ -113,8 +113,8 @@ describe 'User' do let!(:conference2) { create(:conference) } # user is cfp let!(:conference3) { create(:conference) } # user is info_desk let!(:conference4) { create(:conference) } # user is volunteer coordinator - let!(:conference5) { create(:conference, make_conference_public: true) } # user has no role - let!(:conference6) { create(:conference, make_conference_public: false) } # user has no role + let!(:conference5) { create(:conference, splashpage: create(:splashpage, public: true)) } # user has no role + let!(:conference6) { create(:conference, splashpage: create(:splashpage, public: false)) } # user has no role let(:role_organizer) { create(:role, name: 'organizer', resource: conference1) } let(:role_cfp) { create(:role, name: 'cfp', resource: conference2) } let(:role_info_desk) { create(:role, name: 'info_desk', resource: conference3) } diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb index 9015ee61..3cdfc183 100644 --- a/spec/models/conference_spec.rb +++ b/spec/models/conference_spec.rb @@ -952,7 +952,7 @@ describe Conference do @result['tracks'] = true @result['event_types'] = true @result['difficulty_levels'] = true - @result['make_conference_public'] = true + @result['splashpage'] = true # Setup negative result hash @result_false = Hash.new @@ -970,7 +970,7 @@ describe Conference do subject.tracks = [] subject.event_types = [] subject.difficulty_levels = [] - subject.make_conference_public = false + subject.splashpage = create(:splashpage, public: false) expect(subject.get_status).to eq(@result_false) end @@ -984,7 +984,7 @@ describe Conference do subject.tracks = [] subject.event_types = [] subject.difficulty_levels = [] - subject.make_conference_public = false + subject.splashpage = create(:splashpage, public: false) @result_false['registration'] = true @result_false['process'] = 13.to_s @@ -1001,7 +1001,7 @@ describe Conference do subject.tracks = [] subject.event_types = [] subject.difficulty_levels = [] - subject.make_conference_public = false + subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @result_false['registration'] = true @@ -1020,7 +1020,7 @@ describe Conference do subject.tracks = [] subject.event_types = [] subject.difficulty_levels = [] - subject.make_conference_public = false + subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @result_false['registration'] = true @@ -1040,7 +1040,7 @@ describe Conference do subject.tracks = [] subject.event_types = [] subject.difficulty_levels = [] - subject.make_conference_public = false + subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @result_false['registration'] = true @@ -1061,7 +1061,7 @@ describe Conference do subject.venue = create(:venue) subject.event_types = [] subject.difficulty_levels = [] - subject.make_conference_public = false + subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @result_false['registration'] = true @@ -1084,7 +1084,7 @@ describe Conference do subject.call_for_papers = create(:call_for_papers) subject.venue = create(:venue) subject.difficulty_levels = [] - subject.make_conference_public = false + subject.splashpage = create(:splashpage, public: false) @result_false['cfp'] = true @result_false['registration'] = true @@ -1108,7 +1108,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 + subject.splashpage = create(:splashpage, public: true) expect(subject.get_status).to eq(@result) end diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index ec41e7a9..6c60ca70 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -3,23 +3,26 @@ describe 'conference/show.html.haml' do before(:each) do allow(view).to receive(:date_string).and_return("January 17 - 21 2014") @conference = create(:conference, - description: 'Lorem Ipsum', - sponsor_description: 'Lorem Ipsum Dolor', - sponsor_email: 'example@example.com', - include_registrations_in_splash: true, - include_program_in_splash: true, - include_sponsors_in_splash: true, - include_tracks_in_splash: true, - include_tickets_in_splash: true, - include_banner_in_splash: true) + sponsor_email: 'example@example.com') + + @conference.splashpage = create(:splashpage, + banner_description: 'Lorem Ipsum', + sponsor_description: 'Lorem Ipsum Dolor', + registration_description: 'Lorem Ipsum Dolor', + include_registrations: true, + include_program: true, + include_sponsors: true, + include_tracks: true, + include_tickets: true, + include_banner: true, + include_social_media: true, + include_venue: true, + include_lodgings: true) @conference.contact.update(facebook: 'http://www.fbexample.com', googleplus: 'http://www.google-example.com', instagram: 'http://instagram.com', - twitter: 'http://twitter.com', - public: true - ) + twitter: 'http://twitter.com') @conference.registration_period = create(:registration_period, - description: 'Lorem Ipsum Dolor', start_date: Date.today, end_date: Date.tomorrow) @conference.call_for_papers = create(:call_for_papers, conference: @conference, @@ -30,15 +33,14 @@ describe 'conference/show.html.haml' do @sponsorship_level = @conference.sponsorship_levels.first @sponsorship_level.sponsors << create(:sponsor, sponsorship_level: @sponsorship_level, conference: @conference) - @conference.venue = create(:venue, include_venue_in_splash: true, - include_lodgings_in_splash: true) + @conference.venue = create(:venue) @conference.venue.lodgings << create(:lodging, venue: @conference.venue) assign :conference, @conference render end it 'renders banner component' do - expect(view.content_for(:splash)).to include("#{@conference.description}") + expect(view.content_for(:splash)).to include("#{@conference.splashpage.banner_description}") expect(view.content_for(:splash)).to include("#{@conference.short_title}") end @@ -47,7 +49,7 @@ describe 'conference/show.html.haml' do end it 'renders registration partial' do - expect(view.content_for(:splash)).to include("#{@conference.registration_period.description}") + expect(view.content_for(:splash)).to include("#{@conference.splashpage.registration_description}") expect(view).to render_template(partial: 'conference/_registration') end