Skip to content

Commit

Permalink
dropped votes
Browse files Browse the repository at this point in the history
  • Loading branch information
shlok007 committed Apr 5, 2017
1 parent dc1dd63 commit 9ab074c
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def show
@difficulty_levels = @program.difficulty_levels
@versions = @event.versions |
PaperTrail::Version.where(item_type: 'Commercial').where_object(commercialable_id: @event.id, commercialable_type: 'Event') |
PaperTrail::Version.where(item_type: 'Commercial').where_object_changes(commercialable_id: @event.id, commercialable_type: 'Event') |
PaperTrail::Version.where(item_type: 'Commercial').where_object_changes(commercialable_id: @event.id, commercialable_type: 'Event')
@votable_fields = VotableField.where(votable_type: 'Event', conference: @event.program.conference, enabled: true, for_admin: true)
Event.vote(@votable_fields)
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/program.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def show_voting?
Time.current > voting_end_date
end

def rating_enabled?
rating
end

##
# Checks if we are still in voting period
# ====Returns
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/events/_proposal.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
%b Description
%td= simple_format(@event.description)

- if @conference.program && @conference.program.rating
- if @votable_fields.present?
= render partial: 'voting'

.row
Expand Down
32 changes: 32 additions & 0 deletions app/views/admin/events/_voting.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
%hr
- if @program.rating_enabled?
- if @program.voting_period?
- if @program.show_voting?
%table.table
%thead
%td.col-md-2
%b Overall Votes
- @votable_fields.each do |field|
%tr
%td.col-md-2
= field.title
%td
= rating_for @event, field.title, disable: true, star: field.stars
%tr
%td
Voters
%td
= raters(@votable_fields)
%table.table
%thead
%td.col-md-2
%b Your Votes
- @votable_fields.each do |field|
%tr
%td.col-md-2
= field.title
%td
= rating_for_user @event, current_user, field.title, star: field.stars
- else
%b
= voting_open_or_close(@program)
13 changes: 0 additions & 13 deletions app/views/admin/events/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
%b ID
%th
%b Title
- if @program.rating_enabled?
%th
%b Rating
%th
%b Submitter
%th
Expand Down Expand Up @@ -83,16 +80,6 @@
- bgcolor = '#F7819F'
- else
- bgcolor = ''
%td{ style: "background-color: #{bgcolor}" }
- if @program.show_voting?
- unless event.submitter.nil?
= link_to event.submitter.name, admin_user_path(event.submitter)
- if event.submitter.registrations.count < 1
(Unregistered!)
- else
Unknown submitter
- else
%i Hidden
%td
- if @program.show_voting?
- if speaker = event.speakers.first
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/programs/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
= f.input :schedule_public, label: 'Show Schedule on the home and splash page'
= f.input :schedule_fluid, label: 'Allow submitters to change their event after it is scheduled'
= f.input :languages, hint: "Enter the languages allowed for events as values of #{link_to('ISO 639-1', 'http://www.loc.gov/standards/iso639-2/php/code_list.php', target: "_blank")} language codes separated with commas. The first language would be the default language. Leave it blank if you do not want to specify languages.".html_safe
= f.input :rating, label: 'Enable voting'
= f.input :blind_voting, hint: 'Enable this feature if you do not want to show voting results and voters prior to user submitting a vote. For the feature to work you need to set the voting dates below as well'
= f.input :voting_start_date, as: :string, input_html: { id: 'datetimepicker-voting_start_date', readonly: true, value: (f.object.voting_start_date.to_formatted_s(:db_without_seconds) unless f.object.voting_start_date.nil?) }
= f.input :voting_end_date, as: :string, input_html: { id: 'datetimepicker-voting_start_date', readonly: true, value: (f.object.voting_end_date.to_formatted_s(:db_without_seconds) unless f.object.voting_end_date.nil?) }
Expand Down
9 changes: 0 additions & 9 deletions app/views/admin/users/_submissions.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
%th Title
%th State
%th Type
%th Rating
%th Created At
%tbody
- @user.events.each do |event|
Expand All @@ -21,12 +20,4 @@
%td= link_to event.title, admin_conference_program_event_path(event.program.conference.short_title, event)
%td= event.state
%td= "#{event.event_type.title} (#{show_time(event.event_type.length)})"
%td
- if event.program && event.program.rating && event.program.rating > 0
- event.program.rating.times do |counter|
- if event.average_rating.to_f.round == counter+1
= label_tag 'label_rating', '', class: 'avgrating', avgrate: true
= javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');"
- else
= label_tag 'label_rating', '', class: 'avgrating'
%td= event.created_at
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeRatingToBooleanInProgram < ActiveRecord::Migration
def change
change_column :programs, :rating, :boolean, default: false
end
end
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170326084800) do
ActiveRecord::Schema.define(version: 20170405004358) do

create_table "ahoy_events", force: :cascade do |t|
t.uuid "visit_id", limit: 16
Expand Down Expand Up @@ -296,7 +296,7 @@

create_table "programs", force: :cascade do |t|
t.integer "conference_id"
t.integer "rating", default: 0
t.boolean "rating", default: false
t.boolean "schedule_public", default: false
t.boolean "schedule_fluid", default: false
t.datetime "created_at"
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/votes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
factory :vote do
event
user
rating 1
rating true
end
end

0 comments on commit 9ab074c

Please sign in to comment.