Commit 5b255d83 authored by Tugce Nur Tas's avatar Tugce Nur Tas Committed by Tuğçe Nur Taş
Browse files

add assignments started method for hours

parent b7e377da
......@@ -6,6 +6,7 @@ class GroupAssignment < ApplicationRecord
after_update :save_group_assignment_logs, if: :dates_updated?
before_destroy :save_group_assignment_logs
scope :started, (-> { where('period_start < ?', Time.zone.today) })
scope :ongoing, (-> { where('group_assignments.period_end > ?', Time.zone.today) })
scope :no_end, (-> { where(period_end: nil) })
......
......@@ -157,6 +157,14 @@ class Volunteer < ApplicationRecord
assignments.size.positive?
end
def assignment_started?
assignments.started.size.positive?
end
def group_assignment_stared?
group_assignments.started.size.positive?
end
def external?
external
end
......@@ -165,8 +173,8 @@ class Volunteer < ApplicationRecord
!external
end
def internal_and_assignments?
internal? && assignments?
def internal_and_started_assignments?
internal? && assignment_started? || group_assignment_stared?
end
def self_applicant?
......
......@@ -23,7 +23,7 @@ nav.navbar.section-navigation
- elsif @volunteer.certificates.size > 1
li= button_link t('.show_certificates'), volunteer_certificates_path(@volunteer)
ul.list-inline
- if @volunteer.internal_and_assignments?
- if @volunteer.internal_and_started_assignments?
li = button_link t('.report_hours'), new_volunteer_hour_url(@volunteer)
li = button_link t('.hour_reports'), volunteer_hours_path(@volunteer)
li= button_link current_user.volunteer? ? t('edit_profile') : t_title(:edit), edit_volunteer_path(@volunteer)
......
Supports Markdown
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