Handle the edge case of newly created unranked events
This commit is contained in:
parent
abe3366e5e
commit
ff68699b96
|
@ -12,6 +12,8 @@ class Event < ActiveRecord::Base
|
|||
|
||||
belongs_to :event_type
|
||||
|
||||
scope :ranked, -> { where.not(ranked: nil).where.not(votes: nil) }
|
||||
|
||||
validates :conference, presence: true
|
||||
validates :title, presence: true
|
||||
validates :abstract, presence: true
|
||||
|
@ -60,6 +62,10 @@ class Event < ActiveRecord::Base
|
|||
}
|
||||
end
|
||||
|
||||
def ranked?
|
||||
conference.has_vote_results? and rank.present? and number_of_votes.present?
|
||||
end
|
||||
|
||||
def per_cent_of_votes
|
||||
if conference.has_vote_results? and conference.number_of_ballots_cast > 0
|
||||
Rational(number_of_votes * 100, conference.number_of_ballots_cast)
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
.row
|
||||
.col-lg-12
|
||||
.submissions-chart#submissions-chart data-submissions="#{submissions_chart_data(@conference).to_json}"
|
||||
- if @conference.vote_data_endpoint.present?
|
||||
- if @conference.has_voting_endpoint?
|
||||
hr
|
||||
.row
|
||||
.col-lg-12
|
||||
|
@ -109,16 +109,23 @@
|
|||
th
|
||||
tbody
|
||||
- if @conference.has_vote_results?
|
||||
- current_conference.events.order(rank: :asc).group_by(&:rank).to_a[0..9].each do |rank, events|
|
||||
- current_conference.events.order(rank: :asc).group_by(&:rank).select { |rank, _| rank.nil? or rank <= 10 }.each do |rank, events|
|
||||
- events.each.with_index do |event, index|
|
||||
tr
|
||||
- if index == 0
|
||||
td.text-right rowspan="#{events.count}"
|
||||
.large
|
||||
span.label.label-info = event.rank
|
||||
td.text-right rowspan="#{events.count}"
|
||||
span title="#{t('.vote_ratio', votes: event.number_of_votes, total_votes: @conference.number_of_ballots_cast)}"
|
||||
= number_to_percentage(event.per_cent_of_votes, strip_insignificant_zeros: true, precision: 2)
|
||||
- if event.ranked?
|
||||
td.text-right rowspan="#{events.count}"
|
||||
.large
|
||||
span.label.label-info = event.rank
|
||||
td.text-right rowspan="#{events.count}"
|
||||
span title="#{t('.vote_ratio', votes: event.number_of_votes, total_votes: @conference.number_of_ballots_cast)}"
|
||||
= number_to_percentage(event.per_cent_of_votes, strip_insignificant_zeros: true, precision: 2)
|
||||
- else
|
||||
td.text-right rowspan="#{events.count}"
|
||||
.large
|
||||
span.label.label-danger ×
|
||||
td.text-right rowspan="#{events.count}"
|
||||
= t('.unranked')
|
||||
td = event.title
|
||||
td.actions = action_buttons(@conference, event, [:show])
|
||||
- else
|
||||
|
|
|
@ -26,12 +26,19 @@
|
|||
- events.each.with_index do |event, index|
|
||||
tr
|
||||
- if index == 0
|
||||
td.text-right rowspan="#{events.count}"
|
||||
.large
|
||||
span.label.label-info = event.rank
|
||||
td.text-right rowspan="#{events.count}"
|
||||
span title="#{t('.vote_ratio', votes: event.number_of_votes, total_votes: @conference.number_of_ballots_cast)}"
|
||||
= number_to_percentage(event.per_cent_of_votes, strip_insignificant_zeros: true, precision: 2)
|
||||
- if event.ranked?
|
||||
td.text-right rowspan="#{events.count}"
|
||||
.large
|
||||
span.label.label-info = event.rank
|
||||
td.text-right rowspan="#{events.count}"
|
||||
span title="#{t('.vote_ratio', votes: event.number_of_votes, total_votes: @conference.number_of_ballots_cast)}"
|
||||
= number_to_percentage(event.per_cent_of_votes, strip_insignificant_zeros: true, precision: 2)
|
||||
- else
|
||||
td.text-right rowspan="#{events.count}"
|
||||
.large
|
||||
span.label.label-danger ×
|
||||
td.text-right rowspan="#{events.count}"
|
||||
= t('.unranked')
|
||||
td = event.title
|
||||
td.actions = action_buttons(@conference, event, [:show])
|
||||
- else
|
||||
|
|
|
@ -14,6 +14,14 @@
|
|||
dd = event.track.name
|
||||
dt = Event.human_attribute_name :language
|
||||
dd = t("locales.#{event.language}")
|
||||
- if event.ranked?
|
||||
dt = Event.human_attribute_name :rank
|
||||
dd title="#{t('management.conferences.vote_results.vote_ratio', votes: event.number_of_votes, total_votes: @conference.number_of_ballots_cast)}"
|
||||
.label.label-info
|
||||
= event.rank
|
||||
=< number_to_percentage(event.per_cent_of_votes, strip_insignificant_zeros: true, precision: 2)
|
||||
|
||||
|
||||
|
||||
td.visible-md.visible-lg.visible-xl
|
||||
= links_to_event_participants_for(event)
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
tr
|
||||
td = event.title
|
||||
td.text-center
|
||||
- if event.conference.has_vote_results?
|
||||
- if event.ranked?
|
||||
.large
|
||||
.label.label-info = event.rank
|
||||
td = event.conference.title
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
.panel.panel-info.panel-rank
|
||||
.panel-heading
|
||||
= t '.rank'
|
||||
- if @conference.has_vote_results?
|
||||
- if @event.ranked?
|
||||
.panel-body
|
||||
.row
|
||||
.col-xs-3
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
tr
|
||||
td = event.title
|
||||
td.text-center
|
||||
- if event.conference.has_vote_results?
|
||||
- if event.ranked?
|
||||
.large
|
||||
.label.label-info = event.rank
|
||||
td = event.conference.title
|
||||
|
|
|
@ -29,6 +29,7 @@ bg:
|
|||
fetch_vote_results: "Изтегли резултатите от гласуването"
|
||||
percent: "%"
|
||||
rank: "Позиция"
|
||||
unranked: "Няма данни"
|
||||
show:
|
||||
full_vote_results: "Пълни резултати от гласуването"
|
||||
vote_data_never_updated: "Резулатите от гласуването не са изтеглени"
|
||||
|
|
Loading…
Reference in New Issue