Merge branch 'master' into poll-shifts-search-officers

This commit is contained in:
BertoCQ
2017-09-11 00:07:12 +02:00
committed by GitHub
17 changed files with 117 additions and 54 deletions

View File

@@ -30,6 +30,11 @@ class Admin::Poll::BoothsController < Admin::BaseController
end end
end end
def available
@booths = Poll::Booth.available.order(name: :asc).page(params[:page])
render :index
end
private private
def booth_params def booth_params

View File

@@ -25,7 +25,7 @@ module AdminHelper
end end
def menu_polls? 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 end
def menu_profiles? def menu_profiles?

View File

@@ -57,7 +57,7 @@ module Abilities
can [:index, :create, :edit, :update, :destroy], Geozone 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, :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 [:search, :create, :index, :destroy], ::Poll::Officer
can [:create, :destroy], ::Poll::BoothAssignment can [:create, :destroy], ::Poll::BoothAssignment
can [:create, :destroy], ::Poll::OfficerAssignment can [:create, :destroy], ::Poll::OfficerAssignment

View File

@@ -10,5 +10,10 @@ class Poll
return Booth.none if terms.blank? return Booth.none if terms.blank?
Booth.where("name ILIKE ? OR location ILIKE ?", "%#{terms}%", "%#{terms}%") Booth.where("name ILIKE ? OR location ILIKE ?", "%#{terms}%", "%#{terms}%")
end end
def self.available
where(polls: { id: Poll.current_or_incoming }).includes(:polls)
end
end end
end end

View File

@@ -73,12 +73,15 @@
<%= link_to t('admin.menu.poll_officers'), admin_officers_path %> <%= link_to t('admin.menu.poll_officers'), admin_officers_path %>
</li> </li>
<li <%# "class=active" if controller_name == "booths" %>> <li <%= "class=active" if controller_name == "booths" &&
action_name != "available" %>>
<%= link_to t('admin.menu.poll_booths'), admin_booths_path %> <%= link_to t('admin.menu.poll_booths'), admin_booths_path %>
</li> </li>
<li <%= "class=active" if controller_name == "booths" %>> <li <%= "class=active" if controller_name == "shifts" ||
<%= link_to t('admin.menu.poll_shifts'), admin_booths_path %> controller_name == "booths" &&
action_name == "available" %>>
<%= link_to t('admin.menu.poll_shifts'), available_admin_booths_path %>
</li> </li>
</ul> </ul>
</li> </li>

View File

@@ -23,7 +23,8 @@
<% end %> <% end %>
<% if author_of?(@proposal, current_user) %> <% 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' %> class: 'button hollow float-right' %>
<% end %> <% end %>

View File

@@ -1,5 +1,5 @@
<% if show_admin_menu? %> <% if show_admin_menu? %>
<li> <li>
<%= link_to t("layouts.header.administration_menu"), "#", rel: "nofollow" %> <%= link_to t("layouts.header.administration_menu"), "#", rel: "nofollow" %>
<ul class="menu"> <ul class="menu">
<% if current_user.administrator? %> <% if current_user.administrator? %>
@@ -33,5 +33,5 @@
</li> </li>
<% end %> <% end %>
</ul> </ul>
</li> </li>
<% end %> <% end %>

View File

@@ -20,7 +20,7 @@
<li> <li>
<%= layout_menu_link_to t("layouts.header.poll_questions"), <%= layout_menu_link_to t("layouts.header.poll_questions"),
polls_path, polls_path,
controller_name == "polls", controller_name == "polls" || controller_name == "questions",
accesskey: "3", accesskey: "3",
title: t("shared.go_to_page") + t("layouts.header.poll_questions") %> title: t("shared.go_to_page") + t("layouts.header.poll_questions") %>
</li> </li>

View File

@@ -63,9 +63,9 @@ en:
text: |- text: |-
Use it in your local government or help us to improve it, it is free software. 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: titles:
how_to_use: Use it in your local government how_to_use: Use it in your local government
privacy: Privacy Policy privacy: Privacy Policy

View File

@@ -63,9 +63,9 @@ es:
text: |- text: |-
Utilízalo en tu municipio libremente o ayúdanos a mejorarlo, es software libre. 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: titles:
how_to_use: Utilízalo en tu municipio how_to_use: Utilízalo en tu municipio
privacy: Política de Privacidad privacy: Política de Privacidad

View File

@@ -1196,7 +1196,7 @@ fr:
how_to_use: how_to_use:
text: "Utilisez cet outil dans votre collectivité ou aidez-nous àl'améliorer, 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 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 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 '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 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é, la Mairie de Madrid autant que possible pour le faire. Si vous êtes intéressé,
n'hésitez pas à nous contacter : <a href='mailto:ag.gobiernoabierto@consul.dev'>ag.gobiernoabierto@consul.dev</a>\r\n\r\nSi n'hésitez pas à nous contacter : <a href='mailto:ag.gobiernoabierto@consul.dev'>ag.gobiernoabierto@consul.dev</a>\r\n\r\nSi
vous êtes développeur, vous pouvez voir le code et nous aider à l'améliorer 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: titles:
faq: Solution pour les problèmes techniques (FAQ) faq: Solution pour les problèmes techniques (FAQ)

View File

@@ -59,9 +59,9 @@ fr:
text: |- text: |-
Utilisez le librement pour votre gouvernement ou aider nous à l'améliorer, c'est un logiciel libre. 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: titles:
how_to_use: Utilisez-le pour votre gouvernement how_to_use: Utilisez-le pour votre gouvernement
privacy: Politique de confidentialité privacy: Politique de confidentialité

View File

@@ -60,9 +60,9 @@ nl:
text: |- text: |-
Gebruik het in uw gemeente en help ons het te verbeteren, het is gratis software. 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: titles:
how_to_use: Gebruik het in uw gemeente how_to_use: Gebruik het in uw gemeente
privacy: Privacy Verklaring privacy: Privacy Verklaring

View File

@@ -1212,7 +1212,7 @@ pt-BR:
how_to_use: how_to_use:
text: "Use este programa em seu governo local ou nos ajude a melhorá-lo, ele 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] é 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 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 '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 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 Madrid, o tanto quanto possível para fazê-lo, por isso, se você estiver
interessado escreva-nos: <a href = \"mailto: ag.gobiernoabierto@consul.dev interessado escreva-nos: <a href = \"mailto: ag.gobiernoabierto@consul.dev
'> ag.gobiernoabierto@consul.dev </a>\r\n\r\nSe você é um programador, você '> ag.gobiernoabierto@consul.dev </a>\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')." 'cônsul github')."
titles: titles:
faq: Solução para problemas técnicos (FAQ) faq: Solução para problemas técnicos (FAQ)

View File

@@ -287,6 +287,8 @@ Rails.application.routes.draw do
end end
resources :booths do resources :booths do
get :available, on: :collection
resources :shifts do resources :shifts do
get :search_officers, on: :collection get :search_officers, on: :collection
end end

View File

@@ -36,6 +36,32 @@ feature 'Admin booths' do
expect(page).to_not have_content "There are no booths" expect(page).to_not have_content "There are no booths"
end 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 scenario 'Show' do
booth = create(:poll_booth) booth = create(:poll_booth)

View File

@@ -24,4 +24,25 @@ describe :booth do
end end
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 end