| 
				
			 | 
			
			
				@@ -137,9 +137,7 @@ class Activity < ApplicationRecord 
			 | 
		
	
		
			
			| 
				137
			 | 
			
				137
			 | 
			
			
				   #  2. do not have Participants (and thus, no way to confirm) yet 
			 | 
		
	
		
			
			| 
				138
			 | 
			
				138
			 | 
			
			
				   def create_missing_participants! 
			 | 
		
	
		
			
			| 
				139
			 | 
			
				139
			 | 
			
			
				     people = self.group.people 
			 | 
		
	
		
			
			| 
				140
			 | 
			
				
			 | 
			
			
				-    unless self.participants.empty? 
			 | 
		
	
		
			
			| 
				141
			 | 
			
				
			 | 
			
			
				-      people = people.where('people.id NOT IN (?)', self.people.ids) 
			 | 
		
	
		
			
			| 
				142
			 | 
			
				
			 | 
			
			
				-    end 
			 | 
		
	
		
			
			| 
				
			 | 
			
				140
			 | 
			
			
				+    people = people.where('people.id NOT IN (?)', self.people.ids) unless self.participants.empty? 
			 | 
		
	
		
			
			| 
				143
			 | 
			
				141
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				144
			 | 
			
				142
			 | 
			
			
				     people.each do |p| 
			 | 
		
	
		
			
			| 
				145
			 | 
			
				143
			 | 
			
			
				       Participant.create( 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -198,13 +196,9 @@ class Activity < ApplicationRecord 
			 | 
		
	
		
			
			| 
				198
			 | 
			
				196
			 | 
			
			
				         a.reminder_at = Time.zone.local(rd.year, rd.month, rd.day, rt.hour, rt.min) 
			 | 
		
	
		
			
			| 
				199
			 | 
			
				197
			 | 
			
			
				       end 
			 | 
		
	
		
			
			| 
				200
			 | 
			
				198
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				201
			 | 
			
				
			 | 
			
			
				-      unless row['subgroup_division_enabled'].blank? 
			 | 
		
	
		
			
			| 
				202
			 | 
			
				
			 | 
			
			
				-        a.subgroup_division_enabled = row['subgroup_division_enabled'].casecmp('y').zero? 
			 | 
		
	
		
			
			| 
				203
			 | 
			
				
			 | 
			
			
				-      end 
			 | 
		
	
		
			
			| 
				
			 | 
			
				199
			 | 
			
			
				+      a.subgroup_division_enabled = row['subgroup_division_enabled'].casecmp('y').zero? unless row['subgroup_division_enabled'].blank? 
			 | 
		
	
		
			
			| 
				204
			 | 
			
				200
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				205
			 | 
			
				
			 | 
			
			
				-      unless row['no_response_action'].blank? 
			 | 
		
	
		
			
			| 
				206
			 | 
			
				
			 | 
			
			
				-        a.no_response_action = row['no_response_action'].casecmp('p').zero? 
			 | 
		
	
		
			
			| 
				207
			 | 
			
				
			 | 
			
			
				-      end 
			 | 
		
	
		
			
			| 
				
			 | 
			
				201
			 | 
			
			
				+      a.no_response_action = row['no_response_action'].casecmp('p').zero? unless row['no_response_action'].blank? 
			 | 
		
	
		
			
			| 
				208
			 | 
			
				202
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				209
			 | 
			
				203
			 | 
			
			
				       result << a 
			 | 
		
	
		
			
			| 
				210
			 | 
			
				204
			 | 
			
			
				     end 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -271,9 +265,7 @@ class Activity < ApplicationRecord 
			 | 
		
	
		
			
			| 
				271
			 | 
			
				265
			 | 
			
			
				       groups.first[0] += 1 
			 | 
		
	
		
			
			| 
				272
			 | 
			
				266
			 | 
			
			
				     end 
			 | 
		
	
		
			
			| 
				273
			 | 
			
				267
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				274
			 | 
			
				
			 | 
			
			
				-    if mail 
			 | 
		
	
		
			
			| 
				275
			 | 
			
				
			 | 
			
			
				-      self.notify_subgroups! 
			 | 
		
	
		
			
			| 
				276
			 | 
			
				
			 | 
			
			
				-    end 
			 | 
		
	
		
			
			| 
				
			 | 
			
				268
			 | 
			
			
				+    self.notify_subgroups! if mail 
			 | 
		
	
		
			
			| 
				277
			 | 
			
				269
			 | 
			
			
				   end 
			 | 
		
	
		
			
			| 
				278
			 | 
			
				270
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				279
			 | 
			
				271
			 | 
			
			
				   def clear_subgroups!(only_assignable = true) 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -310,30 +302,22 @@ class Activity < ApplicationRecord 
			 | 
		
	
		
			
			| 
				310
			 | 
			
				302
			 | 
			
			
				   # Assert that the deadline for participants to change the deadline, if any, 
			 | 
		
	
		
			
			| 
				311
			 | 
			
				303
			 | 
			
			
				   # is set before the event starts. 
			 | 
		
	
		
			
			| 
				312
			 | 
			
				304
			 | 
			
			
				   def deadline_before_start 
			 | 
		
	
		
			
			| 
				313
			 | 
			
				
			 | 
			
			
				-    if self.deadline > self.start 
			 | 
		
	
		
			
			| 
				314
			 | 
			
				
			 | 
			
			
				-      errors.add(:deadline, I18n.t('activities.errors.must_be_before_start')) 
			 | 
		
	
		
			
			| 
				315
			 | 
			
				
			 | 
			
			
				-    end 
			 | 
		
	
		
			
			| 
				
			 | 
			
				305
			 | 
			
			
				+    errors.add(:deadline, I18n.t('activities.errors.must_be_before_start')) if self.deadline > self.start 
			 | 
		
	
		
			
			| 
				316
			 | 
			
				306
			 | 
			
			
				   end 
			 | 
		
	
		
			
			| 
				317
			 | 
			
				307
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				318
			 | 
			
				308
			 | 
			
			
				   # Assert that the activity's end, if any, occurs after the event's start. 
			 | 
		
	
		
			
			| 
				319
			 | 
			
				309
			 | 
			
			
				   def end_after_start 
			 | 
		
	
		
			
			| 
				320
			 | 
			
				
			 | 
			
			
				-    if self.end < self.start 
			 | 
		
	
		
			
			| 
				321
			 | 
			
				
			 | 
			
			
				-      errors.add(:end, I18n.t('activities.errors.must_be_after_start')) 
			 | 
		
	
		
			
			| 
				322
			 | 
			
				
			 | 
			
			
				-    end 
			 | 
		
	
		
			
			| 
				
			 | 
			
				310
			 | 
			
			
				+    errors.add(:end, I18n.t('activities.errors.must_be_after_start')) if self.end < self.start 
			 | 
		
	
		
			
			| 
				323
			 | 
			
				311
			 | 
			
			
				   end 
			 | 
		
	
		
			
			| 
				324
			 | 
			
				312
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				325
			 | 
			
				313
			 | 
			
			
				   # Assert that the reminder for non-response is sent while participants still 
			 | 
		
	
		
			
			| 
				326
			 | 
			
				314
			 | 
			
			
				   # can change their response. 
			 | 
		
	
		
			
			| 
				327
			 | 
			
				315
			 | 
			
			
				   def reminder_before_deadline 
			 | 
		
	
		
			
			| 
				328
			 | 
			
				
			 | 
			
			
				-    if self.reminder_at > self.deadline 
			 | 
		
	
		
			
			| 
				329
			 | 
			
				
			 | 
			
			
				-      errors.add(:reminder_at, I18n.t('activities.errors.must_be_before_deadline')) 
			 | 
		
	
		
			
			| 
				330
			 | 
			
				
			 | 
			
			
				-    end 
			 | 
		
	
		
			
			| 
				
			 | 
			
				316
			 | 
			
			
				+    errors.add(:reminder_at, I18n.t('activities.errors.must_be_before_deadline')) if self.reminder_at > self.deadline 
			 | 
		
	
		
			
			| 
				331
			 | 
			
				317
			 | 
			
			
				   end 
			 | 
		
	
		
			
			| 
				332
			 | 
			
				318
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				333
			 | 
			
				319
			 | 
			
			
				   # Assert that there is at least one divisible subgroup. 
			 | 
		
	
		
			
			| 
				334
			 | 
			
				320
			 | 
			
			
				   def subgroups_for_division_present 
			 | 
		
	
		
			
			| 
				335
			 | 
			
				
			 | 
			
			
				-    if self.subgroups.where(is_assignable: true).none? && subgroup_division_enabled? 
			 | 
		
	
		
			
			| 
				336
			 | 
			
				
			 | 
			
			
				-      errors.add(:subgroup_division_enabled, I18n.t('activities.errors.cannot_divide_without_subgroups')) 
			 | 
		
	
		
			
			| 
				337
			 | 
			
				
			 | 
			
			
				-    end 
			 | 
		
	
		
			
			| 
				
			 | 
			
				321
			 | 
			
			
				+    errors.add(:subgroup_division_enabled, I18n.t('activities.errors.cannot_divide_without_subgroups')) if self.subgroups.where(is_assignable: true).none? && subgroup_division_enabled? 
			 | 
		
	
		
			
			| 
				338
			 | 
			
				322
			 | 
			
			
				   end 
			 | 
		
	
		
			
			| 
				339
			 | 
			
				323
			 | 
			
			
				 end 
			 |