Expose conflicts for all events

This commit is contained in:
Petko Bordjukov 2016-10-13 10:39:45 +03:00
parent a1a1aaaafb
commit 74505569c1
5 changed files with 68 additions and 1 deletions

View File

@ -29,6 +29,12 @@ module Management
end end
end end
def conflicts
@conference = find_conference
@event = @conference.events.find(params[:id])
@conflicts = @event.conflict_counts
end
def destroy def destroy
@conference = find_conference @conference = find_conference
@event = @conference.events.find(params[:id]) @event = @conference.events.find(params[:id])

View File

@ -0,0 +1,50 @@
- content_for :title
= t '.conflicts_of', event: @event.title
.row
.col-lg-12
h1.page-header
= t '.conflicts'
- if @conference.has_vote_results?
small<
= t 'management.conferences.vote_results.vote_data_updated_at', updated_at: l(@conference.vote_data_updated_at, format: :long)
- if @conference.vote_data_endpoint.present?
.row
.col-lg-12
p.lead
= t '.hint_html', event: @event.title
.panel.panel-default
table.table.table-striped.table-hover.record-table
- if @conference.has_vote_results?
thead
tr
th.text-right = t('.percent')
th = Event.model_name.human.mb_chars.capitalize
th
tbody
- if @conference.has_vote_results?
- @conflicts.each do |conflict_count|
- conflict_percent = Rational(conflict_count.number_of_conflicts, @conference.number_of_ballots_cast)
tr
td.text-right
.large
span.label.label-success data-conflicts="#{conflict_count.number_of_conflicts}" data-most-conflicts="#{@conference.most_conflicts}" data-least-conflicts="#{@conference.least_conflicts}"
= number_to_percentage(conflict_percent * 100, strip_insignificant_zeros: true, precision: 2)
td
h4 = conflict_count.right.title
h5 = conflict_count.right.subtitle
= links_to_event_participants_for(conflict_count.right)
td.actions
= action_buttons @conference, conflict_count.right, [:show]
- else
tr
td colspan="20"
= t 'management.conferences.vote_results.vote_data_never_updated'
= icon :refresh, t('management.conferences.vote_results.fetch_vote_results')
- if @conference.has_vote_results?
.panel-footer.text-right
.btn-group
= action_buttons @conference, @event, [:show, :index]
= link_to update_vote_data_management_conference_path(@conference), method: :patch, class: ['btn', 'btn-primary'] do
= icon :refresh, t('management.conferences.vote_results.fetch_vote_results')

View File

@ -110,5 +110,7 @@
- if @conference.has_vote_results? - if @conference.has_vote_results?
.panel-footer.text-right .panel-footer.text-right
.btn-group .btn-group
= link_to conflicts_management_conference_event_path(@event, conference_id: @conference.id), class: ['btn', 'btn-info'] do
= icon :percent, t('.conflicts')
= link_to update_vote_data_management_conference_path(@conference), method: :patch, class: ['btn', 'btn-primary'] do = link_to update_vote_data_management_conference_path(@conference), method: :patch, class: ['btn', 'btn-primary'] do
= icon :refresh, t('management.conferences.vote_results.fetch_vote_results') = icon :refresh, t('management.conferences.vote_results.fetch_vote_results')

View File

@ -42,6 +42,11 @@ bg:
percent: "%" percent: "%"
rank: "Позиция" rank: "Позиция"
events: events:
conflicts:
conflicts: "Конфликти"
conflicts_of: "Конфликти на „%{event}“"
percent: "Процент"
hint_html: "Следващата таблица илюстрира какъв процент от посетителите, изявили интерес да присъстват на <strong>„%{event}“</strong>, биха желали да присъстват на всяко от посочените събития."
edit: edit:
edit: "Редакция на %{event_type} „%{event_title}“" edit: "Редакция на %{event_type} „%{event_title}“"
speaker: speaker:

View File

@ -38,7 +38,11 @@ Rails.application.routes.draw do
get :vote_results get :vote_results
end end
resources :events resources :events do
member do
get :conflicts
end
end
resources :volunteers resources :volunteers
resources :propositions resources :propositions
resources :sponsorship_offers resources :sponsorship_offers