diff --git a/app/models/region.rb b/app/models/region.rb index a73056cd..dad5551f 100644 --- a/app/models/region.rb +++ b/app/models/region.rb @@ -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? diff --git a/app/views/regions/_filter.haml b/app/views/regions/_filter.haml index 4667a6ad..7ebdbd8f 100644 --- a/app/views/regions/_filter.haml +++ b/app/views/regions/_filter.haml @@ -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 diff --git a/app/views/regions/_selector.haml b/app/views/regions/_selector.haml index 6dc21b2b..309635e3 100644 --- a/app/views/regions/_selector.haml +++ b/app/views/regions/_selector.haml @@ -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 }