vol1ura/Sat_9am_5km

View on GitHub
app/views/admin/athletes/_athlete.html.arb

Summary

Maintainability
Test Coverage
# frozen_string_literal: true

attributes_table_for athlete do
  row :id
  row :parkrun_code
  row :fiveverst_code
  row :runpark_code
  row :parkzhrun_code
  row :gender
  row :club
  row :event
  if current_user.admin?
    row :user
  else
    row(:registered) { |a| a.user_id.present? }
  end
  row(:id_info) { |a| athlete_code_id a }
  row(:profile) { |a| link_to athlete_url(a), a }
  row(:results) { |a| link_to "смотреть таблицу (всего #{a.results.size} в т.ч. неопуб.)", results_admin_athlete_path(a) }
  row(:volunteering) { |a| link_to "смотреть таблицу (всего #{a.volunteering.size})", volunteering_admin_athlete_path(a) }
end

panel 'Предстоящие волонтёрства' do
  dataset =
    athlete
      .volunteering
      .includes(activity: :event)
      .where(activity: { date: Date.current.. })
      .rewhere(activity: { published: false })
  table_for dataset do
    column('Забег') { |v| link_to human_activity_name(v.activity), admin_activity_path(v.activity) }
    column('Роль') { |v| human_volunteer_role v.role }
  end
end

if !athlete.user_id && current_user.admin?
  panel 'Правки' do
    render partial: 'admin/audits_table', locals: { object: athlete }
  end
end