Merge pull request #34 from differentreality/final_voting_visual

Voting visual
This commit is contained in:
Henne Vogelsang 2014-03-03 10:40:03 +01:00
commit 4092c68ea4
7 changed files with 61 additions and 35 deletions

View file

@ -60,11 +60,6 @@ $(function() {
$(".comment-reply").hide(); $(".comment-reply").hide();
$(".user-details-popover").popover(); $(".user-details-popover").popover();
$("#comments-div").hide(); $("#comments-div").hide();
$("#votes-link").click(function(){
$("#votes-div").toggle();
return false;
});
}); });
function word_count(text, divId, maxcount) { function word_count(text, divId, maxcount) {

View file

@ -14,7 +14,7 @@
background: url(../assets/star.png) 0 0; background: url(../assets/star.png) 0 0;
width: 26px; width: 26px;
height: 26px; height: 26px;
display: block; display: inline-block;
} }
.myrating, .othersrating { .myrating, .othersrating {
background: url(../assets/star.png) 0 0; background: url(../assets/star.png) 0 0;

View file

@ -1,5 +1,6 @@
class Admin::EventsController < ApplicationController class Admin::EventsController < ApplicationController
before_filter :verify_organizer before_filter :verify_organizer
# FIXME: The timezome should only be applied on output, otherwise # FIXME: The timezome should only be applied on output, otherwise
# you get lost in timezone conversions... # you get lost in timezone conversions...
# around_filter :set_timezone_for_this_request # around_filter :set_timezone_for_this_request
@ -122,16 +123,21 @@ class Admin::EventsController < ApplicationController
end end
def vote def vote
event = Event.find(params[:id]) @event = Event.find(params[:id])
@ratings = @event.votes.includes(:person)
if votes = current_user.person.votes.find_by_event_id(params[:id]) if votes = current_user.person.votes.find_by_event_id(params[:id])
votes.update_attributes(:rating => params[:rating]) votes.update_attributes(:rating => params[:rating])
else else
@myvote = event.votes.build @myvote = @event.votes.build
@myvote.person = current_user.person @myvote.person = current_user.person
@myvote.rating = params[:rating] @myvote.rating = params[:rating]
@myvote.save @myvote.save
end end
redirect_to admin_conference_event_path(@conference.short_title, event)
respond_to do |format|
format.html { redirect_to admin_conference_event_path(@conference.short_title, @event)}
format.js
end
end end
end end

View file

@ -5,7 +5,6 @@
%br %br
%span.muted %span.muted
= @event.subtitle = @event.subtitle
.span2 .span2
= link_to "Edit", edit_admin_conference_event_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary" = link_to "Edit", edit_admin_conference_event_path(@conference.short_title, @event), :class => "btn btn-mini btn-primary"
@ -13,7 +12,7 @@
.span12 .span12
%table.table %table.table
%tr %tr
%td %td{:style => "width:15%"}
%b Type %b Type
%td %td
.dropdown .dropdown
@ -113,6 +112,10 @@
%td %td
%b Description %b Description
%td= simple_format(@event.description) %td= simple_format(@event.description)
- if @conference.call_for_papers.rating > 0
= render :partial => "voting"
- if @event.event_attachments.size > 0 - if @event.event_attachments.size > 0
%table.table %table.table
%thead %thead
@ -142,11 +145,7 @@
%td %td
= link_to "Delete", conference_proposal_event_attachment_path(@conference.short_title, @event.id, a.id), = 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!" :method => :delete, :confirm => "Are you sure you want to delete this attachment? It's permanant!"
- if @conference.call_for_papers.rating > 0
.row-fluid
= link_to "Votes (#{@event.voters.length})", "#", :id => "votes-link"
#votes-div
= render :partial => 'voting'
.row-fluid .row-fluid
= link_to "Comments (#{@comment_count})", "#", :id => "event-comment-link" = link_to "Comments (#{@comment_count})", "#", :id => "event-comment-link"
#comments-div #comments-div

View file

@ -1,7 +1,31 @@
%table#myeventratings{:style=>"width: 20%"} %table.table#myrating
%tr
%td{:style => "width:15%"}
%b Rating
%td
- if @event.average_rating.to_f > 0
#{@event.average_rating}/#{@conference.call_for_papers.rating}
- else
Rating: 0/#{@conference.call_for_papers.rating}
- @conference.call_for_papers.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"
%tr %tr
%td %td
%b Your vote: %b Voters
%td
= @event.voters.length
- if @event.voters.length > 0
(
= @ratings.map {|x| "#{x.first_name} #{x.last_name}"}.join ', '
)
%tr
%td
%b Your vote
%td %td
- @conference.call_for_papers.rating.times do |counter| - @conference.call_for_papers.rating.times do |counter|
- voted = @event.voted?(@event, current_user.person) - voted = @event.voted?(@event, current_user.person)

View file

@ -13,8 +13,9 @@
%b ID %b ID
%th %th
%b Title %b Title
%th - if @conference.call_for_papers.rating != 0
%b Rating %th
%b Rating
%th %th
%b Submitter %b Submitter
%th %th
@ -31,22 +32,23 @@
= event.id = event.id
%td %td
=link_to event.title, admin_conference_event_path(@conference.short_title, event) =link_to event.title, admin_conference_event_path(@conference.short_title, event)
%td
- if @conference.call_for_papers.rating != 0
- if event.average_rating.to_f > 0
Rating: (#{event.average_rating}/#{@conference.call_for_papers.rating})
- else
Rating: (0/#{@conference.call_for_papers.rating})
%br
- @conference.call_for_papers.rating.times do |counter| - if @conference.call_for_papers.rating != 0
- if event.average_rating.to_f.round == counter+1 %td{:style => "width:96px"}
= label_tag "label_rating", "", :class => "avgrating", :avgrate => true - if event.average_rating.to_f > 0
= javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');" %b #{event.average_rating}/#{@conference.call_for_papers.rating}
- else %br
= label_tag "label_rating", "", :class => "avgrating" #{pluralize(event.voters.length, 'voter')}
- else %br
= link_to "(enable voting)", admin_conference_cfp_info_path(@conference.short_title) - @conference.call_for_papers.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"
- else
Rating: 0/#{@conference.call_for_papers.rating}
%br
- if event.submitter.registrations.count < 1 - if event.submitter.registrations.count < 1
- bgcolor="#F7819F" - bgcolor="#F7819F"

View file

@ -1 +1 @@
$('table#myeventratings').replaceWith("<%= escape_javascript(render :partial => 'voting') %>"); $('table#myrating').replaceWith("<%= escape_javascript(render :partial => 'voting') %>");