Commit cd331b3b authored by Jiri Strojil's avatar Jiri Strojil

Merge branch 'fixes/records-occur-more-than-once' into 'develop'

Fixes/records occur more than once

See merge request !853
parents a681c92d f1f70383
Pipeline #31523 passed with stage
in 52 minutes and 10 seconds
......@@ -40,7 +40,7 @@ class SemesterProcessVolunteersController < ApplicationController
authorize SemesterProcessVolunteer
semester = Semester.parse(params[:semester])
@semester_process = SemesterProcess.find_by_semester(semester).last
@q = SemesterProcessVolunteer.index(semester).ransack(params[:q])
@q = SemesterProcessVolunteer.index(@semester_process).ransack(params[:q])
@q.sorts = ['volunteer_contact_last_name asc'] if @q.sorts.empty?
@spvs = @q.result.paginate(page: params[:page])
set_responsibles
......
......@@ -32,16 +32,10 @@ class SemesterProcessVolunteer < ApplicationRecord
validates_associated :hours, :semester_feedbacks, :volunteer
scope :index_joins, lambda {
joins(:semester_process).joins(volunteer: [:contact]).joins(:semester_process_volunteer_missions)
}
scope :index, lambda { |semester = nil|
if semester
index_joins.where('semester_processes.semester && daterange(?,?)', semester.begin, semester.end)
else
index_joins
end
joins(:semester_process).where(semester_process: semester)
.joins(:semester_process_volunteer_missions, volunteer: [:contact])
.group('semester_process_volunteers.id, contacts_volunteers.last_name')
}
......
......@@ -32,12 +32,11 @@ class SemesterProcessVolunteerActionsTest < ApplicationSystemTestCase
## SETUP ##
# Offen/open -> @spv1
# Übernommen/responsibility taken over from superadmin1
@volunteer2 = create :volunteer_with_user
@volunteer2.contact.update(first_name: 'volunteer2', last_name: 'volunteer2')
@spv2 = create(:semester_process_volunteer, :with_mission, volunteer: @volunteer2,
semester_process: create(:semester_process))
semester_process: @semester_process)
@superadmin2 = create :user
@spv2.update(responsible: @superadmin2)
......@@ -45,7 +44,7 @@ class SemesterProcessVolunteerActionsTest < ApplicationSystemTestCase
@volunteer3 = create :volunteer_with_user
@volunteer3.contact.update(first_name: 'volunteer3', last_name: 'volunteer3')
@spv3 = create(:semester_process_volunteer, :with_mission, volunteer: @volunteer3,
semester_process: create(:semester_process))
semester_process: @semester_process)
@superadmin3 = create :user
@spv3.update(responsible: @superadmin3)
## SETUP 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