From ecfc348ea8deec0c64178f3f92cd82d9b828a81e Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Mon, 8 Dec 2014 18:08:21 +0200 Subject: [PATCH] add highlights and fix cfp in splashpage --- app/controllers/admin/events_controller.rb | 3 ++ app/controllers/conference_controller.rb | 4 +- app/models/conference.rb | 8 ++-- app/models/splashpage.rb | 2 +- .../admin/call_for_papers/_form.html.haml | 1 - .../admin/call_for_papers/show.html.haml | 7 --- app/views/admin/event_types/index.html.haml | 2 +- app/views/admin/events/_proposal.html.haml | 13 ++++++ app/views/admin/splashpages/_form.html.haml | 1 + app/views/admin/splashpages/show.html.haml | 9 +++- app/views/conference/_program.html.haml | 17 ++++++- app/views/conference/show.html.haml | 4 +- app/views/proposal/_proposal_form.html.haml | 4 +- ...141127161313_add_is_highlight_in_events.rb | 5 ++ ...de_cfp_in_splash_add_column_include_cfp.rb | 46 +++++++++++++++++++ db/schema.rb | 11 +++-- spec/views/conference/show.html.haml_spec.rb | 6 +-- 17 files changed, 111 insertions(+), 32 deletions(-) create mode 100644 db/migrate/20141127161313_add_is_highlight_in_events.rb create mode 100644 db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index 1b534f33..9da0ae7e 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -113,6 +113,9 @@ module Admin if params.has_key? :difficulty_level_id @event.update_attribute(:difficulty_level_id, params[:difficulty_level_id]) end + if params.has_key? :is_highlight + @event.update_attribute(:is_highlight, params[:is_highlight]) + end if @event.submitter.update_attributes!(params[:user]) && @event. update_attributes!(params[:event]) diff --git a/app/controllers/conference_controller.rb b/app/controllers/conference_controller.rb index feaa2a0e..3ba355fd 100644 --- a/app/controllers/conference_controller.rb +++ b/app/controllers/conference_controller.rb @@ -7,9 +7,7 @@ class ConferenceController < ApplicationController @antiquated = @conferences - @current end - def show - @keynote_speakers = @conference.keynote_speakers - end + def show; end def schedule @rooms = @conference.rooms diff --git a/app/models/conference.rb b/app/models/conference.rb index 5c1ae0c2..724c2499 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -43,6 +43,10 @@ class Conference < ActiveRecord::Base def confirmed where(state: :confirmed) end + + def highlights + where(is_highlight: true) + end end has_many :event_users, through: :events has_many :speakers, -> { distinct }, through: :event_users, source: :user do @@ -559,10 +563,6 @@ class Conference < ActiveRecord::Base email_settings.updated_conference_registration_dates_template end - def keynote_speakers - User.with_role(:keynote_speaker, self) - end - private after_create do diff --git a/app/models/splashpage.rb b/app/models/splashpage.rb index e414f75b..07fbb5cc 100644 --- a/app/models/splashpage.rb +++ b/app/models/splashpage.rb @@ -1,7 +1,7 @@ class Splashpage < ActiveRecord::Base belongs_to :conference attr_accessible :public, - :include_tracks, :include_program, + :include_tracks, :include_program, :include_cfp, :include_venue, :include_registrations, :include_tickets, :include_lodgings, :include_sponsors, :include_social_media diff --git a/app/views/admin/call_for_papers/_form.html.haml b/app/views/admin/call_for_papers/_form.html.haml index 11f6476d..f18e6a07 100644 --- a/app/views/admin/call_for_papers/_form.html.haml +++ b/app/views/admin/call_for_papers/_form.html.haml @@ -7,7 +7,6 @@ = semantic_form_for(@call_for_paper, :url => admin_conference_call_for_paper_path(@conference.short_title),:html => {:multipart => true}) do |f| = 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.input :include_cfp_in_splash, label: "Show Call for Papers on the splash page" = f.input :schedule_public, label: "Show Schedule on the home and splash page" = f.input :schedule_changes, label: "Allow submitters to change their event after it is scheduled" = f.input :rating, :hint => "Enter the number of different rating levels you want to have for voting on proposals. Enter 0 if you do not want to vote on proposals." diff --git a/app/views/admin/call_for_papers/show.html.haml b/app/views/admin/call_for_papers/show.html.haml index 01322c75..3857e58d 100644 --- a/app/views/admin/call_for_papers/show.html.haml +++ b/app/views/admin/call_for_papers/show.html.haml @@ -29,13 +29,6 @@ Tracks: %dd = tracks(@conference) - %dt - Public - %dd#cfp_in_splash - - if @call_for_paper.include_cfp_in_splash - True - - else - False %dt Public Schedule %dd#schedule_public diff --git a/app/views/admin/event_types/index.html.haml b/app/views/admin/event_types/index.html.haml index 6a9326a1..fddc2dd3 100644 --- a/app/views/admin/event_types/index.html.haml +++ b/app/views/admin/event_types/index.html.haml @@ -22,7 +22,7 @@ = event_type.length Minutes %td - = "#{event_type.minimum_abstract_length}:#{event_type.maximum_abstract_length}" + = "#{event_type.minimum_abstract_length} - #{event_type.maximum_abstract_length}" Words %td %span.label{style: "background-color: #{event_type.color};"} diff --git a/app/views/admin/events/_proposal.html.haml b/app/views/admin/events/_proposal.html.haml index d4f9a2c1..fdf17ba7 100644 --- a/app/views/admin/events/_proposal.html.haml +++ b/app/views/admin/events/_proposal.html.haml @@ -25,6 +25,19 @@ - @event_types.each do |type| %li= link_to type.title, admin_conference_event_path(@conference.short_title, @event, :event_type_id => type.id) , :method => :put, :event_type_id => type.id + %tr + %td + %b Highlight + %td + = link_to "#{@event.is_highlight}".capitalize, + admin_conference_event_path(@conference.short_title, + @event, + is_highlight: !@event.is_highlight), + method: :put, is_highlight: !@event.is_highlight + - if @event.is_highlight + (the event is as a highlight and will appear in the splashpage) + - else + (mark as true to make the event a highlight that appears in the splashpage) %tr %td %b State diff --git a/app/views/admin/splashpages/_form.html.haml b/app/views/admin/splashpages/_form.html.haml index 59babd14..38335b31 100644 --- a/app/views/admin/splashpages/_form.html.haml +++ b/app/views/admin/splashpages/_form.html.haml @@ -8,6 +8,7 @@ = f.inputs name: 'Components' do = f.input :include_tracks, label: 'Display tracks on the splashpage?' = f.input :include_program, label: 'Display program on the splashpage?' + = f.input :include_cfp, label: 'Display call for papers information on splashpage, while cfp is open?' = f.input :include_venue, label: 'Display venue on the splashpage?' = f.input :include_registrations, label: 'Display the registration period on the splashpage?' = f.input :include_tickets, label: 'Display tickets on the splashpage?' diff --git a/app/views/admin/splashpages/show.html.haml b/app/views/admin/splashpages/show.html.haml index cd26a461..ae340cad 100644 --- a/app/views/admin/splashpages/show.html.haml +++ b/app/views/admin/splashpages/show.html.haml @@ -3,7 +3,7 @@ .page-header %h1 Splashpage %p.text-muted - Build a + Build a = link_to "splash page", conference_path(@conference.short_title) with all the information for your conference - if @splashpage @@ -45,6 +45,13 @@ Yes - else No + %dt + Include CFP: + %dd + - if @splashpage.include_cfp + Yes + - else + No %dt Include Social Media: %dd diff --git a/app/views/conference/_program.html.haml b/app/views/conference/_program.html.haml index 40e5db13..b4c6eab1 100644 --- a/app/views/conference/_program.html.haml +++ b/app/views/conference/_program.html.haml @@ -24,9 +24,22 @@ = link_to(schedule_conference_path(@conference.short_title), class: 'btn btn-default btn-lg') do Full Schedule - - #FIXME: Display keynotes https://github.com/openSUSE/osem/issues/544 - - #FIXME: Display schedule highlights https://github.com/openSUSE/osem/issues/545 + %h3.text-center + Don't miss out! + %br + - if @conference.events.highlights.any? + .row + .col-md-12 + - @conference.events.highlights.each_slice(2) do |slice| + .row.row-centered + - slice.each do |event| + .col-md-6.col-centered.col-top.highlights + %p.text-center + %b= event.title + %h5.text-center + = simple_format truncate(event.abstract, length: 500, separator: ' ') + = link_to "Read More", conference_proposal_path(@conference.short_title, event) = content_for :splash_nav do %li diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index ea9af0ee..e4354598 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -33,7 +33,7 @@ %section#program = render 'program' - - if @conference.cfp_open? and @conference.call_for_paper.include_cfp_in_splash? + - if @conference.cfp_open? and @conference.splashpage.include_cfp %section#callforpapers = render 'call_for_paper' @@ -53,7 +53,7 @@ %section#sponsors = render 'sponsors' - - if @conference.splashpage.include_social_media and @conference.contact.has_social_media? + - if @conference.contact.has_social_media? and @conference.splashpage.include_social_media %section#social-media = render 'social_media' diff --git a/app/views/proposal/_proposal_form.html.haml b/app/views/proposal/_proposal_form.html.haml index 1d46f079..6ad68fa2 100644 --- a/app/views/proposal/_proposal_form.html.haml +++ b/app/views/proposal/_proposal_form.html.haml @@ -11,8 +11,8 @@ %section#details - if can? :update, @event or can? :create, @event = f.input :event_type_id, as: :select, - collection: @conference.event_types.map {|x| ["#{x.title} - #{show_time(x.length)}", x.id, - data: { min_words: x.minimum_abstract_length, max_words: x.maximum_abstract_length }]}, + collection: @conference.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, + data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length }]}, include_blank: false, label: 'Session Type' - else Event type: #{@event.event_type.title} diff --git a/db/migrate/20141127161313_add_is_highlight_in_events.rb b/db/migrate/20141127161313_add_is_highlight_in_events.rb new file mode 100644 index 00000000..0b61ef26 --- /dev/null +++ b/db/migrate/20141127161313_add_is_highlight_in_events.rb @@ -0,0 +1,5 @@ +class AddIsHighlightInEvents < ActiveRecord::Migration + def change + add_column :events, :is_highlight, :boolean, default: false + end +end diff --git a/db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb b/db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb new file mode 100644 index 00000000..037cb077 --- /dev/null +++ b/db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb @@ -0,0 +1,46 @@ +class MigrateDataRemoveColumnIncludeCfpInSplashAddColumnIncludeCfp < ActiveRecord::Migration + class TempConference < ActiveRecord::Base + self.table_name = 'conferences' + end + + class TempCallForPaper< ActiveRecord::Base + self.table_name = 'call_for_papers' + end + + class TempSplashpage < ActiveRecord::Base + self.table_name = 'splashpages' + attr_accessible :conference_id + end + + def up + add_column :splashpages, :include_cfp, :boolean, default: false + + TempConference.all.each do |conference| + cfp = TempCallForPaper.find_by(conference_id: conference.id) + + if cfp && cfp.include_cfp_in_splash + splashpage = TempSplashpage.find_or_initialize_by(conference_id: conference.id) + splashpage.include_cfp = cfp.include_cfp_in_splash # true + splashpage.save! + end + end + + remove_column :call_for_papers, :include_cfp_in_splash, :boolean, default: false + end + + def down + add_column :call_for_papers, :include_cfp_in_splash, :boolean, default: false + + TempConference.all.each do |conference| + splashpage = TempSplashpage.find_by(conference_id: conference.id) + cfp = TempCallForPaper.find_by(conference_id: conference.id) + + if splashpage && cfp + cfp.include_cfp_in_splash = splashpage.include_cfp + cfp.save! + end + end + + remove_column :splashpages, :include_cfp, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 065acd24..7c94011c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -32,15 +32,14 @@ ActiveRecord::Schema.define(version: 20141130182139) do end create_table "call_for_papers", force: true do |t| - 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 "conference_id" t.datetime "created_at" t.datetime "updated_at" - t.boolean "schedule_changes", default: false - t.integer "rating", default: 3 + t.boolean "schedule_changes", default: false + t.integer "rating", default: 3 t.boolean "schedule_public" - t.boolean "include_cfp_in_splash", default: false end create_table "campaigns", force: true do |t| @@ -234,6 +233,7 @@ ActiveRecord::Schema.define(version: 20141130182139) do t.boolean "require_registration" t.integer "difficulty_level_id" t.integer "week" + t.boolean "is_highlight", default: false end create_table "events_registrations", id: false, force: true do |t| @@ -378,6 +378,7 @@ ActiveRecord::Schema.define(version: 20141130182139) do t.boolean "include_lodgings" t.datetime "created_at" t.datetime "updated_at" + t.boolean "include_cfp", default: false end create_table "sponsors", force: true do |t| diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index 39003be6..c70c32cf 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -12,7 +12,8 @@ describe 'conference/show.html.haml' do include_tickets: true, include_social_media: true, include_venue: true, - include_lodgings: true) + include_lodgings: true, + include_cfp: true) @conference.contact.update(sponsor_email: 'example@example.com', facebook: 'http://facebook.com', @@ -24,8 +25,7 @@ describe 'conference/show.html.haml' do start_date: Date.yesterday, end_date: Date.tomorrow) - @conference.call_for_paper = create(:call_for_paper, conference: @conference, - include_cfp_in_splash: true) + @conference.call_for_paper = create(:call_for_paper, conference: @conference) @conference.sponsorship_levels << create(:sponsorship_level, conference: @conference) @sponsorship_level = @conference.sponsorship_levels.first