From ed8a71e55442659bc88c8f1169801a0aa3f0012e Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Thu, 27 Nov 2014 20:40:26 +0200 Subject: [PATCH 01/17] Splaspage: Add highlights. Fix cfp inclusion. --- app/models/conference.rb | 8 ++++++++ app/models/splashpage.rb | 2 +- app/views/admin/call_for_papers/_form.html.haml | 1 - app/views/admin/call_for_papers/show.html.haml | 7 ------- 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 ++-- ...20141127161313_add_is_highlight_in_events.rb | 5 +++++ ...ove_column_include_cfp_in_splash_from_cfp.rb | 5 +++++ ...1127163536_add_include_cfp_in_splashpages.rb | 5 +++++ db/schema.rb | 15 ++++++++------- spec/views/conference/show.html.haml_spec.rb | 6 +++--- 13 files changed, 61 insertions(+), 24 deletions(-) create mode 100644 db/migrate/20141127161313_add_is_highlight_in_events.rb create mode 100644 db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb create mode 100644 db/migrate/20141127163536_add_include_cfp_in_splashpages.rb diff --git a/app/models/conference.rb b/app/models/conference.rb index f79d9678..14e0a6e4 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -562,6 +562,14 @@ class Conference < ActiveRecord::Base User.with_role(:keynote_speaker, self) end + ## + # + # ====Returns + # * +Array+ -> Events with attribute 'is_highlight' + def highlights + events.where(is_highlight: true) + 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/splashpages/_form.html.haml b/app/views/admin/splashpages/_form.html.haml index 59babd14..656aa0e0 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 CfP 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 f352528d..288d83f7 100644 --- a/app/views/conference/_program.html.haml +++ b/app/views/conference/_program.html.haml @@ -24,9 +24,22 @@ = link_to(conference_schedule_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 + - #FIXME: Display keynotes https://github.com/openSUSE/osem/issues/544 + %h3.text-center + Don't miss out! + - if @conference.highlights.any? + .row + .col-md-12 + - @conference.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 4cc793d2..6fe65c71 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/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/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb b/db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb new file mode 100644 index 00000000..4f3519df --- /dev/null +++ b/db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb @@ -0,0 +1,5 @@ +class RemoveColumnIncludeCfpInSplashFromCfp < ActiveRecord::Migration + def change + remove_column :call_for_papers, :include_cfp_in_splash, :boolean, default: false + end +end diff --git a/db/migrate/20141127163536_add_include_cfp_in_splashpages.rb b/db/migrate/20141127163536_add_include_cfp_in_splashpages.rb new file mode 100644 index 00000000..d2e7c0d3 --- /dev/null +++ b/db/migrate/20141127163536_add_include_cfp_in_splashpages.rb @@ -0,0 +1,5 @@ +class AddIncludeCfpInSplashpages < ActiveRecord::Migration + def change + add_column :splashpages, :include_cfp, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 065acd24..b72a5ce2 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| @@ -334,11 +334,11 @@ ActiveRecord::Schema.define(version: 20141130182139) do create_table "roles", force: true do |t| t.string "name" - t.datetime "created_at" - t.datetime "updated_at" t.string "description" t.integer "resource_id" t.string "resource_type" + t.datetime "created_at" + t.datetime "updated_at" end add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id" @@ -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 From 2511a7dd512a39d9cd1d20d876d2811d2243c43a Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Thu, 27 Nov 2014 21:33:13 +0200 Subject: [PATCH 02/17] add event_type keynote --- app/controllers/conference_controller.rb | 4 +--- app/models/conference.rb | 7 +++++-- app/views/admin/event_types/index.html.haml | 2 +- app/views/conference/_program.html.haml | 19 ++++++++++++++++++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/controllers/conference_controller.rb b/app/controllers/conference_controller.rb index 969b77dd..d82ec310 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 gallery_photos @photos = @conference.photos diff --git a/app/models/conference.rb b/app/models/conference.rb index 14e0a6e4..1f6088fd 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -558,8 +558,8 @@ class Conference < ActiveRecord::Base email_settings.updated_conference_registration_dates_template end - def keynote_speakers - User.with_role(:keynote_speaker, self) + def keynotes + events.where(state: 'confirmed').select { |e| e.event_type.title == 'Keynote'} end ## @@ -902,6 +902,9 @@ class Conference < ActiveRecord::Base event_types << EventType.create(title: 'Workshop', length: 60, color: '#0000FF', minimum_abstract_length: 0, maximum_abstract_length: 500) + event_types << EventType.create(title: 'Keynote', length: 60, color: '#00FF00', + minimum_abstract_length: 0, + maximum_abstract_length: 500) true end 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/conference/_program.html.haml b/app/views/conference/_program.html.haml index 288d83f7..95868464 100644 --- a/app/views/conference/_program.html.haml +++ b/app/views/conference/_program.html.haml @@ -24,10 +24,27 @@ = link_to(conference_schedule_path(@conference.short_title), class: 'btn btn-default btn-lg') do Full Schedule - - #FIXME: Display keynotes https://github.com/openSUSE/osem/issues/544 + - if @conference.keynotes.any? + .row + .col-md12 + %h3.text-center + Keynote Talks! + .row + .col-md-12 + - @conference.keynotes.each_slice(3) do |slice| + .row.row-centered + - slice.each do |event| + .col-md-6.col-centered + .thumbnail + %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) %h3.text-center Don't miss out! + %br - if @conference.highlights.any? .row .col-md-12 From 5d444143eaa558d1cfb1410af15ebd48c4c442cb Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Thu, 27 Nov 2014 21:59:41 +0200 Subject: [PATCH 03/17] fix count in spec --- spec/features/event_types_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/event_types_spec.rb b/spec/features/event_types_spec.rb index b47cb73e..e3e33a8c 100644 --- a/spec/features/event_types_spec.rb +++ b/spec/features/event_types_spec.rb @@ -13,7 +13,7 @@ feature EventType do conference_id: conference.short_title) within('table#event_types') do - expect(page.assert_selector('tr', count: 3)).to be true + expect(page.assert_selector('tr', count: 4)).to be true end # Add event type @@ -33,7 +33,7 @@ feature EventType do expect(page.has_content?('Party')).to be true expect(page.has_content?('13042')).to be true expect(page.has_content?('#e4e4e4')).to be true - expect(page.assert_selector('tr', count: 4)).to be true + expect(page.assert_selector('tr', count: 5)).to be true end # Remove event type @@ -43,7 +43,7 @@ feature EventType do expect(flash).to eq('Event type successfully deleted.') within('table#event_types') do - expect(page.assert_selector('tr', count: 3)).to be true + expect(page.assert_selector('tr', count: 4)).to be true expect(page.has_content?('Party')).to be false end end From 2f6fccb9121b73ddbf90a055827cdaf5db31f24b Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Fri, 28 Nov 2014 14:47:39 +0200 Subject: [PATCH 04/17] keynote type available only to admins. Able to mark as highlight. Highlights and Keynotes scoped. --- app/controllers/admin/events_controller.rb | 3 +++ app/models/conference.rb | 20 ++++++++------------ app/views/admin/events/_proposal.html.haml | 13 +++++++++++++ app/views/conference/_program.html.haml | 8 ++++---- app/views/proposal/_proposal_form.html.haml | 4 ++-- 5 files changed, 30 insertions(+), 18 deletions(-) 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/models/conference.rb b/app/models/conference.rb index 1f6088fd..45f01b96 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -43,6 +43,14 @@ class Conference < ActiveRecord::Base def confirmed where(state: :confirmed) end + + def keynotes + where(state: :confirmed).select { |e| e.event_type.title == 'Keynote'} + 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 @@ -558,18 +566,6 @@ class Conference < ActiveRecord::Base email_settings.updated_conference_registration_dates_template end - def keynotes - events.where(state: 'confirmed').select { |e| e.event_type.title == 'Keynote'} - end - - ## - # - # ====Returns - # * +Array+ -> Events with attribute 'is_highlight' - def highlights - events.where(is_highlight: true) - end - private after_create do 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/conference/_program.html.haml b/app/views/conference/_program.html.haml index 95868464..7dfde4b1 100644 --- a/app/views/conference/_program.html.haml +++ b/app/views/conference/_program.html.haml @@ -24,14 +24,14 @@ = link_to(conference_schedule_path(@conference.short_title), class: 'btn btn-default btn-lg') do Full Schedule - - if @conference.keynotes.any? + - if @conference.events.keynotes.any? .row .col-md12 %h3.text-center Keynote Talks! .row .col-md-12 - - @conference.keynotes.each_slice(3) do |slice| + - @conference.events.keynotes.each_slice(3) do |slice| .row.row-centered - slice.each do |event| .col-md-6.col-centered @@ -45,10 +45,10 @@ %h3.text-center Don't miss out! %br - - if @conference.highlights.any? + - if @conference.events.highlights.any? .row .col-md-12 - - @conference.highlights.each_slice(2) do |slice| + - @conference.events.highlights.each_slice(2) do |slice| .row.row-centered - slice.each do |event| .col-md-6.col-centered.col-top.highlights diff --git a/app/views/proposal/_proposal_form.html.haml b/app/views/proposal/_proposal_form.html.haml index 1d46f079..f6ed5bb1 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.reject { |type| type.title == 'Keynote'}.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} From bd570ecb3ced88576b82cb2b54ebbf6fe968036e Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Fri, 28 Nov 2014 14:51:48 +0200 Subject: [PATCH 05/17] add include_cfp to splashpage, remove old column, migrate data --- ...e_column_include_cfp_in_splash_from_cfp.rb | 5 -- ...27163536_add_include_cfp_in_splashpages.rb | 5 -- ...de_cfp_in_splash_add_column_include_cfp.rb | 46 +++++++++++++++++++ 3 files changed, 46 insertions(+), 10 deletions(-) delete mode 100644 db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb delete mode 100644 db/migrate/20141127163536_add_include_cfp_in_splashpages.rb create mode 100644 db/migrate/20141128073306_migrate_data_remove_column_include_cfp_in_splash_add_column_include_cfp.rb diff --git a/db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb b/db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb deleted file mode 100644 index 4f3519df..00000000 --- a/db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveColumnIncludeCfpInSplashFromCfp < ActiveRecord::Migration - def change - remove_column :call_for_papers, :include_cfp_in_splash, :boolean, default: false - end -end diff --git a/db/migrate/20141127163536_add_include_cfp_in_splashpages.rb b/db/migrate/20141127163536_add_include_cfp_in_splashpages.rb deleted file mode 100644 index d2e7c0d3..00000000 --- a/db/migrate/20141127163536_add_include_cfp_in_splashpages.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIncludeCfpInSplashpages < ActiveRecord::Migration - def change - add_column :splashpages, :include_cfp, :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 From d44d5bd3789151df1bfda657317d83bdaa433998 Mon Sep 17 00:00:00 2001 From: Stella Date: Sun, 30 Nov 2014 12:47:22 +0200 Subject: [PATCH 06/17] do not allow creation of proposal with keynote type --- app/controllers/proposal_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index 5956f24f..a0659071 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -39,6 +39,16 @@ class ProposalController < ApplicationController @event.event_users.new(user: current_user, event_role: 'speaker') + type_id = params[:event][:event_type_id].to_f + keynote_ids = EventType.where(title: 'Keynote').pluck(:id) + + if keynote_ids.include? type_id + @event.errors.add(:event_type_id, 'You are not allowed to create a Keynote!') + flash[:error] = "Could not submit proposal: #{@event.errors.full_messages.join(', ')}" + render action: 'new' + return + end + if !@event.save flash[:error] = "Could not submit proposal: #{@event.errors.full_messages.join(', ')}" render action: 'new' From b50badc9c711f2a46b9f0d1c97b23de02b8b394a Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Thu, 4 Dec 2014 14:27:17 +0200 Subject: [PATCH 07/17] wording --- app/views/admin/splashpages/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/splashpages/_form.html.haml b/app/views/admin/splashpages/_form.html.haml index 656aa0e0..38335b31 100644 --- a/app/views/admin/splashpages/_form.html.haml +++ b/app/views/admin/splashpages/_form.html.haml @@ -8,7 +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 CfP information on splashpage, while cfp is open?' + = 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?' From 2a45f49a052518178147afcd30c9ff16693c0e34 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Fri, 5 Dec 2014 09:13:01 +0200 Subject: [PATCH 08/17] show Keynote type in new proposal --- app/views/proposal/_proposal_form.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/proposal/_proposal_form.html.haml b/app/views/proposal/_proposal_form.html.haml index f6ed5bb1..1d46f079 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.reject { |type| type.title == 'Keynote'}.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, - data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length }]}, + 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 }]}, include_blank: false, label: 'Session Type' - else Event type: #{@event.event_type.title} From 0768514d896802ae46119a5ce9cd1092e191d011 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Fri, 5 Dec 2014 09:13:06 +0200 Subject: [PATCH 09/17] Revert "do not allow creation of proposal with keynote type" This reverts commit e103ea18b5e4fb0ddb82aaf9c058325d7e3daced. --- app/controllers/proposal_controller.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index a0659071..5956f24f 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -39,16 +39,6 @@ class ProposalController < ApplicationController @event.event_users.new(user: current_user, event_role: 'speaker') - type_id = params[:event][:event_type_id].to_f - keynote_ids = EventType.where(title: 'Keynote').pluck(:id) - - if keynote_ids.include? type_id - @event.errors.add(:event_type_id, 'You are not allowed to create a Keynote!') - flash[:error] = "Could not submit proposal: #{@event.errors.full_messages.join(', ')}" - render action: 'new' - return - end - if !@event.save flash[:error] = "Could not submit proposal: #{@event.errors.full_messages.join(', ')}" render action: 'new' From 88f73bb6fc9cee2a27ac0edf18d0a596fa0ca4c5 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Thu, 27 Nov 2014 20:40:26 +0200 Subject: [PATCH 10/17] Splaspage: Add highlights. Fix cfp inclusion. --- app/models/conference.rb | 12 ++++++++++ app/views/conference/_program.html.haml | 22 ++----------------- ...e_column_include_cfp_in_splash_from_cfp.rb | 5 +++++ ...27163536_add_include_cfp_in_splashpages.rb | 5 +++++ 4 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb create mode 100644 db/migrate/20141127163536_add_include_cfp_in_splashpages.rb diff --git a/app/models/conference.rb b/app/models/conference.rb index 45f01b96..e5c55018 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -566,6 +566,18 @@ class Conference < ActiveRecord::Base email_settings.updated_conference_registration_dates_template end + def keynote_speakers + User.with_role(:keynote_speaker, self) + end + + ## + # + # ====Returns + # * +Array+ -> Events with attribute 'is_highlight' + def highlights + events.where(is_highlight: true) + end + private after_create do diff --git a/app/views/conference/_program.html.haml b/app/views/conference/_program.html.haml index 7dfde4b1..5b1c82ae 100644 --- a/app/views/conference/_program.html.haml +++ b/app/views/conference/_program.html.haml @@ -24,31 +24,13 @@ = link_to(conference_schedule_path(@conference.short_title), class: 'btn btn-default btn-lg') do Full Schedule - - if @conference.events.keynotes.any? - .row - .col-md12 - %h3.text-center - Keynote Talks! - .row - .col-md-12 - - @conference.events.keynotes.each_slice(3) do |slice| - .row.row-centered - - slice.each do |event| - .col-md-6.col-centered - .thumbnail - %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) %h3.text-center Don't miss out! - %br - - if @conference.events.highlights.any? + - if @conference.highlights.any? .row .col-md-12 - - @conference.events.highlights.each_slice(2) do |slice| + - @conference.highlights.each_slice(2) do |slice| .row.row-centered - slice.each do |event| .col-md-6.col-centered.col-top.highlights diff --git a/db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb b/db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb new file mode 100644 index 00000000..4f3519df --- /dev/null +++ b/db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb @@ -0,0 +1,5 @@ +class RemoveColumnIncludeCfpInSplashFromCfp < ActiveRecord::Migration + def change + remove_column :call_for_papers, :include_cfp_in_splash, :boolean, default: false + end +end diff --git a/db/migrate/20141127163536_add_include_cfp_in_splashpages.rb b/db/migrate/20141127163536_add_include_cfp_in_splashpages.rb new file mode 100644 index 00000000..d2e7c0d3 --- /dev/null +++ b/db/migrate/20141127163536_add_include_cfp_in_splashpages.rb @@ -0,0 +1,5 @@ +class AddIncludeCfpInSplashpages < ActiveRecord::Migration + def change + add_column :splashpages, :include_cfp, :boolean, default: false + end +end From 6a62e9f8b9c8d516128554ab643e5dd410154145 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Thu, 27 Nov 2014 21:33:13 +0200 Subject: [PATCH 11/17] add event_type keynote --- app/models/conference.rb | 4 ++-- app/views/conference/_program.html.haml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/conference.rb b/app/models/conference.rb index e5c55018..4cdf1a45 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -566,8 +566,8 @@ class Conference < ActiveRecord::Base email_settings.updated_conference_registration_dates_template end - def keynote_speakers - User.with_role(:keynote_speaker, self) + def keynotes + events.where(state: 'confirmed').select { |e| e.event_type.title == 'Keynote'} end ## diff --git a/app/views/conference/_program.html.haml b/app/views/conference/_program.html.haml index 5b1c82ae..a67d81e1 100644 --- a/app/views/conference/_program.html.haml +++ b/app/views/conference/_program.html.haml @@ -24,9 +24,9 @@ = link_to(conference_schedule_path(@conference.short_title), class: 'btn btn-default btn-lg') do Full Schedule - %h3.text-center Don't miss out! + %br - if @conference.highlights.any? .row .col-md-12 From 8ac11821fa3ab71b57a865211ce238c317752dc5 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Fri, 28 Nov 2014 14:47:39 +0200 Subject: [PATCH 12/17] keynote type available only to admins. Able to mark as highlight. Highlights and Keynotes scoped. --- app/models/conference.rb | 12 ------------ app/views/conference/_program.html.haml | 4 ++-- app/views/proposal/_proposal_form.html.haml | 4 ++-- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/app/models/conference.rb b/app/models/conference.rb index 4cdf1a45..45f01b96 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -566,18 +566,6 @@ class Conference < ActiveRecord::Base email_settings.updated_conference_registration_dates_template end - def keynotes - events.where(state: 'confirmed').select { |e| e.event_type.title == 'Keynote'} - end - - ## - # - # ====Returns - # * +Array+ -> Events with attribute 'is_highlight' - def highlights - events.where(is_highlight: true) - end - private after_create do diff --git a/app/views/conference/_program.html.haml b/app/views/conference/_program.html.haml index a67d81e1..07a602c9 100644 --- a/app/views/conference/_program.html.haml +++ b/app/views/conference/_program.html.haml @@ -27,10 +27,10 @@ %h3.text-center Don't miss out! %br - - if @conference.highlights.any? + - if @conference.events.highlights.any? .row .col-md-12 - - @conference.highlights.each_slice(2) do |slice| + - @conference.events.highlights.each_slice(2) do |slice| .row.row-centered - slice.each do |event| .col-md-6.col-centered.col-top.highlights diff --git a/app/views/proposal/_proposal_form.html.haml b/app/views/proposal/_proposal_form.html.haml index 1d46f079..f6ed5bb1 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.reject { |type| type.title == 'Keynote'}.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} From 0296f80076905bdc8ff2c9af3d291c6b4cbecac2 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Fri, 28 Nov 2014 14:51:48 +0200 Subject: [PATCH 13/17] add include_cfp to splashpage, remove old column, migrate data --- ...127163428_remove_column_include_cfp_in_splash_from_cfp.rb | 5 ----- db/migrate/20141127163536_add_include_cfp_in_splashpages.rb | 5 ----- 2 files changed, 10 deletions(-) delete mode 100644 db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb delete mode 100644 db/migrate/20141127163536_add_include_cfp_in_splashpages.rb diff --git a/db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb b/db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb deleted file mode 100644 index 4f3519df..00000000 --- a/db/migrate/20141127163428_remove_column_include_cfp_in_splash_from_cfp.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveColumnIncludeCfpInSplashFromCfp < ActiveRecord::Migration - def change - remove_column :call_for_papers, :include_cfp_in_splash, :boolean, default: false - end -end diff --git a/db/migrate/20141127163536_add_include_cfp_in_splashpages.rb b/db/migrate/20141127163536_add_include_cfp_in_splashpages.rb deleted file mode 100644 index d2e7c0d3..00000000 --- a/db/migrate/20141127163536_add_include_cfp_in_splashpages.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIncludeCfpInSplashpages < ActiveRecord::Migration - def change - add_column :splashpages, :include_cfp, :boolean, default: false - end -end From a8b0c28cee1e2b86c8741d983c65a6dec5ec2625 Mon Sep 17 00:00:00 2001 From: Stella Date: Sun, 30 Nov 2014 12:47:22 +0200 Subject: [PATCH 14/17] do not allow creation of proposal with keynote type --- app/controllers/proposal_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index 5956f24f..a0659071 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -39,6 +39,16 @@ class ProposalController < ApplicationController @event.event_users.new(user: current_user, event_role: 'speaker') + type_id = params[:event][:event_type_id].to_f + keynote_ids = EventType.where(title: 'Keynote').pluck(:id) + + if keynote_ids.include? type_id + @event.errors.add(:event_type_id, 'You are not allowed to create a Keynote!') + flash[:error] = "Could not submit proposal: #{@event.errors.full_messages.join(', ')}" + render action: 'new' + return + end + if !@event.save flash[:error] = "Could not submit proposal: #{@event.errors.full_messages.join(', ')}" render action: 'new' From c787190571373242c53a1e1ad8d7ffd18cc0c5f6 Mon Sep 17 00:00:00 2001 From: Stella Date: Sun, 7 Dec 2014 16:52:10 +0200 Subject: [PATCH 15/17] add is_keynote attribute to event_types --- app/controllers/admin/event_types_controller.rb | 5 ++++- app/models/conference.rb | 9 ++++++--- app/models/event_type.rb | 2 +- app/views/admin/event_types/_form.html.haml | 3 ++- app/views/admin/event_types/index.html.haml | 2 ++ app/views/admin/events/edit.html.haml | 2 +- app/views/conference/_program.html.haml | 5 +++-- .../20141207115535_add_is_keynote_to_event_types.rb | 5 +++++ db/schema.rb | 9 +++++---- 9 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20141207115535_add_is_keynote_to_event_types.rb diff --git a/app/controllers/admin/event_types_controller.rb b/app/controllers/admin/event_types_controller.rb index 85d1ff6b..c1bf4bcf 100644 --- a/app/controllers/admin/event_types_controller.rb +++ b/app/controllers/admin/event_types_controller.rb @@ -49,7 +49,10 @@ module Admin private def event_type_params - params[:event_type] + params.require(:event_type).permit(:title, :length, + :minimum_abstract_length, + :maximum_abstract_length, + :color, :is_keynote) end end end diff --git a/app/models/conference.rb b/app/models/conference.rb index 45f01b96..7c105abb 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -45,11 +45,13 @@ class Conference < ActiveRecord::Base end def keynotes - where(state: :confirmed).select { |e| e.event_type.title == 'Keynote'} + where(state: :confirmed). + select { |e| e.event_type.is_keynote == true} end def highlights - where(is_highlight: true) + where(state: :confirmed).where(is_highlight: true). + select { |e| e.event_type.is_keynote != true} # No duplication, if event is a keynote end end has_many :event_users, through: :events @@ -900,7 +902,8 @@ class Conference < ActiveRecord::Base maximum_abstract_length: 500) event_types << EventType.create(title: 'Keynote', length: 60, color: '#00FF00', minimum_abstract_length: 0, - maximum_abstract_length: 500) + maximum_abstract_length: 500, + is_keynote: true) true end diff --git a/app/models/event_type.rb b/app/models/event_type.rb index a2204985..2be9c6d8 100644 --- a/app/models/event_type.rb +++ b/app/models/event_type.rb @@ -1,6 +1,6 @@ class EventType < ActiveRecord::Base attr_accessible :title, :length, :minimum_abstract_length, :maximum_abstract_length, :color, - :conference_id + :conference_id, :is_keynote belongs_to :conference diff --git a/app/views/admin/event_types/_form.html.haml b/app/views/admin/event_types/_form.html.haml index 8ef37e4e..47e52c0c 100644 --- a/app/views/admin/event_types/_form.html.haml +++ b/app/views/admin/event_types/_form.html.haml @@ -13,6 +13,7 @@ = f.input :length, :input_html => {:size => 3} = f.input :minimum_abstract_length, :input_html => {:size => 3} = f.input :maximum_abstract_length, :input_html => {:size => 3} + = f.input :is_keynote = f.input :color, :input_html => { :size => 6, :type => 'color' } %p.text-right - = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } \ No newline at end of file + = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } diff --git a/app/views/admin/event_types/index.html.haml b/app/views/admin/event_types/index.html.haml index fddc2dd3..a7f2c179 100644 --- a/app/views/admin/event_types/index.html.haml +++ b/app/views/admin/event_types/index.html.haml @@ -11,6 +11,7 @@ %th Title %th Length %th Abstract Length + %th Keynote %th Color %th Actions %tbody @@ -24,6 +25,7 @@ %td = "#{event_type.minimum_abstract_length} - #{event_type.maximum_abstract_length}" Words + %td= event_type.is_keynote %td %span.label{style: "background-color: #{event_type.color};"} = event_type.color diff --git a/app/views/admin/events/edit.html.haml b/app/views/admin/events/edit.html.haml index 0ea1048e..bccdad74 100644 --- a/app/views/admin/events/edit.html.haml +++ b/app/views/admin/events/edit.html.haml @@ -1 +1 @@ -= render 'proposal/form' \ No newline at end of file += render 'proposal/form' diff --git a/app/views/conference/_program.html.haml b/app/views/conference/_program.html.haml index 07a602c9..8f7d3c16 100644 --- a/app/views/conference/_program.html.haml +++ b/app/views/conference/_program.html.haml @@ -30,12 +30,13 @@ - if @conference.events.highlights.any? .row .col-md-12 - - @conference.events.highlights.each_slice(2) do |slice| + - @conference.events.highlights.each_slice(3) do |slice| .row.row-centered - slice.each do |event| - .col-md-6.col-centered.col-top.highlights + .col-md-4.col-centered.col-top.highlights %p.text-center %b= event.title + by #{event.speakers.first.name} %h5.text-center = simple_format truncate(event.abstract, length: 500, separator: ' ') = link_to "Read More", conference_proposal_path(@conference.short_title, event) diff --git a/db/migrate/20141207115535_add_is_keynote_to_event_types.rb b/db/migrate/20141207115535_add_is_keynote_to_event_types.rb new file mode 100644 index 00000000..baf95ee0 --- /dev/null +++ b/db/migrate/20141207115535_add_is_keynote_to_event_types.rb @@ -0,0 +1,5 @@ +class AddIsKeynoteToEventTypes < ActiveRecord::Migration + def change + add_column :event_types, :is_keynote, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index b72a5ce2..ed9c045a 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: 20141130182139) do +ActiveRecord::Schema.define(version: 20141207115535) do create_table "ahoy_events", force: true do |t| t.uuid "visit_id" @@ -191,11 +191,12 @@ ActiveRecord::Schema.define(version: 20141130182139) do create_table "event_types", force: true do |t| t.integer "conference_id" - t.string "title", null: false + t.string "title", null: false t.integer "length", default: 30 t.integer "minimum_abstract_length", default: 0 t.integer "maximum_abstract_length", default: 500 t.string "color" + t.boolean "is_keynote", default: false end create_table "event_users", force: true do |t| @@ -334,11 +335,11 @@ ActiveRecord::Schema.define(version: 20141130182139) do create_table "roles", force: true do |t| t.string "name" + t.datetime "created_at" + t.datetime "updated_at" t.string "description" t.integer "resource_id" t.string "resource_type" - t.datetime "created_at" - t.datetime "updated_at" end add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id" From c9615f1880e348a29a8d85ea675e0bc18a50bb7f Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Mon, 8 Dec 2014 16:11:38 +0200 Subject: [PATCH 16/17] Revert "add is_keynote attribute to event_types" This reverts commit 96253b1fe048e2052fc35e961c5afbf27d0ef740. Conflicts: app/models/conference.rb --- app/controllers/admin/event_types_controller.rb | 5 +---- app/models/conference.rb | 6 ++---- app/models/event_type.rb | 2 +- app/views/admin/event_types/_form.html.haml | 3 +-- app/views/admin/event_types/index.html.haml | 2 -- app/views/admin/events/edit.html.haml | 2 +- app/views/conference/_program.html.haml | 6 +++--- db/migrate/20141207115535_add_is_keynote_to_event_types.rb | 5 ----- db/schema.rb | 5 ++--- 9 files changed, 11 insertions(+), 25 deletions(-) delete mode 100644 db/migrate/20141207115535_add_is_keynote_to_event_types.rb diff --git a/app/controllers/admin/event_types_controller.rb b/app/controllers/admin/event_types_controller.rb index c1bf4bcf..85d1ff6b 100644 --- a/app/controllers/admin/event_types_controller.rb +++ b/app/controllers/admin/event_types_controller.rb @@ -49,10 +49,7 @@ module Admin private def event_type_params - params.require(:event_type).permit(:title, :length, - :minimum_abstract_length, - :maximum_abstract_length, - :color, :is_keynote) + params[:event_type] end end end diff --git a/app/models/conference.rb b/app/models/conference.rb index 7c105abb..2c61a35f 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -45,13 +45,11 @@ class Conference < ActiveRecord::Base end def keynotes - where(state: :confirmed). - select { |e| e.event_type.is_keynote == true} + where(state: :confirmed).select { |e| e.event_type.title == 'Keynote'} end def highlights - where(state: :confirmed).where(is_highlight: true). - select { |e| e.event_type.is_keynote != true} # No duplication, if event is a keynote + where(is_highlight: true) end end has_many :event_users, through: :events diff --git a/app/models/event_type.rb b/app/models/event_type.rb index 2be9c6d8..a2204985 100644 --- a/app/models/event_type.rb +++ b/app/models/event_type.rb @@ -1,6 +1,6 @@ class EventType < ActiveRecord::Base attr_accessible :title, :length, :minimum_abstract_length, :maximum_abstract_length, :color, - :conference_id, :is_keynote + :conference_id belongs_to :conference diff --git a/app/views/admin/event_types/_form.html.haml b/app/views/admin/event_types/_form.html.haml index 47e52c0c..8ef37e4e 100644 --- a/app/views/admin/event_types/_form.html.haml +++ b/app/views/admin/event_types/_form.html.haml @@ -13,7 +13,6 @@ = f.input :length, :input_html => {:size => 3} = f.input :minimum_abstract_length, :input_html => {:size => 3} = f.input :maximum_abstract_length, :input_html => {:size => 3} - = f.input :is_keynote = f.input :color, :input_html => { :size => 6, :type => 'color' } %p.text-right - = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } + = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } \ No newline at end of file diff --git a/app/views/admin/event_types/index.html.haml b/app/views/admin/event_types/index.html.haml index a7f2c179..fddc2dd3 100644 --- a/app/views/admin/event_types/index.html.haml +++ b/app/views/admin/event_types/index.html.haml @@ -11,7 +11,6 @@ %th Title %th Length %th Abstract Length - %th Keynote %th Color %th Actions %tbody @@ -25,7 +24,6 @@ %td = "#{event_type.minimum_abstract_length} - #{event_type.maximum_abstract_length}" Words - %td= event_type.is_keynote %td %span.label{style: "background-color: #{event_type.color};"} = event_type.color diff --git a/app/views/admin/events/edit.html.haml b/app/views/admin/events/edit.html.haml index bccdad74..0ea1048e 100644 --- a/app/views/admin/events/edit.html.haml +++ b/app/views/admin/events/edit.html.haml @@ -1 +1 @@ -= render 'proposal/form' += render 'proposal/form' \ No newline at end of file diff --git a/app/views/conference/_program.html.haml b/app/views/conference/_program.html.haml index 8f7d3c16..f04ba644 100644 --- a/app/views/conference/_program.html.haml +++ b/app/views/conference/_program.html.haml @@ -24,19 +24,19 @@ = link_to(conference_schedule_path(@conference.short_title), class: 'btn btn-default btn-lg') do Full Schedule + %h3.text-center Don't miss out! %br - if @conference.events.highlights.any? .row .col-md-12 - - @conference.events.highlights.each_slice(3) do |slice| + - @conference.events.highlights.each_slice(2) do |slice| .row.row-centered - slice.each do |event| - .col-md-4.col-centered.col-top.highlights + .col-md-6.col-centered.col-top.highlights %p.text-center %b= event.title - by #{event.speakers.first.name} %h5.text-center = simple_format truncate(event.abstract, length: 500, separator: ' ') = link_to "Read More", conference_proposal_path(@conference.short_title, event) diff --git a/db/migrate/20141207115535_add_is_keynote_to_event_types.rb b/db/migrate/20141207115535_add_is_keynote_to_event_types.rb deleted file mode 100644 index baf95ee0..00000000 --- a/db/migrate/20141207115535_add_is_keynote_to_event_types.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIsKeynoteToEventTypes < ActiveRecord::Migration - def change - add_column :event_types, :is_keynote, :boolean, default: false - end -end diff --git a/db/schema.rb b/db/schema.rb index ed9c045a..7c94011c 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: 20141207115535) do +ActiveRecord::Schema.define(version: 20141130182139) do create_table "ahoy_events", force: true do |t| t.uuid "visit_id" @@ -191,12 +191,11 @@ ActiveRecord::Schema.define(version: 20141207115535) do create_table "event_types", force: true do |t| t.integer "conference_id" - t.string "title", null: false + t.string "title", null: false t.integer "length", default: 30 t.integer "minimum_abstract_length", default: 0 t.integer "maximum_abstract_length", default: 500 t.string "color" - t.boolean "is_keynote", default: false end create_table "event_users", force: true do |t| From 8b45c2a281c95cfe75dcf28f8c70cf59285a2c49 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Mon, 8 Dec 2014 16:28:09 +0200 Subject: [PATCH 17/17] remove keynotes --- app/controllers/proposal_controller.rb | 10 ---------- app/models/conference.rb | 8 -------- app/views/proposal/_proposal_form.html.haml | 2 +- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index a0659071..5956f24f 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -39,16 +39,6 @@ class ProposalController < ApplicationController @event.event_users.new(user: current_user, event_role: 'speaker') - type_id = params[:event][:event_type_id].to_f - keynote_ids = EventType.where(title: 'Keynote').pluck(:id) - - if keynote_ids.include? type_id - @event.errors.add(:event_type_id, 'You are not allowed to create a Keynote!') - flash[:error] = "Could not submit proposal: #{@event.errors.full_messages.join(', ')}" - render action: 'new' - return - end - if !@event.save flash[:error] = "Could not submit proposal: #{@event.errors.full_messages.join(', ')}" render action: 'new' diff --git a/app/models/conference.rb b/app/models/conference.rb index 2c61a35f..ff8d11af 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -44,10 +44,6 @@ class Conference < ActiveRecord::Base where(state: :confirmed) end - def keynotes - where(state: :confirmed).select { |e| e.event_type.title == 'Keynote'} - end - def highlights where(is_highlight: true) end @@ -898,10 +894,6 @@ class Conference < ActiveRecord::Base event_types << EventType.create(title: 'Workshop', length: 60, color: '#0000FF', minimum_abstract_length: 0, maximum_abstract_length: 500) - event_types << EventType.create(title: 'Keynote', length: 60, color: '#00FF00', - minimum_abstract_length: 0, - maximum_abstract_length: 500, - is_keynote: true) true end diff --git a/app/views/proposal/_proposal_form.html.haml b/app/views/proposal/_proposal_form.html.haml index f6ed5bb1..6ad68fa2 100644 --- a/app/views/proposal/_proposal_form.html.haml +++ b/app/views/proposal/_proposal_form.html.haml @@ -11,7 +11,7 @@ %section#details - if can? :update, @event or can? :create, @event = f.input :event_type_id, as: :select, - collection: @conference.event_types.reject { |type| type.title == 'Keynote'}.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, + 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