Commit b42dbf05 authored by Tugce Nur Tas's avatar Tugce Nur Tas

review changes

parent 7c4ff587
Pipeline #36510 failed with stage
in 37 minutes and 35 seconds
......@@ -37,10 +37,10 @@ class SemesterProcessVolunteer < ApplicationRecord
scope :active_missions, lambda {
joins(:semester_process_volunteer_missions).includes(semester_process_volunteer_missions: [:assignment, :group_assignment])
.where("(semester_process_volunteer_missions.assignment_id IS NOT NULL AND
.where("(semester_process_volunteer_missions.assignment_id IS NOT NULL AND
assignments.period_end IS NULL)
OR
(semester_process_volunteer_missions.group_assignment_id IS NOT NULL AND
OR
(semester_process_volunteer_missions.group_assignment_id IS NOT NULL AND
group_assignments.period_end is NULL)")
.references(:assignments, :group_assignments)
}
......@@ -53,6 +53,14 @@ class SemesterProcessVolunteer < ApplicationRecord
left_outer_joins(:semester_feedbacks).where(semester_feedbacks: { id: nil})
}
scope :unsubmitted, -> { where(commited_at: nil) }
scope :submitted, -> { where.not(commited_at: nil) }
scope :in_semester, lambda { |semester|
semester = (Date.parse(semester)..Date.parse(semester).advance(months: 5).end_of_month) if semester.is_a?(String)
joins(:semester_process).where('semester_processes.semester && daterange(?,?)', semester.begin, semester.end)
}
attr_accessor :hours
def hours
......
......@@ -182,30 +182,26 @@ class Volunteer < ApplicationRecord
end
def unsubmitted_semester_feedbacks
semester_process_volunteers.where(commited_at: nil)
semester_process_volunteers.unsubmitted
end
def submitted_semester_feedbacks
semester_process_volunteers.where.not(commited_at: nil)
semester_process_volunteers.submitted
end
def unsubmitted_semester_feedbacks?
return false if unsubmitted_semester_feedbacks.blank?
true
semester_process_volunteers.unsubmitted.any?
end
def submitted_semester_feedbacks_covers_semester?(selected_billing_semester)
submitted_semester_feedbacks.any? do |semester_feedback|
semester_feedback.semester.cover?(selected_billing_semester.to_date)
end
submitted_semester_feedbacks.in_semester(selected_billing_semester).any?
end
def unsubmitted_semester_feedbacks_covers_semester?(selected_billing_semester)
unsubmitted_semester_feedbacks.any? do |semester_feedback|
semester_feedback.semester.cover?(selected_billing_semester.to_date)
end
unsubmitted_semester_feedbacks.in_semester(selected_billing_semester).any?
end
## Activness Scopes
#
scope :will_take_more_assignments, (-> { where(take_more_assignments: true) })
......
......@@ -32,7 +32,6 @@ h1 Spesenformulare erfassen
span.label.label-success Bestätigt
- elsif volunteer.unsubmitted_semester_feedbacks_covers_semester?(@selected_billing_semester)
span.label.label-warning Unbestätigt
- else
td= link_to volunteer, edit_volunteer_path(volunteer)
td
- if volunteer.iban?
......
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