summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorCharlie Root <root@web.ccc.local>2025-01-28 22:47:15 +0100
committerCharlie Root <root@web.ccc.local>2025-01-28 22:47:15 +0100
commitc4296b59a7f9d667d295f9c37b71f7849b818fb3 (patch)
treeccbace3a183c075991a0dfeb1dd9e6f25e901cf3 /app/models
parentdfbaadf0210b02a8bb54380c2c50302413dcf6d6 (diff)
Big overhaul patch and style changes
Diffstat (limited to 'app/models')
-rw-r--r--app/models/occurrence.rb3
-rw-r--r--app/models/page.rb12
2 files changed, 13 insertions, 2 deletions
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
16 :include => :node, 16 :include => :node,
17 :conditions => [ 17 :conditions => [
18 "start_time > ? AND end_time < ?", start_time, end_time 18 "start_time > ? AND end_time < ?", start_time, end_time
19 ] 19 ],
20 :order => "start_time"
20 ) 21 )
21 end 22 end
22 23
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
149 published_at.nil? ? true : published_at < Time.now 149 published_at.nil? ? true : published_at < Time.now
150 end 150 end
151 151
152 def effective_lang
153 if translated_locales.empty?
154 return 'de'
155 elsif translated_locales.include?(I18n.locale)
156 return I18n.locale
157 else
158 return translated_locales.first
159 end
160 end
161
152 # Returns true if a page has translations where one of them is significantly 162 # Returns true if a page has translations where one of them is significantly
153 # older than the other. 163 # older than the other.
154 # Takes the I18n.default locale and a second :locale to test if the 164 # Takes the I18n.default locale and a second :locale to test if the
@@ -238,4 +248,4 @@ class Page < ActiveRecord::Base
238 end 248 end
239 end 249 end
240 250
241end \ No newline at end of file 251end