Commit dd9ce16b authored by Jiri Strojil's avatar Jiri Strojil
Browse files

Minor fixes

parent e5c2f19b
Pipeline #30757 failed with stage
in 36 minutes and 3 seconds
class SemesterProcessVolunteersController < ApplicationController
before_action :prepare_review, only: [:review_semester, :submit_review]
before_action :initialize_feedback, only: [:review_semester, :submit_review]
before_action :set_semester_process_volunteer, only: [:show, :edit, :update]
before_action :set_semester, only: [:index]
......@@ -21,15 +20,12 @@ class SemesterProcessVolunteersController < ApplicationController
@feedbacks.each(&:save!)
@hours.each(&:save!)
end
redirect_to(
review_semester_semester_process_volunteer_path(@semester_process_volunteer),
notice: 'Successfully reviewed.'
)
redirect_to review_semester_semester_process_volunteer_path(@semester_process_volunteer), notice: t('.success')
rescue ActiveRecord::RecordInvalid => exception
puts "ERROR!"
puts exception.message
null_reviewed
render :review_semester, notice: exception.message, errors: exception.message
render :review_semester
end
def index
......@@ -54,25 +50,31 @@ class SemesterProcessVolunteersController < ApplicationController
def build_nested_objects
@feedbacks, @hours = [], []
review_params[:semester_feedbacks_attributes].each do |_i, hash|
review_params[:semester_feedbacks_attributes].each do |_key, hash|
@feedbacks << SemesterFeedback.new(hash[:semester_feedback]
.merge({ author: current_user, semester_process_volunteer: @semester_process_volunteer }))
@hours << Hour.new(hash[:hour])
if hash[:hour][:hours]&.to_i.positive?
spv_mission = SemesterProcessVolunteerMission.find(hash[:hour][:spv_mission_id])
@hours << Hour.new(hash[:hour].merge({
hourable: spv_mission.mission.group_assignment? ? spv_mission.mission.group_offer : spv_mission.mission,
volunteer: spv_mission.volunteer,
meeting_date: Time.zone.now,
semester_process_volunteer: @semester_process_volunteer
}))
end
end
end
def prepare_review
# careful cuz mission id can be present in both missions
@semester_process_volunteer = SemesterProcessVolunteer.find(params[:id])
#@hours = @semester_process_volunteer.hours
authorize @semester_process_volunteer
@volunteer = @semester_process_volunteer.volunteer
@missions = @semester_process_volunteer.missions
authorize @semester_process_volunteer
end
def review_params
params.require(:semester_process_volunteer).permit(
volunteer_attributes: [:waive, :iban, :bank],
volunteer_attributes: [:id ,:waive, :iban, :bank],
semester_feedbacks_attributes: [[semester_feedback: [:mission, :goals, :achievements, :future, :comments, :conversation, :spv_mission_id]],
[hour: [:hours, :spv_mission_id ]]])
end
......
module SemesterProcessVolunteerHelper
def initialize_feedback
@feedback = SemesterFeedback.new(mission: @mission, semester_process_volunteer: @semester_process_volunteer,
author: current_user)
end
def set_reviewed
@semester_process_volunteer.commited_by = current_user
......
......@@ -44,7 +44,7 @@ class SemesterProcessVolunteer < ApplicationRecord
}
def semester_feedback_with_mission(mission)
self.semester_feedbacks.select{|sf| sf.mission == mission}.last
self.semester_feedbacks.order(:created_at).select{|sf| sf.mission == mission}.last
end
# will only return an array, not a AD-result
......
class SemesterProcessVolunteerMission < ApplicationRecord
include MissionEitherOneRelation
delegate :volunteer, to: :semester_process_volunteer
belongs_to :semester_process_volunteer
attr_accessor :hour
......
......@@ -192,6 +192,8 @@ de:
semester_process_volunteers:
show:
title: 'Semester Prozess %{semester} von %{name}'
submit_review:
success: Erfolgreich überprüft
salutation: &id-salutations
all: Alle
family: Familie
......
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