Region selector and filter better scoped
This commit is contained in:
parent
b617ee1dca
commit
61e67072c0
@ -6,7 +6,8 @@ class Region < ApplicationRecord
|
||||
has_many :orgas, dependent: :destroy
|
||||
|
||||
default_scope { order :name }
|
||||
scope :local, ->(*) { where 'url IS NULL OR url = \'\'' }
|
||||
scope :top, ->(*) { where(region: nil).includes(:regions).reorder :code }
|
||||
scope :local, ->(*) { where(url: nil).or(Region.where(url: '')) }
|
||||
scope :region, (lambda do |region|
|
||||
return if region.nil? || region == 'all' || region.to_i.zero?
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
-# Choose a region to filter events with
|
||||
%nav.region_filter
|
||||
%ul= render partial: '/regions/filter_region',
|
||||
collection: Region.where(region: nil).includes(:regions)
|
||||
%ul= render partial: '/regions/filter_region', collection: Region.top
|
||||
|
@ -1,3 +1,5 @@
|
||||
.radios= render partial: '/regions/selector_region',
|
||||
collection: Region.where(region: nil, url: ''),
|
||||
locals: { f: f }
|
||||
-# Select a region for an event or organisation
|
||||
.radios
|
||||
= render partial: '/regions/selector_region',
|
||||
collection: Region.top.local,
|
||||
locals: { f: f }
|
||||
|
Loading…
Reference in New Issue
Block a user