Sprankelprachtig aan/afmeldsysteem

participant.rb 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # A Participant represents the many-to-many relation between People and
  2. # Activities, and contains the information on whether or not the person plans
  3. # to be present at the activity.
  4. class Participant < ApplicationRecord
  5. # @!attribute is_organizer
  6. # @return [Boolean]
  7. # whether the person is an organizer for this event.
  8. #
  9. # @!attribute attending
  10. # @return [Boolean]
  11. # whether or not the person plans to attend the activity.
  12. #
  13. # @!attribute notes
  14. # @return [String]
  15. # a short text indicating any irregularities, such as arriving later or
  16. # leaving earlier.
  17. belongs_to :person
  18. belongs_to :activity
  19. validates :person_id,
  20. uniqueness: {
  21. scope: :activity_id,
  22. message: "person already participates in this activity"
  23. }
  24. # TODO: Move to a more appropriate place
  25. # @return [String]
  26. # the class for a row containing this activity.
  27. def row_class
  28. if self.attending
  29. "success"
  30. elsif self.attending == false
  31. "danger"
  32. else
  33. "warning"
  34. end
  35. end
  36. end