summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-06-30 03:55:42 +0200
committererdgeist <erdgeist@erdgeist.org>2026-06-30 19:22:24 +0200
commit51629c5c42270a346885057a441095c964101cc1 (patch)
treec2eaf148feb443ef51b20d3147fc9e368239ab12 /app/models
parent4705ef970469a852c7bdb4c097ba748e972c8f63 (diff)
Fix events CRUD for standalone events and add events to admin menu
- event_params now permits title, description, is_primary - event_information helper lists all node.events, not just the first - Occurrence.generate handles nil node (standalone events) - Page.aggregate order_by title uses correlated subquery to avoid GROUP BY conflict with tag-filter path; order_direction whitelisted to ASC/DESC to prevent SQL injection - Events link added to admin menu bar - events/index shows title, is_primary; drops latitude/longitude columns
Diffstat (limited to 'app/models')
-rw-r--r--app/models/occurrence.rb2
-rw-r--r--app/models/page.rb8
2 files changed, 5 insertions, 5 deletions
diff --git a/app/models/occurrence.rb b/app/models/occurrence.rb
index 143124f..777be24 100644
--- a/app/models/occurrence.rb
+++ b/app/models/occurrence.rb
@@ -35,7 +35,7 @@ class Occurrence < ApplicationRecord
35 self.create( 35 self.create(
36 :start_time => occurrence, 36 :start_time => occurrence,
37 :end_time => (occurrence + duration), 37 :end_time => (occurrence + duration),
38 :node_id => node.id, 38 :node_id => node&.id,
39 :event_id => event.id 39 :event_id => event.id
40 ) 40 )
41 end 41 end
diff --git a/app/models/page.rb b/app/models/page.rb
index 385b3f6..c982c2e 100644
--- a/app/models/page.rb
+++ b/app/models/page.rb
@@ -63,15 +63,15 @@ class Page < ApplicationRecord
63 end 63 end
64 end 64 end
65 65
66 direction = %w[ASC DESC].include?(options[:order_direction]&.upcase) ? options[:order_direction].upcase : "ASC"
67
66 if options[:order_by] == "title" 68 if options[:order_by] == "title"
67 return scope 69 return scope
68 .joins(:translations) 70 .order(Arel.sql("(SELECT pt.title FROM page_translations pt WHERE pt.page_id = pages.id AND pt.locale = #{ActiveRecord::Base.connection.quote(I18n.locale.to_s)}) #{direction}"))
69 .where(page_translations: { locale: I18n.locale })
70 .order("page_translations.title #{options[:order_direction]}")
71 .paginate(:page => page, :per_page => options[:limit]) 71 .paginate(:page => page, :per_page => options[:limit])
72 end 72 end
73 73
74 scope.order("#{options[:order_by]} #{options[:order_direction]}") 74 scope.order("#{options[:order_by]} #{direction}")
75 .paginate(:page => page, :per_page => options[:limit]) 75 .paginate(:page => page, :per_page => options[:limit])
76 end 76 end
77 77