adds available booths

This commit is contained in:
rgarcia
2017-09-08 21:59:54 +02:00
parent 90a5053ca8
commit 45d2fdd201
4 changed files with 14 additions and 2 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

@@ -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

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