Class: ProjectAdminQuery

Inherits:
ProjectQuery show all
Defined in:
app/models/project_admin_query.rb

Overview

Redmine - project management software Copyright © Jean-Philippe Lang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Constant Summary

Constants inherited from Query

Query::VISIBILITY_PRIVATE, Query::VISIBILITY_PUBLIC, Query::VISIBILITY_ROLES

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ProjectQuery

#available_columns, #default_columns_names, #default_display_type, #default_sort_criteria, #initialize, #initialize_available_filters, #result_count, #results_scope

Methods inherited from Query

add_available_column, #add_available_filter, #add_filter, #add_filter_error, #add_filters, #add_short_filter, #all_projects, #all_projects_values, #as_params, #assigned_to_values, #author_values, #available_block_columns, #available_filters, #available_filters_as_json, #available_inline_columns, #available_totalable_columns, #block_columns, build_from_params, #build_from_params, #column_names=, #columns, #css_classes, #default_columns_names, #default_display_type, #default_sort_criteria, #default_totalable_names, #delete_available_filter, #display_type=, #fixed_version_values, #group_by_column, #group_by_sort_order, #group_by_statement, #groupable_columns, #grouped?, #has_column?, #has_custom_field_column?, #has_default_columns?, #has_filter?, #inline_columns, #is_global?, #is_private?, #is_public?, #issue_custom_fields, #issue_statuses_values, #label_for, #operator_for, operators_labels, #principals, #project_custom_fields, #project_statement, #project_values, #queried_table_name, #result_count_by_group, #sort_clause, #sort_criteria, #sort_criteria=, #sort_criteria_key, #sort_criteria_order, #sortable_columns, #statement, #subproject_values, #time_entry_custom_fields, #total_by_group_for, #total_for, #totalable_columns, #totalable_names, #totalable_names=, #totals, #totals_by_group, #trackers, #type_for, #users, #validate_query_filters, #value_for, #values_for, #watcher_values

Methods included from Redmine::SubclassFactory

included

Methods inherited from ApplicationRecord

human_attribute_name

Constructor Details

This class inherits a constructor from ProjectQuery

Class Method Details

.default(project: nil, user: User.current) ⇒ Object



23
24
25
# File 'app/models/project_admin_query.rb', line 23

def self.default(project: nil, user: User.current)
  nil
end

.visible(*args) ⇒ Object



27
28
29
30
31
32
33
34
# File 'app/models/project_admin_query.rb', line 27

def self.visible(*args)
  user = args.shift || User.current
  if user.admin?
    where('1=1')
  else
    where('1=0')
  end
end

Instance Method Details

#available_display_typesObject



44
45
46
# File 'app/models/project_admin_query.rb', line 44

def available_display_types
  ['list']
end

#base_scopeObject



60
61
62
# File 'app/models/project_admin_query.rb', line 60

def base_scope
  Project.where(statement)
end

#display_typeObject



48
49
50
# File 'app/models/project_admin_query.rb', line 48

def display_type
  'list'
end

#editable_by?(user) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'app/models/project_admin_query.rb', line 40

def editable_by?(user)
  user&.admin?
end

#project_statuses_valuesObject



52
53
54
55
56
57
58
# File 'app/models/project_admin_query.rb', line 52

def project_statuses_values
  values = super

  values << [l(:project_status_archived), Project::STATUS_ARCHIVED.to_s]
  values << [l(:project_status_scheduled_for_deletion), Project::STATUS_SCHEDULED_FOR_DELETION.to_s]
  values
end

#visible?(user = User.current) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/models/project_admin_query.rb', line 36

def visible?(user=User.current)
  user&.admin?
end