Commit 6f556ee6 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider

Merge branch 'fix/volunteer_via_journal_association_not_found_in_deleted_case' into 'develop'

Fix/volunteer via journal association not found in deleted case

See merge request !923
parents dec403ce 09162cea
Pipeline #36172 passed with stage
in 35 minutes and 32 seconds
......@@ -10,7 +10,7 @@ class JournalsController < ApplicationController
end
def new
@journal = @journaled.journals.new
@journal = Journal.new
handle_semester_feedback_quote
authorize @journal
end
......@@ -18,8 +18,9 @@ class JournalsController < ApplicationController
def edit; end
def create
@journal = @journaled.journals.new(journal_params)
@journal = Journal.new(journal_params)
@journal.user = current_user
@journal.journalable = @journaled
authorize @journal
if @journal.save
redirect_to [@journaled, Journal], make_notice
......@@ -58,11 +59,15 @@ class JournalsController < ApplicationController
end
def handle_semester_feedback_quote
return unless params[:semester_feedback_id]
@semester_feedback = SemesterFeedback.find_by(id: params[:semester_feedback_id])
return unless @semester_feedback
return unless params[:sp_volunteer_id]
@journal.category = :feedback
@journal.title = "Semester Prozess Feedback vom #{I18n.l(@semester_feedback.created_at.to_date)}: "
@semester_process_volunteer = SemesterProcessVolunteer.find(params[:sp_volunteer_id])
@journal.journalable = @semester_process_volunteer.volunteer
@journal.title = "Semester Prozess Feedback vom #{I18n.l(@semester_process_volunteer.created_at.to_date)}: "
@semester_feedback = @semester_process_volunteer.semester_feedbacks&.first
return unless @semester_feedback
@journal.body = @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")
......
......@@ -12,28 +12,28 @@ nav.navbar.section-navigation
= bootstrap_paginate(@journals)
.table-responsive
table.table
thead
tr
th.hidden-print Aktionen
th= sort_link @q, :category
th= sort_link @q, :created_at
th= t_attr(:text)
th= t_attr(:author)
tbody
- @journals.each do |record|
tr
td.index-action-cell.hidden-print
= button_link icon_span(:edit), url_for([@journaled, record]) + '/edit',
title: 'Bearbeiten'
td= t("category.#{record.category}")
td= l(record.created_at.to_date)
td
- if record.title?
strong= record.title
br
= word_wrap(record.body) if record.body
td= link_to record.user.full_name, record.user.profile
table.table
thead
tr
th.hidden-print Aktionen
th= sort_link @q, :category
th= sort_link @q, :created_at
th= t_attr(:text)
th= t_attr(:author)
tbody
- @journals.each do |record|
tr
td.index-action-cell.hidden-print
= button_link icon_span(:edit), url_for([@journaled, record]) + '/edit',
title: 'Bearbeiten'
td= t("category.#{record.category}")
td= l(record.created_at.to_date)
td
- if record.title?
strong= record.title
br
= word_wrap(record.body) if record.body
td= link_to record.user.full_name, record.user.profile
= bootstrap_paginate(@journals)
......
......@@ -27,8 +27,8 @@ h1 Semester Prozess
td.index-action-cell.hidden-print
= button_link icon_span(:edit), review_semester_review_semester_url(spv), title: 'Bearbeiten'
= button_link icon_span(:journal), volunteer_journals_path(spv.volunteer), title: 'Journal'
= button_link icon_span(:journal_new), new_volunteer_journal_path(spv.volunteer,
semester_feedback_id: spv.semester_feedbacks.ids), title: 'Neuen Journal eintrag mit Zitat erstellen'
= button_link icon_span(:journal_new), new_volunteer_journal_path(spv.volunteer, sp_volunteer_id: spv.id),
title: 'Neuen Journal eintrag mit Zitat erstellen'
= button_link icon_span(:hours), volunteer_hours_path(spv.volunteer), title: 'Stunden'
td
- if spv.commited_at.present?
......
......@@ -13,7 +13,7 @@ class JournalsControllerTest < ActionDispatch::IntegrationTest
@spv = create(:semester_process_volunteer, volunteer: @volunteer)
@semester_feedback = create(:semester_feedback, :no_mission, semester_process_volunteer: @spv, volunteer: @volunteer)
get new_volunteer_journal_path(@volunteer, semester_feedback_id: @semester_feedback.id)
get new_volunteer_journal_path(@volunteer, sp_volunteer_id: @spv.id)
@journal = @controller.instance_variable_get(:@journal)
assert_equal @journal.category, 'feedback'
assert_equal @journal.title, "Semester Prozess Feedback vom #{I18n.l(@semester_feedback.created_at.to_date)}: "
......
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