From e8f95f4b5b13e5fefae692ffec94388b15c07b25 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 8 Sep 2017 12:39:23 +0200 Subject: [PATCH 1/7] Format link_to consistently --- app/views/proposals/show.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index 177228d76..1dc918e8e 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -23,7 +23,8 @@ <% end %> <% if author_of?(@proposal, current_user) %> - <%= link_to t("proposals.show.send_notification"), new_proposal_notification_path(proposal_id: @proposal.id), + <%= link_to t("proposals.show.send_notification"), + new_proposal_notification_path(proposal_id: @proposal.id), class: 'button hollow float-right' %> <% end %> From da3ef02e2fdb7fc63245b21c7504150803c96804 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 8 Sep 2017 12:45:20 +0200 Subject: [PATCH 2/7] Correctly indent admin login erb file --- app/views/shared/_admin_login_items.html.erb | 62 ++++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/app/views/shared/_admin_login_items.html.erb b/app/views/shared/_admin_login_items.html.erb index 85a367e97..5ba498523 100644 --- a/app/views/shared/_admin_login_items.html.erb +++ b/app/views/shared/_admin_login_items.html.erb @@ -1,37 +1,37 @@ <% if show_admin_menu? %> -
  • - <%= link_to t("layouts.header.administration_menu"), "#", rel: "nofollow" %> - +
  • <% end %> From 90a5053ca8c2efdbd314b14d54590e2330f0398f Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 8 Sep 2017 14:55:08 +0200 Subject: [PATCH 3/7] Correct consul github url on how to use translations --- config/locales/en/pages.yml | 4 ++-- config/locales/es/pages.yml | 6 +++--- config/locales/fr/general.yml | 4 ++-- config/locales/fr/pages.yml | 4 ++-- config/locales/nl/pages.yml | 6 +++--- config/locales/pt-BR/general.yml | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/config/locales/en/pages.yml b/config/locales/en/pages.yml index 83db1a8e4..d1884cbad 100644 --- a/config/locales/en/pages.yml +++ b/config/locales/en/pages.yml @@ -63,9 +63,9 @@ en: text: |- Use it in your local government or help us to improve it, it is free software. - This Open Government Portal use the [CONSUL app](https://github.com/ayuntamientomadrid 'consul github') that is free software, with [licence AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), that means in simple words that anyone can use the code freely, copy it, see it in detail, modify it and redistribute it to the word with the modifications he wants (allowing others to do the same). Because we think culture is better and richer when it is released. + This Open Government Portal use the [CONSUL app](https://github.com/consul/consul 'consul github') that is free software, with [licence AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), that means in simple words that anyone can use the code freely, copy it, see it in detail, modify it and redistribute it to the word with the modifications he wants (allowing others to do the same). Because we think culture is better and richer when it is released. - If you are a programmer, you can see the code and help us to improve it at [CONSUL app](https://github.com/ayuntamientomadrid 'consul github'). + If you are a programmer, you can see the code and help us to improve it at [CONSUL app](https://github.com/consul/consul 'consul github'). titles: how_to_use: Use it in your local government privacy: Privacy Policy diff --git a/config/locales/es/pages.yml b/config/locales/es/pages.yml index 81c916b5a..d67568b2d 100644 --- a/config/locales/es/pages.yml +++ b/config/locales/es/pages.yml @@ -63,9 +63,9 @@ es: text: |- Utilízalo en tu municipio libremente o ayúdanos a mejorarlo, es software libre. - Este Portal de Gobierno Abierto usa la [aplicación CONSUL](https://github.com/ayuntamientomadrid 'github consul') que es software libre, con [licencia AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), esto significa en palabras sencillas, que cualquiera puede libremente usar el código, copiarlo, verlo en detalle, modificarlo, y redistribuirlo al mundo con las modificaciones que quiera (manteniendo el que otros puedan a su vez hacer lo mismo). Porque creemos que la cultura es mejor y más rica cuando se libera. + Este Portal de Gobierno Abierto usa la [aplicación CONSUL](https://github.com/consul/consul 'github consul') que es software libre, con [licencia AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), esto significa en palabras sencillas, que cualquiera puede libremente usar el código, copiarlo, verlo en detalle, modificarlo, y redistribuirlo al mundo con las modificaciones que quiera (manteniendo el que otros puedan a su vez hacer lo mismo). Porque creemos que la cultura es mejor y más rica cuando se libera. - Si eres programador, puedes ver el código y ayudarnos a mejorarlo en [aplicación CONSUL](https://github.com/ayuntamientomadrid 'github consul'). + Si eres programador, puedes ver el código y ayudarnos a mejorarlo en [aplicación CONSUL](https://github.com/consul/consul 'github consul'). titles: how_to_use: Utilízalo en tu municipio privacy: Política de Privacidad @@ -81,4 +81,4 @@ es: info_code: 'Ahora introduce el código que has recibido en tu carta:' password: Contraseña submit: Verificar mi cuenta - title: Verifica tu cuenta \ No newline at end of file + title: Verifica tu cuenta diff --git a/config/locales/fr/general.yml b/config/locales/fr/general.yml index e4d0f9a51..cf1488375 100644 --- a/config/locales/fr/general.yml +++ b/config/locales/fr/general.yml @@ -1196,7 +1196,7 @@ fr: how_to_use: text: "Utilisez cet outil dans votre collectivité ou aidez-nous àl'améliorer, c'est un logiciel libre.\r\n\r\nCe portail de gouvernement ouvert utilise - cette [application Consul ](https://github.com/ayuntamientomadrid 'consul + cette [application Consul ](https://github.com/consul/consul 'consul github') qui est un logiciel libre, avec une [license AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), ce qui signifie en fait que n'importe qui peut utiliser le code librement, le copier, l'étudier en détail, le modifier et le redistribuer @@ -1207,7 +1207,7 @@ fr: la Mairie de Madrid autant que possible pour le faire. Si vous êtes intéressé, n'hésitez pas à nous contacter : ag.gobiernoabierto@consul.dev\r\n\r\nSi vous êtes développeur, vous pouvez voir le code et nous aider à l'améliorer - sur [Consul app](https://github.com/ayuntamientomadrid 'consul github ' + sur [Consul app](https://github.com/consul/consul 'consul github ' )." titles: faq: Solution pour les problèmes techniques (FAQ) diff --git a/config/locales/fr/pages.yml b/config/locales/fr/pages.yml index 42a4e3f2b..dcb57d400 100644 --- a/config/locales/fr/pages.yml +++ b/config/locales/fr/pages.yml @@ -59,9 +59,9 @@ fr: text: |- Utilisez le librement pour votre gouvernement ou aider nous à l'améliorer, c'est un logiciel libre. - Ce portail de Gouvernement Ouvert utilise l'[application Consul](https://github.com/ayuntamientomadrid 'consul github') qui est un logiciel libre, sous [licence AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), ce qui, en quelques mots, signifie que tout le monde peut utiliser le code librement, le copier, le voir en détail, le modifier et le redistribuer avec ces modifications (permettant à d'autres d'en faire de même). Car nous pensons que la culture est meilleure et plus riche quand elle est libre. + Ce portail de Gouvernement Ouvert utilise l'[application Consul](https://github.com/consul/consul 'consul github') qui est un logiciel libre, sous [licence AGPLv3](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ), ce qui, en quelques mots, signifie que tout le monde peut utiliser le code librement, le copier, le voir en détail, le modifier et le redistribuer avec ces modifications (permettant à d'autres d'en faire de même). Car nous pensons que la culture est meilleure et plus riche quand elle est libre. - Si vous êtes un développeur, vous pouvez voir le code et nous aider à l'améliorer en allant sur l'[applicationConsul](https://github.com/ayuntamientomadrid 'consul github'). + Si vous êtes un développeur, vous pouvez voir le code et nous aider à l'améliorer en allant sur l'[applicationConsul](https://github.com/consul/consul 'consul github'). titles: how_to_use: Utilisez-le pour votre gouvernement privacy: Politique de confidentialité diff --git a/config/locales/nl/pages.yml b/config/locales/nl/pages.yml index 71edb19fe..a07151243 100644 --- a/config/locales/nl/pages.yml +++ b/config/locales/nl/pages.yml @@ -60,9 +60,9 @@ nl: text: |- Gebruik het in uw gemeente en help ons het te verbeteren, het is gratis software. - Deze Open Overheid site gebruikt de [Consul web-app](https://github.com/ayuntamientomadrid 'consul github'). Gratis software, onder de [AGPLv3 Licentie](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ). Simpel gezegd betekend dit dat u de app kunt inspecteren, gebruiken, aanpassen en herdistribueren (onder voorwaarde dat anderen hetzelfde kunnen doen met uw versie). + Deze Open Overheid site gebruikt de [Consul web-app](https://github.com/consul/consul 'consul github'). Gratis software, onder de [AGPLv3 Licentie](http://www.gnu.org/licenses/agpl-3.0.html 'AGPLv3 gnu' ). Simpel gezegd betekend dit dat u de app kunt inspecteren, gebruiken, aanpassen en herdistribueren (onder voorwaarde dat anderen hetzelfde kunnen doen met uw versie). - Voor programmeurs: help ons het te verbeteren via [Consul app](https://github.com/ayuntamientomadrid 'consul github'). + Voor programmeurs: help ons het te verbeteren via [Consul app](https://github.com/consul/consul 'consul github'). titles: how_to_use: Gebruik het in uw gemeente privacy: Privacy Verklaring @@ -78,4 +78,4 @@ nl: info_code: 'en de code die u heeft ontvangen:' password: Wachtwoord submit: Verifieer mijn account - title: Verifieer uw account \ No newline at end of file + title: Verifieer uw account diff --git a/config/locales/pt-BR/general.yml b/config/locales/pt-BR/general.yml index 69ca72c02..816c14fa2 100644 --- a/config/locales/pt-BR/general.yml +++ b/config/locales/pt-BR/general.yml @@ -1212,7 +1212,7 @@ pt-BR: how_to_use: text: "Use este programa em seu governo local ou nos ajude a melhorá-lo, ele é um software livre.\r\n\r\nEste Portal de Governo Aberto usa o [app Consul] - (https://github.com/ayuntamientomadrid 'cônsul github'), que é um software + (https://github.com/consul/consul 'cônsul github'), que é um software livre, com [licença AGPLv3] (http://www.gnu.org/licenses/agpl- 3.0.html 'AGPLv3 gnu'), o que significa, em palavras simples que qualquer um pode usar o código livremente, copiá-lo, vê-lo em detalhes, modificá-lo e redistribuí-lo @@ -1223,7 +1223,7 @@ pt-BR: Madrid, o tanto quanto possível para fazê-lo, por isso, se você estiver interessado escreva-nos: ag.gobiernoabierto@consul.dev \r\n\r\nSe você é um programador, você - pode ver o código e nos ajudar a melhorá-lo em [app Consul] (https://github.com/ayuntamientomadrid + pode ver o código e nos ajudar a melhorá-lo em [app Consul] (https://github.com/consul/consul 'cônsul github')." titles: faq: Solução para problemas técnicos (FAQ) From 503a375b2f46f8bf4a1e97dc07891fb4c912d00a Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 8 Sep 2017 18:41:46 +0200 Subject: [PATCH 4/7] includes question controller name on polls subnavigation --- app/views/shared/_subnavigation.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_subnavigation.html.erb b/app/views/shared/_subnavigation.html.erb index 487edeb39..dd9809dd3 100644 --- a/app/views/shared/_subnavigation.html.erb +++ b/app/views/shared/_subnavigation.html.erb @@ -20,7 +20,7 @@
  • <%= layout_menu_link_to t("layouts.header.poll_questions"), polls_path, - controller_name == "polls", + controller_name == "polls" || controller_name == "questions", accesskey: "3", title: t("shared.go_to_page") + t("layouts.header.poll_questions") %>
  • From 45d2fdd201d1027e6d975312a70e87ba86785b45 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 8 Sep 2017 21:59:54 +0200 Subject: [PATCH 5/7] adds available booths --- app/controllers/admin/poll/booths_controller.rb | 5 +++++ app/models/abilities/administrator.rb | 2 +- app/models/poll/booth.rb | 7 ++++++- config/routes.rb | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/poll/booths_controller.rb b/app/controllers/admin/poll/booths_controller.rb index ff3700436..4b322f0b2 100644 --- a/app/controllers/admin/poll/booths_controller.rb +++ b/app/controllers/admin/poll/booths_controller.rb @@ -30,6 +30,11 @@ class Admin::Poll::BoothsController < Admin::BaseController end end + def available + @booths = Poll::Booth.available.order(name: :asc).page(params[:page]) + render :index + end + private def booth_params diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index db4cee09d..773dabf34 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -57,7 +57,7 @@ module Abilities can [:index, :create, :edit, :update, :destroy], Geozone can [:read, :create, :update, :destroy, :add_question, :remove_question, :search_booths, :search_questions, :search_officers], Poll - can [:read, :create, :update, :destroy], Poll::Booth + can [:read, :create, :update, :destroy, :available], Poll::Booth can [:search, :create, :index, :destroy], ::Poll::Officer can [:create, :destroy], ::Poll::BoothAssignment can [:create, :destroy], ::Poll::OfficerAssignment diff --git a/app/models/poll/booth.rb b/app/models/poll/booth.rb index 9edbcbaf0..0aca6eecb 100644 --- a/app/models/poll/booth.rb +++ b/app/models/poll/booth.rb @@ -5,10 +5,15 @@ class Poll has_many :shifts validates :name, presence: true, uniqueness: true - + def self.search(terms) return Booth.none if terms.blank? Booth.where("name ILIKE ? OR location ILIKE ?", "%#{terms}%", "%#{terms}%") end + + def self.available + where(polls: { id: Poll.current_or_incoming }).includes(:polls) + end + end end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index eaf6b98f4..a3f351e60 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -287,6 +287,8 @@ Rails.application.routes.draw do end resources :booths do + get :available, on: :collection + resources :shifts end From 0ad24c108070a1410fb614b9437565bec14237d9 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 8 Sep 2017 22:00:45 +0200 Subject: [PATCH 6/7] highlights correct item in admin menu --- app/helpers/admin_helper.rb | 2 +- app/views/admin/_menu.html.erb | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 9fadfea39..d56c658bd 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -25,7 +25,7 @@ module AdminHelper end def menu_polls? - ["polls", "questions", "officers", "booths", "officer_assignments", "booth_assignments", "recounts", "results"].include? controller_name + ["polls", "questions", "officers", "booths", "officer_assignments", "booth_assignments", "recounts", "results", "shifts"].include? controller_name end def menu_profiles? diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index b42e717b4..e629f5807 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -73,12 +73,15 @@ <%= link_to t('admin.menu.poll_officers'), admin_officers_path %> -
  • > +
  • > <%= link_to t('admin.menu.poll_booths'), admin_booths_path %>
  • -
  • > - <%= link_to t('admin.menu.poll_shifts'), admin_booths_path %> +
  • > + <%= link_to t('admin.menu.poll_shifts'), available_admin_booths_path %>
  • From 4d1f61a87ea6bbf9b019aabfe4d70df2d7289be4 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 8 Sep 2017 22:00:50 +0200 Subject: [PATCH 7/7] adds specs --- spec/features/admin/poll/booths_spec.rb | 26 +++++++++++++++++++++++++ spec/models/poll/booth_spec.rb | 21 ++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/spec/features/admin/poll/booths_spec.rb b/spec/features/admin/poll/booths_spec.rb index ec8c10d58..fd8fb9e84 100644 --- a/spec/features/admin/poll/booths_spec.rb +++ b/spec/features/admin/poll/booths_spec.rb @@ -36,6 +36,32 @@ feature 'Admin booths' do expect(page).to_not have_content "There are no booths" end + scenario "Available" do + booth_for_current_poll = create(:poll_booth) + booth_for_incoming_poll = create(:poll_booth) + booth_for_expired_poll = create(:poll_booth) + + current_poll = create(:poll, :current) + incoming_poll = create(:poll, :incoming) + expired_poll = create(:poll, :expired) + + create(:poll_booth_assignment, poll: current_poll, booth: booth_for_current_poll) + create(:poll_booth_assignment, poll: incoming_poll, booth: booth_for_incoming_poll) + create(:poll_booth_assignment, poll: expired_poll, booth: booth_for_expired_poll) + + visit admin_root_path + + within('#side_menu') do + click_link "Manage shifts" + end + + expect(page).to have_css(".booth", count: 2) + + expect(page).to have_content booth_for_current_poll.name + expect(page).to have_content booth_for_incoming_poll.name + expect(page).to_not have_content booth_for_expired_poll.name + end + scenario 'Show' do booth = create(:poll_booth) diff --git a/spec/models/poll/booth_spec.rb b/spec/models/poll/booth_spec.rb index c095c62cd..d340d8197 100644 --- a/spec/models/poll/booth_spec.rb +++ b/spec/models/poll/booth_spec.rb @@ -24,4 +24,25 @@ describe :booth do end end + describe "#available" do + + it "returns booths associated to current or incoming polls" do + booth_for_current_poll = create(:poll_booth) + booth_for_incoming_poll = create(:poll_booth) + booth_for_expired_poll = create(:poll_booth) + + current_poll = create(:poll, :current) + incoming_poll = create(:poll, :incoming) + expired_poll = create(:poll, :expired) + + create(:poll_booth_assignment, poll: current_poll, booth: booth_for_current_poll) + create(:poll_booth_assignment, poll: incoming_poll, booth: booth_for_incoming_poll) + create(:poll_booth_assignment, poll: expired_poll, booth: booth_for_expired_poll) + + expect(Poll::Booth.available).to include(booth_for_current_poll) + expect(Poll::Booth.available).to include(booth_for_incoming_poll) + expect(Poll::Booth.available).to_not include(booth_for_expired_poll) + end + + end end \ No newline at end of file