Commit 95398b25 authored by Beat Seeliger's avatar Beat Seeliger

Merge branch 'fix/exception_half_year_report' into 'develop'

fix: scope for Volunteer.feedback_overdue replaced with working scope with semester

See merge request !951
parents ccdfb4df a6aa8468
Pipeline #47819 passed with stage
in 49 minutes and 48 seconds
......@@ -14,17 +14,26 @@ class SemesterProcessesController < ApplicationController
def create
@semester_process = SemesterProcess.new(semester_process_params.slice(:kind, :semester))
update_or_create
if update_or_create
redirect_to semester_process_volunteers_path, notice: I18n.t('semester_processes.create.notice')
else
render :new
end
end
def update
@save = params[:save_records]
update_or_create
if update_or_create
redirect_to semester_process_volunteers_path, notice: I18n.t("semester_processes.update.notice.#{semester_process_params[:kind]}")
else
render :new
end
end
def overdue
@semester_process.kind = :reminder
@volunteers = Volunteer.feedback_overdue(@semester_process.semester)
@volunteers = Volunteer.joins(:semester_process_volunteers)
.merge(@semester_process.semester_process_volunteers.unsubmitted)
@semester_process.build_semester_volunteers(@volunteers, preselect: true)
@spvs_sorted = sort_volunteers
......@@ -35,9 +44,7 @@ class SemesterProcessesController < ApplicationController
template = EmailTemplate.half_year_process_overdue.active.first.slice(:subject, :body)
@semester_process.assign_attributes(reminder_mail_body_template: template[:body], reminder_mail_subject_template: template[:subject])
else
redirect_to new_email_template_path,
notice: 'Sie müssen eine aktive E-Mailvorlage haben,
bevor Sie eine Halbjahres Erinnerung erstellen können.'
redirect_to new_email_template_path, notice: I18n.t('semester_processes.update.notice.missing_template')
end
end
......@@ -55,9 +62,7 @@ class SemesterProcessesController < ApplicationController
template = EmailTemplate.half_year_process_email.active.first.slice(:subject, :body)
@semester_process.assign_attributes(mail_body_template: template[:body], mail_subject_template: template[:subject])
else
redirect_to new_email_template_path,
notice: 'Sie müssen eine aktive E-Mailvorlage haben,
bevor Sie eine Halbjahres Erinnerung erstellen können.'
redirect_to new_email_template_path, notice: I18n.t('semester_processes.update.notice.missing_template')
end
end
......@@ -82,19 +87,18 @@ class SemesterProcessesController < ApplicationController
@semester_process.build_semester_volunteers(@volunteers, selected: selected_volunteers, save_records: true)
@semester_process.build_volunteers_feedbacks_and_mails
else
@semester_process.update_attributes(
@semester_process.assign_attributes(
reminder_mail_body_template: semester_process_params[:body],
reminder_mail_subject_template: semester_process_params[:subject]
)
@volunteers = Volunteer.feedback_overdue(@semester_process.semester)
@semester_process.build_volunteers_feedbacks_and_mails(selected_volunteers)
end
if @semester_process.save
redirect_to semester_process_volunteers_path, notice: 'Semester process was successfully created and emails delivered.'
else
render :new
@volunteers = Volunteer.joins(:semester_process_volunteers)
.merge(@semester_process.semester_process_volunteers.unsubmitted)
.find(selected_volunteers)
@semester_process.build_volunteers_feedbacks_and_mails(@volunteers.map(&:id))
end
@semester_process.save
end
def set_semester_process
......
......@@ -84,8 +84,8 @@ class SemesterProcess < ApplicationRecord
def build_volunteers_feedbacks_and_mails(collection = nil)
if collection
SemesterProcessVolunteer.where(volunteer_id: collection).map do |spv|
spv.build_mails(@kind)
semester_process_volunteers.where(volunteer_id: collection).map do |spv|
spv.build_mails(kind)
end
else
@new_semester_process_volunteers.map(&:build_mails)
......
......@@ -802,6 +802,14 @@ de:
hours:
new:
report_hours: "Stunden erfassen"
semester_processes:
create:
notice: Der Semesterprozess wurde erfolgreich erstellt und die emails wurden versendet.
update:
notice:
mail: Der Semesterprozess wurde erfolgreich aktualisiert.
reminder: Die errinnerungs emails wurden erfolgreich erstellt und versendet.
missing_template: Sie müssen eine aktive E-Mailvorlage haben, bevor Sie eine Halbjahres Erinnerung erstellen können.
semester_process_volunteers:
show:
title: 'Semester Prozess %{semester} von %{name}'
......
Markdown is supported
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