moove all SemesterProcessVolunteerHelper to their actual controller as private methods

parent 121c4730
Pipeline #39344 passed with stage
in 51 minutes and 31 seconds
class ReviewSemestersController < ApplicationController
before_action :prepare_review, :initialize_nested_objects, only: [:review_semester, :submit_review]
include ReviewSemesterHelper, SemesterProcessVolunteerHelper
def review_semester; end
def submit_review
......@@ -100,6 +98,19 @@ class ReviewSemestersController < ApplicationController
@nested_objects
end
def render_semester_feedbacks(semester_feedbacks)
text = ''
semester_feedbacks.each do |semester_feedback|
text += semester_feedback.mission.to_label
text += "\n\n"
text += semester_feedback.slice(:goals, :achievements, :future, :comments).map do |key, sfb_quote|
"#{I18n.t("activerecord.attributes.feedback.#{key}")}:\n«#{sfb_quote}»" if sfb_quote.present?
end.compact.join("\n\n")
text += "\n\n"
end
text
end
def review_params
params.require(:semester_process_volunteer).permit(
volunteer_attributes: [:id, :waive, :iban, :bank],
......
......@@ -70,6 +70,19 @@ class SemesterProcessVolunteersController < ApplicationController
private
def set_responsibles
@responsibles = SemesterProcessVolunteer.joins(responsible: [profile: [:contact]])
.distinct
.select('users.id, contacts.full_name')
.map do |responsible|
{
q: :responsible_id_eq,
text: "Übernommen von #{responsible.full_name}",
value: responsible.id
}
end
end
def set_semester
@semester = Semester.new
if params[:semester]
......@@ -80,6 +93,26 @@ class SemesterProcessVolunteersController < ApplicationController
end
end
def set_reviewers
@reviewers = SemesterProcessVolunteer.joins(reviewed_by: [profile: [:contact]])
.distinct
.select('users.id, contacts.full_name')
.map do |reviewed_by|
{
q: :reviewed_by_id_eq,
text: "Quittiert von #{reviewed_by.full_name}",
value: reviewed_by.id
}
end
end
def set_semester_process_volunteer
@spv = SemesterProcessVolunteer.find(params[:id])
authorize @spv
@semester_process = @spv.semester_process
@volunteer = @spv.volunteer
end
def semester_process_volunteer_params
params.require(:semester_process_volunteer).permit(:semester, :notes)
end
......
module SemesterProcessVolunteerHelper
def render_semester_feedbacks(semester_feedbacks)
text = ''
semester_feedbacks.each do |semester_feedback|
text += semester_feedback.mission.to_label
text += "\n\n"
text += semester_feedback.slice(:goals, :achievements, :future, :comments).map do |key, sfb_quote|
"#{I18n.t("activerecord.attributes.feedback.#{key}")}:\n«#{sfb_quote}»" if sfb_quote.present?
end.compact.join("\n\n")
text += "\n\n"
end
text
end
def render_missions(spv)
html = ""
spv.missions.each do |m|
......@@ -20,37 +7,4 @@ module SemesterProcessVolunteerHelper
end
html.html_safe
end
def set_responsibles
@responsibles = SemesterProcessVolunteer.joins(responsible: [profile: [:contact]])
.distinct
.select('users.id, contacts.full_name')
.map do |responsible|
{
q: :responsible_id_eq,
text: "Übernommen von #{responsible.full_name}",
value: responsible.id
}
end
end
def set_reviewers
@reviewers = SemesterProcessVolunteer.joins(reviewed_by: [profile: [:contact]])
.distinct
.select('users.id, contacts.full_name')
.map do |reviewed_by|
{
q: :reviewed_by_id_eq,
text: "Quittiert von #{reviewed_by.full_name}",
value: reviewed_by.id
}
end
end
def set_semester_process_volunteer
@spv = SemesterProcessVolunteer.find(params[:id])
authorize @spv
@semester_process = @spv.semester_process
@volunteer = @spv.volunteer
end
end
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