Verified Commit b5456f7f authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

feat(semester-process-volunteer): add builder that creates hours relations, feedbacks and mails

- relations to all hours with meeting date within the semester
- scaffold empty semesterFeedback record for each mission related
- build the SemesterProcessMail.kind == :mail for the initial mail
parent a479287d
...@@ -3,6 +3,9 @@ class SemesterProcessVolunteer < ApplicationRecord ...@@ -3,6 +3,9 @@ class SemesterProcessVolunteer < ApplicationRecord
belongs_to :volunteer belongs_to :volunteer
belongs_to :semester_process belongs_to :semester_process
delegate :semester, to: :semester_process
delegate :creator, to: :semester_process
belongs_to :responsible, -> { with_deleted }, class_name: 'User', belongs_to :responsible, -> { with_deleted }, class_name: 'User',
inverse_of: 'semester_processes', optional: true inverse_of: 'semester_processes', optional: true
belongs_to :reviewed_by, -> { with_deleted }, class_name: 'User', belongs_to :reviewed_by, -> { with_deleted }, class_name: 'User',
...@@ -37,4 +40,11 @@ class SemesterProcessVolunteer < ApplicationRecord ...@@ -37,4 +40,11 @@ class SemesterProcessVolunteer < ApplicationRecord
end end
end end
def build_hours_feedbacks_and_mails
missions.each do |mission|
hours << mission.hours.date_between_inclusion(:meeting_date, semester.begin, semester.end)
semester_feedbacks << SemesterFeedback.new(mission: mission, volunteer: mission.volunteer)
end
semester_process_mails << SemesterProcessMail.new(kind: :mail, sent_by: creator)
end
end end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment