|
@@ -53,6 +53,8 @@ class Activity < ApplicationRecord
|
53
|
53
|
validate :deadline_before_start, unless: "self.deadline.blank?"
|
54
|
54
|
validate :end_after_start, unless: "self.end.blank?"
|
55
|
55
|
|
|
56
|
+ after_create :create_missing_participants!
|
|
57
|
+
|
56
|
58
|
# Get all people (not participants) that are organizers. Does not include
|
57
|
59
|
# group leaders, although they may modify the activity as well.
|
58
|
60
|
def organizers
|
|
@@ -88,6 +90,23 @@ class Activity < ApplicationRecord
|
88
|
90
|
self.group.is_leader(person)
|
89
|
91
|
end
|
90
|
92
|
|
|
93
|
+ # Create Participants for all People that
|
|
94
|
+ # 1. are members of the group
|
|
95
|
+ # 2. do not have Participants (and thus, no way to confirm) yet
|
|
96
|
+ def create_missing_participants!
|
|
97
|
+ people = self.group.people
|
|
98
|
+ if not self.participants.empty?
|
|
99
|
+ people = people.where('people.id NOT IN (?)', self.people.ids)
|
|
100
|
+ end
|
|
101
|
+
|
|
102
|
+ people.each do |p|
|
|
103
|
+ Participant.create(
|
|
104
|
+ activity: self,
|
|
105
|
+ person: p,
|
|
106
|
+ )
|
|
107
|
+ end
|
|
108
|
+ end
|
|
109
|
+
|
91
|
110
|
private
|
92
|
111
|
# Assert that the deadline for participants to change the deadline, if any,
|
93
|
112
|
# is set before the event starts.
|