Region selector and filter better scoped

remotes/origin/master
echarp 4 years ago
parent b617ee1dca
commit 61e67072c0
  1. 3
      app/models/region.rb
  2. 3
      app/views/regions/_filter.haml
  3. 8
      app/views/regions/_selector.haml

@ -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…
Cancel
Save