From 2f6fccb9121b73ddbf90a055827cdaf5db31f24b Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Fri, 28 Nov 2014 14:47:39 +0200 Subject: [PATCH] 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}