1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- class Participant < ApplicationRecord
-
-
-
-
-
-
-
-
-
-
-
-
- belongs_to :person
- belongs_to :activity
- belongs_to :subgroup, optional: true
- validates :person_id,
- uniqueness: {
- scope: :activity_id,
- message: I18n.t('activities.errors.already_in')
- }
-
-
-
- def row_class
- if self.attending
- "success"
- elsif self.attending == false
- "danger"
- else
- "warning"
- end
- end
- def may_change?(person)
- self.activity.may_change?(person) ||
- self.person == person
- end
-
- def send_reminder
- return unless self.attending.nil?
- self.attending = true
- notes = self.notes || ""
- notes << '[auto]'
- self.notes = notes
- self.save
- return unless self.person.send_attendance_reminder
- ParticipantMailer.attendance_reminder(self.person, self.activity).deliver_later
- end
-
- def send_subgroup_notification
- return unless self.attending && self.subgroup
- ParticipantMailer.subgroup_notification(self.person, self.activity, self).deliver_later
- end
- end
|