From c4296b59a7f9d667d295f9c37b71f7849b818fb3 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Tue, 28 Jan 2025 22:47:15 +0100 Subject: Big overhaul patch and style changes --- app/models/occurrence.rb | 3 ++- app/models/page.rb | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/occurrence.rb b/app/models/occurrence.rb index 591e1e0..62432d5 100644 --- a/app/models/occurrence.rb +++ b/app/models/occurrence.rb @@ -16,7 +16,8 @@ class Occurrence < ActiveRecord::Base :include => :node, :conditions => [ "start_time > ? AND end_time < ?", start_time, end_time - ] + ], + :order => "start_time" ) end diff --git a/app/models/page.rb b/app/models/page.rb index c5da386..0cfad53 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -149,6 +149,16 @@ class Page < ActiveRecord::Base published_at.nil? ? true : published_at < Time.now end + def effective_lang + if translated_locales.empty? + return 'de' + elsif translated_locales.include?(I18n.locale) + return I18n.locale + else + return translated_locales.first + end + end + # Returns true if a page has translations where one of them is significantly # older than the other. # Takes the I18n.default locale and a second :locale to test if the @@ -238,4 +248,4 @@ class Page < ActiveRecord::Base end end -end \ No newline at end of file +end -- cgit v1.3