Welcome to mirror list, hosted at ThFree Co, Russian Federation.

params.rb « issues_finder « finders « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1de117216f891fb144c9a771dd123aab191e8bb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

class IssuesFinder
  class Params < IssuableFinder::Params
    def public_only?
      params.fetch(:public_only, false)
    end

    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

    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?
      strong_memoize(:user_can_see_all_confidential_issues) do
        parent = project? ? project : group
        if parent
          Ability.allowed?(current_user, :read_confidential_issues, parent)
        else
          Ability.allowed?(current_user, :read_all_resources)
        end
      end
    end

    def user_cannot_see_confidential_issues?
      return false if user_can_see_all_confidential_issues?

      current_user.blank?
    end
  end
end

IssuesFinder::Params.prepend_mod_with('IssuesFinder::Params')