diff --git a/app/controllers/management/events_controller.rb b/app/controllers/management/events_controller.rb index 229634a..af4e277 100644 --- a/app/controllers/management/events_controller.rb +++ b/app/controllers/management/events_controller.rb @@ -29,6 +29,12 @@ module Management end end + def conflicts + @conference = find_conference + @event = @conference.events.find(params[:id]) + @conflicts = @event.conflict_counts + end + def destroy @conference = find_conference @event = @conference.events.find(params[:id]) diff --git a/app/views/management/events/conflicts.html.slim b/app/views/management/events/conflicts.html.slim new file mode 100644 index 0000000..5b03bb4 --- /dev/null +++ b/app/views/management/events/conflicts.html.slim @@ -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') diff --git a/app/views/management/events/show.html.slim b/app/views/management/events/show.html.slim index 9554c34..1c411fa 100644 --- a/app/views/management/events/show.html.slim +++ b/app/views/management/events/show.html.slim @@ -110,5 +110,7 @@ - if @conference.has_vote_results? .panel-footer.text-right .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 = icon :refresh, t('management.conferences.vote_results.fetch_vote_results') diff --git a/config/locales/bg.yml b/config/locales/bg.yml index e0bc0dc..88cf97d 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -42,6 +42,11 @@ bg: percent: "%" rank: "Позиция" events: + conflicts: + conflicts: "Конфликти" + conflicts_of: "Конфликти на „%{event}“" + percent: "Процент" + hint_html: "Следващата таблица илюстрира какъв процент от посетителите, изявили интерес да присъстват на „%{event}“, биха желали да присъстват на всяко от посочените събития." edit: edit: "Редакция на %{event_type} „%{event_title}“" speaker: diff --git a/config/routes.rb b/config/routes.rb index 90f5254..d0663bb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -38,7 +38,11 @@ Rails.application.routes.draw do get :vote_results end - resources :events + resources :events do + member do + get :conflicts + end + end resources :volunteers resources :propositions resources :sponsorship_offers