From 0e8746299dcd0a7b6d7a210ca1558f932dca7088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Salvador=20P=C3=A9rez=20Garc=C3=ADa?= Date: Wed, 18 Jul 2018 16:50:51 +0200 Subject: [PATCH 1/3] Fixes #232 In proposal's dashboard, inside community section, the latests topics has been replaced by latest messages. --- app/models/community.rb | 6 +++++- app/views/proposals_dashboard/_comment.html.erb | 10 ++++++++++ app/views/proposals_dashboard/_topic.html.erb | 8 -------- app/views/proposals_dashboard/community.html.erb | 6 +++--- config/locales/en/general.yml | 2 +- config/locales/es/general.yml | 2 +- 6 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 app/views/proposals_dashboard/_comment.html.erb delete mode 100644 app/views/proposals_dashboard/_topic.html.erb diff --git a/app/models/community.rb b/app/models/community.rb index 9a18f3510..f1640c8e9 100644 --- a/app/models/community.rb +++ b/app/models/community.rb @@ -27,7 +27,11 @@ class Community < ActiveRecord::Base end def comments_count - Comment.where(commentable: topics).count + comments.count + end + + def comments + Comment.where(commentable: topics) end def debates_count diff --git a/app/views/proposals_dashboard/_comment.html.erb b/app/views/proposals_dashboard/_comment.html.erb new file mode 100644 index 000000000..4bb5bc88e --- /dev/null +++ b/app/views/proposals_dashboard/_comment.html.erb @@ -0,0 +1,10 @@ +
  • + <%= comment.body %> +

    + <%= comment.commentable.title %> + - + <%= l(comment.updated_at.to_date) %> + - + <%= comment.author.name %> +

    +
  • diff --git a/app/views/proposals_dashboard/_topic.html.erb b/app/views/proposals_dashboard/_topic.html.erb deleted file mode 100644 index becd154c6..000000000 --- a/app/views/proposals_dashboard/_topic.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -
  • - <%= topic.title %> -

    - <%= l(topic.updated_at.to_date) %> - - - <%= topic.author.name %> -

    -
  • diff --git a/app/views/proposals_dashboard/community.html.erb b/app/views/proposals_dashboard/community.html.erb index 6a4a1997c..54c15bf0e 100644 --- a/app/views/proposals_dashboard/community.html.erb +++ b/app/views/proposals_dashboard/community.html.erb @@ -27,13 +27,13 @@ -<% if proposal.community.topics.any? %> +<% if proposal.community.comments.any? %>
    -
    <%= t('.latest_topics') %>
    +
    <%= t('.latest_comments') %>

    <% end %> diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 8ff50b829..fadb75182 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -560,7 +560,7 @@ en: participants: Participants debates: Debates comments: Comments - latest_topics: Latest topics + latest_comments: Latest messages dashboard: polls: index: diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 3c2d6fdd9..91a461d55 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -560,7 +560,7 @@ es: participants: Participantes debates: Debates comments: Comentarios - latest_topics: Últimos debates + latest_comments: Últimos mensajes dashboard: polls: index: From 4ee0a94241289dfee6c082c77e4b6ca52dd1d85c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Salvador=20P=C3=A9rez=20Garc=C3=ADa?= Date: Thu, 19 Jul 2018 10:00:37 +0200 Subject: [PATCH 2/3] Fixed last minute bugs Fixed last minute bugs with polls --- app/models/poll.rb | 1 + app/views/dashboard/polls/_poll.html.erb | 6 ++---- config/locales/en/general.yml | 1 + config/locales/es/general.yml | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index 756c01eec..f01960bd6 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -39,6 +39,7 @@ class Poll < ActiveRecord::Base scope :overlaping_with, lambda { |poll| where('? < ends_at and ? >= starts_at', poll.starts_at.beginning_of_day, poll.ends_at.end_of_day) .where.not(id: poll.id) + .where(related: poll.related) } scope :sort_for_list, -> { order(:geozone_restricted, :starts_at, :name) } diff --git a/app/views/dashboard/polls/_poll.html.erb b/app/views/dashboard/polls/_poll.html.erb index 3c6ff0b44..f437428ac 100644 --- a/app/views/dashboard/polls/_poll.html.erb +++ b/app/views/dashboard/polls/_poll.html.erb @@ -19,11 +19,9 @@
    <% if poll.incoming? %> - <%= link_to 'Editar encuesta', edit_proposal_dashboard_poll_path(proposal, poll), class: 'button hollow' %> + <%= link_to t('.edit_poll'), edit_proposal_dashboard_poll_path(proposal, poll), class: 'button hollow' %> <% else %> - - <%= t('.view_responses') %> - + <%= link_to t('.view_responses'), proposal_dashboard_poll_path(proposal, poll), class: 'button' %> <% end %>
    diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index fadb75182..519a9981a 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -577,6 +577,7 @@ en: one: "%{count} response" other: "%{count} responses" view_responses: View responses + edit_poll: Edit survey show_results: Show results show_results_help: If you check this box the results will be public and all users will be able to see them form: diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 91a461d55..e4823db03 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -577,6 +577,7 @@ es: one: "%{count} respuesta" other: "%{count} respuestas" view_responses: Ver respuestas + edit_poll: Editar encuesta show_results: Mostrar resultados show_results_help: Si marcas esta casilla los resultados serán públicos y todos los usuarios podrán verlos form: From c68061219dbd8c5ddece8e7a94820d26090a3756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Salvador=20P=C3=A9rez=20Garc=C3=ADa?= Date: Thu, 19 Jul 2018 10:07:41 +0200 Subject: [PATCH 3/3] Removed edit poll button from view responses --- app/views/dashboard/polls/_poll_header.html.erb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/views/dashboard/polls/_poll_header.html.erb b/app/views/dashboard/polls/_poll_header.html.erb index 2204f5e0f..7bc148ca5 100644 --- a/app/views/dashboard/polls/_poll_header.html.erb +++ b/app/views/dashboard/polls/_poll_header.html.erb @@ -1,7 +1,3 @@ -<%= link_to t("admin.polls.edit.title"), - edit_proposal_dashboard_poll_path(proposal, poll), - class: "button hollow float-right" %> -

    <%= poll.name %>