Skip to content

Commit

Permalink
#387 hiding from student landing screen the not active phases which w…
Browse files Browse the repository at this point in the history
…ere not completed
  • Loading branch information
Carlos-Eduardo-Cabral-da-Cunha committed Feb 22, 2022
1 parent 52428f9 commit 8d04538
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/controllers/student_enrollment_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def show
enrollment: @enrollment, thesis_defense_committee_professors: @enrollment.thesis_defense_committee_professors)
existing_partial('student_enrollment/show_class_enrollments', :class_enrollments, @enrollment.class_enrollments)
existing_partial('student_enrollment/show_advisements', :advisements, @enrollment.advisements)
existing_partial('student_enrollment/show_phases', :phase_completions, @enrollment.phase_completions)
existing_partial('student_enrollment/show_phases', :phase_completions, @enrollment.completed_or_active_phase_completions)
existing_partial('student_enrollment/show_deferrals', :deferrals, @enrollment.deferrals)
existing_partial('student_enrollment/show_holds', :holds, @enrollment.enrollment_holds)
existing_partial('student_enrollment/show_scholarships', :scholarship_durations, @enrollment.scholarship_durations)
Expand Down
8 changes: 2 additions & 6 deletions app/helpers/enrollments_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,9 @@ def enrollment_thesis_defense_committee_participations_show_column(record, colum


def enrollment_phase_due_dates_show_column(record, column)
completed_or_active_phases = record.phase_completions.joins(:phase)
.where.not(:completion_date => nil)
.or(record.phase_completions.joins(:phase)
.where('phases.active' => true) )
return '-' if completed_or_active_phases.empty?
return '-' if record.completed_or_active_phase_completions.empty?
render(partial: 'enrollments/show_phases_table',
locals: { phase_completions: completed_or_active_phases,
locals: { phase_completions: record.completed_or_active_phase_completions,
dateformat: :monthyear,
show_obs: true })
end
Expand Down
7 changes: 7 additions & 0 deletions app/models/enrollment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,11 @@ def create_user!
true
end

def completed_or_active_phase_completions
phase_completions.joins(:phase)
.where.not(:completion_date => nil)
.or(phase_completions.joins(:phase)
.where('phases.active' => true) )
end

end

0 comments on commit 8d04538

Please sign in to comment.