diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 2e35b8256..11fe4b482 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -2030,10 +2030,4 @@ } } } - - .number { - font-size: rem-calc(60); - font-weight: bold; - line-height: rem-calc(60); - } } diff --git a/app/assets/stylesheets/stats.scss b/app/assets/stylesheets/stats.scss index 97004acb4..418e93def 100644 --- a/app/assets/stylesheets/stats.scss +++ b/app/assets/stylesheets/stats.scss @@ -26,9 +26,58 @@ border-bottom: 1px solid $border; } + section section { + clear: both; + margin-top: rem-calc(30); + margin-bottom: rem-calc(30); + overflow: hidden; + } + h3 { font-size: rem-calc(20); - margin-bottom: 0; - margin-top: rem-calc(30); + margin-bottom: rem-calc(12); + } + + .participants { + $background-width: 52px; + + float: left; + margin-left: $background-width; + margin-right: rem-calc(22); + position: relative; + + &::before { + // TODO: change image and move it to a non-custom folder + content: image-url("custom/polls/stats_man.png"); + left: -$background-width; + position: absolute; + } + + .number { + display: block; + font-size: rem-calc(60); + font-weight: bold; + line-height: rem-calc(60); + } + + .info { + color: $dark-gray; + font-style: italic; + } + + &.gender { + + &.male { + &::before { + content: image-url("custom/polls/stats_man.png"); + } + } + + &.female { + &::before { + content: image-url("custom/polls/stats_woman.png"); + } + } + } } } diff --git a/app/models/poll/stats.rb b/app/models/poll/stats.rb index ebba64b35..5a166457e 100644 --- a/app/models/poll/stats.rb +++ b/app/models/poll/stats.rb @@ -3,15 +3,19 @@ class Poll::Stats alias_method :poll, :resource def self.stats_methods - %i[total_participants total_participants_web total_web_valid total_web_white total_web_null - total_participants_booth total_booth_valid total_booth_white total_booth_null - total_valid_votes total_white_votes total_null_votes valid_percentage_web valid_percentage_booth - total_valid_percentage white_percentage_web white_percentage_booth total_white_percentage - null_percentage_web null_percentage_booth total_null_percentage total_participants_web_percentage - total_participants_booth_percentage] + super + + %i[total_participants_web total_web_valid total_web_white total_web_null + total_participants_booth total_booth_valid total_booth_white total_booth_null + total_valid_votes total_white_votes total_null_votes valid_percentage_web valid_percentage_booth + total_valid_percentage white_percentage_web white_percentage_booth total_white_percentage + null_percentage_web null_percentage_booth total_null_percentage total_participants_web_percentage + total_participants_booth_percentage] end private + def participants + User.where(id: voters.pluck(:user_id)) + end def total_participants total_participants_web + total_participants_booth diff --git a/app/views/polls/stats.html.erb b/app/views/polls/stats.html.erb index e7513e3b6..346653654 100644 --- a/app/views/polls/stats.html.erb +++ b/app/views/polls/stats.html.erb @@ -14,6 +14,9 @@
  • <%= link_to t("stats.total_participants"), "#total_participants" %>
  • +
  • + <%= link_to t("stats.by_gender"), "#participants_by_gender" %> +
  • @@ -26,9 +29,29 @@

    <%= t("stats.total_participants") %>

    -

    - <%= t("polls.show.stats.total_votes") %>
    +

    <%= @stats[:total_participants] %> + <%= t("polls.show.stats.total_votes") %>
    +

    +
    + +
    +

    <%= t("stats.by_gender") %>

    + +

    + <%= @stats[:total_male_participants] %> + + <%= I18n.t("stats.men_percentage", + percentage: number_to_stats_percentage(@stats[:male_percentage])) %> + +

    + +

    + <%= @stats[:total_female_participants] %> + + <%= I18n.t("stats.women_percentage", + percentage: number_to_stats_percentage(@stats[:female_percentage])) %> +

    diff --git a/config/locales/en/budgets.yml b/config/locales/en/budgets.yml index b5039aea6..e1757b7a8 100644 --- a/config/locales/en/budgets.yml +++ b/config/locales/en/budgets.yml @@ -202,7 +202,6 @@ en: total_participants_booths: Vote phase booth participants participants: Participants supports: Supports - by_gender: "Participants by gender" total_male_participants: Mens total_female_participants: Women by_age: "Participants by age groups" diff --git a/config/locales/en/stats.yml b/config/locales/en/stats.yml index c1f7f1b23..101419948 100644 --- a/config/locales/en/stats.yml +++ b/config/locales/en/stats.yml @@ -2,3 +2,6 @@ en: stats: title: "Participation data" total_participants: "Participants" + by_gender: "Participants by gender" + men_percentage: "%{percentage} Men" + women_percentage: "%{percentage} Women" diff --git a/config/locales/es/budgets.yml b/config/locales/es/budgets.yml index eaa78c1d8..7b5c25b8e 100644 --- a/config/locales/es/budgets.yml +++ b/config/locales/es/budgets.yml @@ -203,7 +203,6 @@ es: participants: Participantes supports: Apoyos total: Total - by_gender: "Participación por género" total_male_participants: Hombres total_female_participants: Mujeres by_age: "Participación por grupos de edad" diff --git a/config/locales/es/stats.yml b/config/locales/es/stats.yml index 46c87d551..3ef82915e 100644 --- a/config/locales/es/stats.yml +++ b/config/locales/es/stats.yml @@ -2,3 +2,6 @@ es: stats: title: "Estadísticas de participación" total_participants: "Participantes" + by_gender: "Participación por género" + men_percentage: "%{percentage} Hombres" + women_percentage: "%{percentage} Mujeres"