diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-06-30 03:55:42 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-06-30 19:22:24 +0200 |
| commit | 51629c5c42270a346885057a441095c964101cc1 (patch) | |
| tree | c2eaf148feb443ef51b20d3147fc9e368239ab12 /app/models/page.rb | |
| parent | 4705ef970469a852c7bdb4c097ba748e972c8f63 (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/page.rb')
| -rw-r--r-- | app/models/page.rb | 8 |
1 files changed, 4 insertions, 4 deletions
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 | ||
