summaryrefslogtreecommitdiff
path: root/app/models/occurrence.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-06-30 19:15:22 +0200
committererdgeist <erdgeist@erdgeist.org>2026-06-30 19:22:24 +0200
commita7a6ad786eeb9f94f7882462bccbdd31e1bb4743 (patch)
treeecc0a17db462065b27270f7e593a8244e24c8846 /app/models/occurrence.rb
parent31ca8e93efa860d73918b57ddddeaedf9917b22d (diff)
Phase 1: standalone events, external_url on nodes
- Migration: node_id nullable on events and occurrences, add title/description/is_primary to events, external_url to nodes - Existing events marked is_primary: true (were all 1:1 with nodes) - Node: has_one :event -> has_many :events - Event: belongs_to :node optional, validates title presence for standalone events, is_primary uniqueness scoped to node_id, display_title helper falling back through node title - Occurrence: belongs_to :node optional, summary falls back to event.display_title - nodes_helper: event_information uses events.first (interim; will be replaced in Phase 3 event UI) - Tests: fix node.event -> node.events.first in event_test
Diffstat (limited to 'app/models/occurrence.rb')
-rw-r--r--app/models/occurrence.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/app/models/occurrence.rb b/app/models/occurrence.rb
index 3baf447..143124f 100644
--- a/app/models/occurrence.rb
+++ b/app/models/occurrence.rb
@@ -1,13 +1,12 @@
1# TODO Make a gem out of the c wrapper
2require 'chaos_calendar' 1require 'chaos_calendar'
3 2
4class Occurrence < ApplicationRecord 3class Occurrence < ApplicationRecord
5 4
6 # Associations 5 # Associations
7 6
8 belongs_to :node 7 belongs_to :node, optional: true
9 belongs_to :event 8 belongs_to :event
10 9
11 # Class Methods 10 # Class Methods
12 11
13 def self.find_in_range start_time, end_time 12 def self.find_in_range start_time, end_time
@@ -64,7 +63,7 @@ class Occurrence < ApplicationRecord
64 # Instance Methods 63 # Instance Methods
65 64
66 def summary 65 def summary
67 node.head.title 66 node&.head&.title || event.display_title
68 end 67 end
69 68
70end 69end