2020-03-30 17:08:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class IssuesFinder
|
|
|
|
class Params < IssuableFinder::Params
|
|
|
|
def public_only?
|
|
|
|
params.fetch(:public_only, false)
|
|
|
|
end
|
|
|
|
|
2022-01-24 13:14:42 -05:00
|
|
|
def filter_by_any_due_date?
|
|
|
|
due_date? && params[:due_date] == Issue::AnyDueDate.name
|
|
|
|
end
|
|
|
|
|
2020-03-30 17:08:01 -04:00
|
|
|
def filter_by_no_due_date?
|
|
|
|
due_date? && params[:due_date] == Issue::NoDueDate.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def filter_by_overdue?
|
|
|
|
due_date? && params[:due_date] == Issue::Overdue.name
|
|
|
|
end
|
|
|
|
|
2022-01-24 13:14:42 -05:00
|
|
|
def filter_by_due_today?
|
|
|
|
due_date? && params[:due_date] == Issue::DueToday.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def filter_by_due_tomorrow?
|
|
|
|
due_date? && params[:due_date] == Issue::DueTomorrow.name
|
|
|
|
end
|
|
|
|
|
2020-03-30 17:08:01 -04:00
|
|
|
def filter_by_due_this_week?
|
|
|
|
due_date? && params[:due_date] == Issue::DueThisWeek.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def filter_by_due_this_month?
|
|
|
|
due_date? && params[:due_date] == Issue::DueThisMonth.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def filter_by_due_next_month_and_previous_two_weeks?
|
|
|
|
due_date? && params[:due_date] == Issue::DueNextMonthAndPreviousTwoWeeks.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def user_can_see_all_confidential_issues?
|
2020-06-29 08:09:20 -04:00
|
|
|
strong_memoize(:user_can_see_all_confidential_issues) do
|
|
|
|
parent = project? ? project : group
|
|
|
|
if parent
|
|
|
|
Ability.allowed?(current_user, :read_confidential_issues, parent)
|
2020-03-30 17:08:01 -04:00
|
|
|
else
|
2021-08-12 14:10:45 -04:00
|
|
|
user_can_see_all_issues?
|
2020-03-30 17:08:01 -04:00
|
|
|
end
|
2020-06-29 08:09:20 -04:00
|
|
|
end
|
2020-03-30 17:08:01 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def user_cannot_see_confidential_issues?
|
|
|
|
return false if user_can_see_all_confidential_issues?
|
|
|
|
|
|
|
|
current_user.blank?
|
|
|
|
end
|
2021-08-12 14:10:45 -04:00
|
|
|
|
|
|
|
def user_can_see_all_issues?
|
|
|
|
strong_memoize(:user_can_see_all_issues) do
|
|
|
|
Ability.allowed?(current_user, :read_all_resources)
|
|
|
|
end
|
|
|
|
end
|
2020-03-30 17:08:01 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
IssuesFinder::Params.prepend_mod_with('IssuesFinder::Params')
|