From de1ed9be2b1311ab010348e0212eb3b54ba7105f Mon Sep 17 00:00:00 2001 From: Stella Date: Sat, 28 Dec 2013 15:29:50 +0200 Subject: [PATCH 1/3] Fixes for voting on proposals. 0 for no voting option. Set default value in migration to avoid blank/null problems. --- app/models/call_for_papers.rb | 2 +- app/views/admin/callforpapers/show.html.haml | 2 +- ...1228132353_change_default_rating_in_call_for_papers.rb | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb diff --git a/app/models/call_for_papers.rb b/app/models/call_for_papers.rb index f3915b75..879cf2fe 100644 --- a/app/models/call_for_papers.rb +++ b/app/models/call_for_papers.rb @@ -3,6 +3,6 @@ class CallForPapers < ActiveRecord::Base belongs_to :conference validates_presence_of :start_date, :end_date, :hard_deadline - validates :rating, :numericality => { :greater_than_or_equal_to => 1, :less_than_or_equal_to => 10 } + validates :rating, :numericality => { :greater_than_or_equal_to => 0, :less_than_or_equal_to => 10 } end diff --git a/app/views/admin/callforpapers/show.html.haml b/app/views/admin/callforpapers/show.html.haml index 6757dff7..f342534e 100644 --- a/app/views/admin/callforpapers/show.html.haml +++ b/app/views/admin/callforpapers/show.html.haml @@ -9,6 +9,6 @@ = f.input :hard_deadline, :as => :string, :input_html => { :id => "cfp-hard-datepicker", :readonly => "readonly" } = f.input :description, :hint => "Welcome text for the Call for Papers" = f.input :schedule_changes - = f.input :rating, :hint => "Enter the number of different rating levels you want to have for voting on proposals." + = 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." = f.input :rating_desc, :label => "Rating Description", :hint => "Enter comments about voting process.", :input_html => {:value => "1 is for 'I don't like this proposal',\n2 is for 'I am ok with this proposal.',\n3 is for 'I love this proposal!'", :rows => 5, :class => "span6"} = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} diff --git a/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb b/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb new file mode 100644 index 00000000..adaaac75 --- /dev/null +++ b/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb @@ -0,0 +1,8 @@ +class ChangeDefaultRatingInCallForPapers < ActiveRecord::Migration + def up + change_column :call_for_papers, :rating, :integer, :default => 3 + end + + def down + end +end From 28b8b58030ee42d5d47dabf25ac9d0411b2dba0c Mon Sep 17 00:00:00 2001 From: Stella Date: Sat, 28 Dec 2013 15:51:37 +0200 Subject: [PATCH 2/3] migration, add down func --- .../20131228132353_change_default_rating_in_call_for_papers.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb b/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb index adaaac75..d81556d7 100644 --- a/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb +++ b/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb @@ -4,5 +4,6 @@ class ChangeDefaultRatingInCallForPapers < ActiveRecord::Migration end def down + change_column :call_for_papers, :rating, :integer, :null => 1 end end From 8ca2e534305e5d1b0d5bc990cf7fc7a2daf8088f Mon Sep 17 00:00:00 2001 From: Stella Date: Sat, 28 Dec 2013 16:20:00 +0200 Subject: [PATCH 3/3] show voting options only if rating is enabled (>0) --- app/views/admin/events/_proposal.html.haml | 2 +- app/views/admin/events/index.html.haml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/admin/events/_proposal.html.haml b/app/views/admin/events/_proposal.html.haml index 0248ec3c..1e931836 100644 --- a/app/views/admin/events/_proposal.html.haml +++ b/app/views/admin/events/_proposal.html.haml @@ -142,7 +142,7 @@ %td = link_to "Delete", conference_proposal_event_attachment_path(@conference.short_title, @event.id, a.id), :method => :delete, :confirm => "Are you sure you want to delete this attachment? It's permanant!" -- if @conference.call_for_papers.rating +- if @conference.call_for_papers.rating > 0 .row-fluid = link_to "Votes (#{@event.voters.length})", "#", :id => "votes-link" #votes-div diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index 58ec1b5f..e5fd2047 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -32,7 +32,7 @@ %td =link_to event.title, admin_conference_event_path(@conference.short_title, event) %td - - if @conference.call_for_papers.rating + - if @conference.call_for_papers.rating != 0 - if event.average_rating.to_f > 0 Rating: (#{event.average_rating}/#{@conference.call_for_papers.rating}) - else @@ -45,6 +45,8 @@ = javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');" - else = label_tag "label_rating", "", :class => "avgrating" + - else + = link_to "(enable voting)", admin_conference_cfp_info_path(@conference.short_title) - if event.submitter.registrations.count < 1 - bgcolor="#F7819F"