Add rank display in EventsController#show
This commit is contained in:
parent
28071e1d7a
commit
4870eff959
|
@ -5,3 +5,7 @@
|
|||
.large {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.panel-rank {
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,10 @@ class Conference < ActiveRecord::Base
|
|||
vote_data_updated_at.present?
|
||||
end
|
||||
|
||||
def has_voting_endpoint?
|
||||
vote_data_endpoint.present?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def planned_cfp_end_date_is_before_start_date
|
||||
|
@ -82,13 +86,13 @@ class Conference < ActiveRecord::Base
|
|||
|
||||
private
|
||||
|
||||
def conn
|
||||
@conn ||= Faraday.new(url: conference.vote_data_endpoint + '/summary.json',
|
||||
def connection
|
||||
@connection ||= Faraday.new(url: conference.vote_data_endpoint + '/summary.json',
|
||||
headers: {'Content-Type' => 'application/json'})
|
||||
end
|
||||
|
||||
def remote_summary_data
|
||||
@remote_summary_data ||= JSON.parse(conn.get do |request|
|
||||
@remote_summary_data ||= JSON.parse(connection.get do |request|
|
||||
request.body = {summary: {talk_ids: Conference.last.events.pluck(:id)}}.to_json
|
||||
end.body)
|
||||
end
|
||||
|
|
|
@ -92,11 +92,11 @@
|
|||
h2
|
||||
=> t '.voting_results'
|
||||
small
|
||||
- if @conference.vote_data_updated_at.present?
|
||||
- if @conference.has_vote_results?
|
||||
= t '.vote_data_updated_at', updated_at: l(@conference.vote_data_updated_at, format: :long)
|
||||
.panel.panel-default
|
||||
table.table.table-striped.table-hover.record-table
|
||||
- if @conference.vote_data_updated_at.present?
|
||||
- if @conference.has_vote_results?
|
||||
thead
|
||||
tr
|
||||
th.text-right = t('.rank')
|
||||
|
@ -104,7 +104,7 @@
|
|||
th = Event.model_name.human.mb_chars.capitalize
|
||||
th
|
||||
tbody
|
||||
- if @conference.vote_data_updated_at.present?
|
||||
- if @conference.has_vote_results?
|
||||
- current_conference.events.order(rank: :asc).group_by(&:rank).to_a[0..9].each do |rank, events|
|
||||
- events.each.with_index do |event, index|
|
||||
tr
|
||||
|
@ -125,7 +125,7 @@
|
|||
p
|
||||
=< link_to update_vote_data_management_conference_path, method: :patch, class: ['btn', 'btn-primary'] do
|
||||
= icon :refresh, t('.fetch_vote_results')
|
||||
- if @conference.vote_data_updated_at.present?
|
||||
- if @conference.has_vote_results?
|
||||
.panel-footer.text-right
|
||||
.btn-group
|
||||
= link_to vote_results_management_conference_path, class: ['btn', 'btn-info'] do
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
.col-lg-12
|
||||
h1.page-header
|
||||
= t '.vote_results'
|
||||
- if @conference.vote_data_updated_at.present?
|
||||
- if @conference.has_vote_results?
|
||||
small<
|
||||
= t '.vote_data_updated_at', updated_at: l(@conference.vote_data_updated_at, format: :long)
|
||||
- if @conference.vote_data_endpoint.present?
|
||||
|
@ -13,7 +13,7 @@
|
|||
.col-lg-12
|
||||
.panel.panel-default
|
||||
table.table.table-striped.table-hover.record-table
|
||||
- if @conference.vote_data_updated_at.present?
|
||||
- if @conference.has_vote_results?
|
||||
thead
|
||||
tr
|
||||
th.text-right = t('.rank')
|
||||
|
@ -21,7 +21,7 @@
|
|||
th = Event.model_name.human.mb_chars.capitalize
|
||||
th
|
||||
tbody
|
||||
- if @conference.vote_data_updated_at.present?
|
||||
- if @conference.has_vote_results?
|
||||
- current_conference.events.order(rank: :asc).group_by(&:rank).each do |rank, events|
|
||||
- events.each.with_index do |event, index|
|
||||
tr
|
||||
|
@ -42,7 +42,7 @@
|
|||
p
|
||||
=< link_to update_vote_data_management_conference_path, method: :patch, class: ['btn', 'btn-primary'] do
|
||||
= icon :refresh, t('.fetch_vote_results')
|
||||
- if @conference.vote_data_updated_at.present?
|
||||
- if @conference.has_vote_results?
|
||||
.panel-footer.text-right
|
||||
.btn-group
|
||||
= link_to management_conference_path, class: ['btn', 'btn-info'] do
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
= @event.title
|
||||
small<
|
||||
= @event.subtitle
|
||||
.row
|
||||
.col-md-9
|
||||
h4
|
||||
= t 'events.metadata', type: @event.event_type.name, language: t("locales.#{@event.language}").mb_chars.downcase, length: @event.length
|
||||
.pull-right.heading-actions
|
||||
.col-md-3.text-right
|
||||
.heading-actions
|
||||
.dropdown>
|
||||
button class="btn btn-sm dropdown-toggle btn-#{proposition_status_class(@event.status)}" type="button" data-toggle="dropdown" title="#{t "status.#{@event.status}"}"
|
||||
= icon(proposition_status_glyph(@event.status))
|
||||
|
@ -24,7 +27,7 @@
|
|||
div.btn-group.btn-group-sm
|
||||
= action_buttons(@conference, @event, [:index, :edit])
|
||||
.row
|
||||
.col-xs-12
|
||||
= content_tag :div, class: @conference.has_vote_results? || @conference.has_voting_endpoint? ? 'col-md-9' : 'col-xs-12'
|
||||
h3 = Event.human_attribute_name :abstract
|
||||
p = simple_format @event.abstract
|
||||
|
||||
|
@ -33,6 +36,31 @@
|
|||
- if @event.notes.present?
|
||||
h3 = Event.human_attribute_name :notes
|
||||
p = simple_format @event.notes
|
||||
- if @conference.has_vote_results? or @conference.has_voting_endpoint?
|
||||
.col-md-3
|
||||
.panel.panel-info.panel-rank
|
||||
.panel-heading
|
||||
= t '.rank'
|
||||
- if @conference.has_vote_results?
|
||||
.panel-body
|
||||
.row
|
||||
.col-xs-3
|
||||
.huge
|
||||
.label.label-info
|
||||
= @event.rank
|
||||
.col-xs-9.text-right
|
||||
.huge
|
||||
= number_to_percentage(@event.per_cent_of_votes, strip_insignificant_zeros: true, precision: 2)
|
||||
= t('management.conferences.vote_results.vote_ratio', votes: @event.number_of_votes, total_votes: @conference.number_of_ballots_cast)
|
||||
- else
|
||||
.panel-body.text-center
|
||||
= t 'management.conferences.vote_results.vote_data_never_updated'
|
||||
|
||||
= link_to update_vote_data_management_conference_path(@conference), method: :patch do
|
||||
.panel-footer.text-primary.text-right
|
||||
= icon :refresh, t('management.conferences.vote_results.fetch_vote_results')
|
||||
|
||||
.row
|
||||
.col-xs-12
|
||||
h3 = Event.human_attribute_name :participants
|
||||
= render partial: 'speaker', collection: @event.participants
|
||||
|
|
|
@ -50,6 +50,7 @@ bg:
|
|||
previous_event_propositions: 'Предишни предложения за събития'
|
||||
contacts: "Информация за контакт"
|
||||
show:
|
||||
rank: "Класиране"
|
||||
review: "Преглед на %{event_type} „%{event_title}“"
|
||||
index:
|
||||
all: "Всички"
|
||||
|
|
Loading…
Reference in New Issue