It is now possible to filter organisations by region. Refs #11
This commit is contained in:
parent
6981b9a3ea
commit
79cb273d2c
@ -1,5 +1,7 @@
|
|||||||
# Groups life cycle
|
# Groups life cycle
|
||||||
class OrgasController < ApplicationController
|
class OrgasController < ApplicationController
|
||||||
|
has_scope :region
|
||||||
|
|
||||||
before_action :set_orga, except: [:index, :new, :create]
|
before_action :set_orga, except: [:index, :new, :create]
|
||||||
before_action :set_mailer_host
|
before_action :set_mailer_host
|
||||||
before_action :authenticate_user!, only: [:edit, :update],
|
before_action :authenticate_user!, only: [:edit, :update],
|
||||||
@ -8,7 +10,8 @@ class OrgasController < ApplicationController
|
|||||||
:destroy]
|
:destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@search = Orga.moderated.includes(:kind).includes(:region).search params[:q]
|
@search = apply_scopes(Orga).moderated.includes(:kind,
|
||||||
|
:region).search params[:q]
|
||||||
@search.sorts = 'updated_at desc' if @search.sorts.empty?
|
@search.sorts = 'updated_at desc' if @search.sorts.empty?
|
||||||
@orgas = @search.result.page params[:page]
|
@orgas = @search.result.page params[:page]
|
||||||
end
|
end
|
||||||
|
@ -17,6 +17,8 @@ class Orga < ActiveRecord::Base
|
|||||||
scope :moderated, -> { where moderated: true }
|
scope :moderated, -> { where moderated: true }
|
||||||
scope :unmoderated, -> { where moderated: false }
|
scope :unmoderated, -> { where moderated: false }
|
||||||
|
|
||||||
|
scope :region, ->(region) { where region: region unless region == 'all' }
|
||||||
|
|
||||||
before_validation do
|
before_validation do
|
||||||
unless submitter.blank?
|
unless submitter.blank?
|
||||||
self.secret ||= SecureRandom.urlsafe_base64(32)[0...32]
|
self.secret ||= SecureRandom.urlsafe_base64(32)[0...32]
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
= render 'search'
|
||||||
|
= render '/regions/selector'
|
||||||
|
|
||||||
%h2
|
%h2
|
||||||
%em.fa.fa-users
|
%em.fa.fa-users
|
||||||
= title t 'orgas.search.title', entity: Orga.model_name.human
|
= title t 'orgas.search.title', entity: Orga.model_name.human
|
||||||
|
|
||||||
= render 'search'
|
|
||||||
|
|
||||||
%table.list.autopagerize_page_element
|
%table.list.autopagerize_page_element
|
||||||
%thead
|
%thead
|
||||||
%th= sort_link @search, :kind_name, Orga.human_attribute_name(:kind)
|
%th= sort_link @search, :kind_name, Orga.human_attribute_name(:kind)
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
year: params[:year],
|
year: params[:year],
|
||||||
tag: params[:tag]
|
tag: params[:tag]
|
||||||
|
|
||||||
|
- unless controller.class == OrgasController
|
||||||
%li
|
%li
|
||||||
= link_to locality: 1,
|
= link_to locality: 1,
|
||||||
start_date: params[:start_date],
|
start_date: params[:start_date],
|
||||||
|
Loading…
Reference in New Issue
Block a user