Commit 83bed1c8 authored by Beat Seeliger's avatar Beat Seeliger

Merge branch 'features/add-journal-entry-to-spv-index' into 'develop'

Features/add journal entry to spv index

See merge request !857
parents a93c934a 8a363043
Pipeline #31547 failed with stage
in 37 minutes and 1 second
......@@ -12,6 +12,7 @@ class JournalsController < ApplicationController
def new
@journal = @journaled.journals.new
handle_feedback_quote
handle_semester_feedback_quote
authorize @journal
end
......@@ -68,6 +69,17 @@ class JournalsController < ApplicationController
end.compact.join("\n\n")
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
@journal.category = :feedback
@journal.title = "Semester Prozess Feedback vom #{I18n.l(@semester_feedback.created_at.to_date)}: "
@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")
end
def journal_params
params.require(:journal).permit(
:category, :user_id, :body, :title, :client_id, :volunteer_id
......
......@@ -9,7 +9,7 @@ h1= t_title(:index)
thead
tr
th.hidden-print Aktionen
th.limit-width Stunden
th.limit-width Journal / Stunden
th Status
th.limit-width Freiwilige/r
th Einsätze
......@@ -27,6 +27,9 @@ h1= t_title(:index)
td.index-action-cell.hidden-print
= button_link icon_span(:edit), review_semester_semester_process_volunteer_path(spv), title: 'Bearbeiten'
td.index-action-cell.hidden-print
= 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(:hours), volunteer_hours_path(spv.volunteer), title: 'Stunden'
td
- if spv.commited_at.present?
......
......@@ -3,14 +3,14 @@ require 'test_helper'
class JournalsControllerTest < ActionDispatch::IntegrationTest
setup do
@superadmin = create :user
@reminder_mailing = create :reminder_mailing, :half_year
@reminder_mailing = create :reminder_mailing, :trial_period
@assignment = @reminder_mailing.reminder_mailing_volunteers.first.reminder_mailable
@volunteer = @assignment.volunteer
@feedback = create :feedback, feedbackable: @assignment, volunteer: @volunteer, author: @volunteer.user
login_as @superadmin
end
test '#new prefilles with feedback quote if feedback_id param is passed' do
login_as @superadmin
test '#new prefilles with feedback quote if feedback_id param is passed for trial period' do
get new_volunteer_journal_path(@volunteer, feedback_id: @feedback.id)
@journal = @controller.instance_variable_get(:@journal)
assert_equal @journal.category, 'feedback'
......@@ -20,4 +20,18 @@ class JournalsControllerTest < ActionDispatch::IntegrationTest
assert @journal.body.include? @feedback.future
assert @journal.body.include? @feedback.comments
end
test '#new prefilling for semester feedback quote if semester_feedback_id param is passed works also' do
@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)
@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)}: "
assert @journal.body.include? @semester_feedback.goals
assert @journal.body.include? @semester_feedback.achievements
assert @journal.body.include? @semester_feedback.future
assert @journal.body.include? @semester_feedback.comments
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