semester_process_volunteer.rb 1.27 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
class SemesterProcessVolunteer < ApplicationRecord
  belongs_to :volunteer
  belongs_to :semester_process
  belongs_to :responsible, -> { with_deleted }, class_name: 'User',
    inverse_of: 'semester_processes', optional: true
  belongs_to :reviewed_by, -> { with_deleted }, class_name: 'User',
    inverse_of: 'semester_processes', optional: true
  belongs_to :commited_by, -> { with_deleted }, class_name: 'User',
    inverse_of: 'semester_processes', optional: true

Kaspar Vollenweider's avatar
Kaspar Vollenweider committed
11
  has_many :semester_process_volunteer_missions, dependent: :destroy
12
13
14
  has_many :assignments, through: :semester_process_volunteer_missions
  has_many :group_assignments, through: :semester_process_volunteer_missions

15
  has_many :semester_feedbacks, dependent: :destroy
16
  has_many :hours, dependent: :nullify
17
18

  has_many :semester_process_mails, dependent: :destroy
19
20
21
22
  has_many :mails, -> { where(kind: 'mail') }, class_name: 'SemesterProcessMail',
    foreign_key: 'semester_process_volunteer_id', inverse_of: 'semester_process_volunteer'
  has_many :reminders, -> { where(kind: 'reminder') }, class_name: 'SemesterProcessMail',
    foreign_key: 'semester_process_volunteer_id', inverse_of: 'semester_process_volunteer'
23
24
25
26
27

  # will only return an array, not a AD-result
  def missions
    assignments + group_assignments
  end
28
end