Merge branch 'feature/rails4_fix_query_menu_items' into feature/rails4

pull/2229/head
Alex Coles 10 years ago
commit bb40d897d9
  1. 14
      app/controllers/api/experimental/queries_controller.rb
  2. 21
      app/helpers/issues_helper.rb
  3. 20
      app/helpers/queries_helper.rb

@ -161,19 +161,5 @@ module Api::Experimental
deny_access unless allowed
end
def visible_queries
unless @visible_queries
# User can see public queries and his own queries
visible = ARCondition.new(['is_public = ? OR user_id = ?', true, (User.current.logged? ? User.current.id : 0)])
# Project specific queries and global queries
visible << (@project.nil? ? ['project_id IS NULL'] : ['project_id IS NULL OR project_id = ?', @project.id])
@visible_queries = Query.find(:all,
select: 'id, name, is_public',
order: 'name ASC',
conditions: visible.conditions)
end
@visible_queries
end
end
end

@ -104,27 +104,6 @@ module IssuesHelper
s.html_safe
end
def visible_queries
unless @visible_queries
# User can see public queries and his own queries
visible = ARCondition.new(['is_public = ? OR user_id = ?', true, (User.current.logged? ? User.current.id : 0)])
# Project specific queries and global queries
visible << (@project.nil? ? ['project_id IS NULL'] : ['project_id IS NULL OR project_id = ?', @project.id])
@visible_queries = Query.find(:all,
select: 'id, name, is_public',
order: 'name ASC',
conditions: visible.conditions)
end
@visible_queries
end
def grouped_query_options
{
l(:label_my_queries) => visible_queries.select { |query| !query.is_public? }.map { |query| [query.name, query.id] },
l(:label_query_plural) => visible_queries.select(&:is_public?).map { |query| [query.name, query.id] }
}
end
# Find the name of an associated record stored in the field attribute
def find_name_by_reflection(field, id)
association = WorkPackage.reflect_on_association(field.to_sym)

@ -76,4 +76,24 @@ module QueriesHelper
@query
end
def visible_queries
unless @visible_queries
# User can see public queries and his own queries
visible = ARCondition.new(['is_public = ? OR user_id = ?', true, (User.current.logged? ? User.current.id : 0)])
# Project specific queries and global queries
visible << (@project.nil? ? ['project_id IS NULL'] : ['project_id IS NULL OR project_id = ?', @project.id])
@visible_queries = Query.where(visible.conditions)
.order('name ASC')
.select(:id, :name, :is_public, :project_id)
end
@visible_queries
end
def grouped_query_options
{
l(:label_my_queries) => visible_queries.select { |query| !query.is_public? }.map { |query| [query.name, query.id] },
l(:label_query_plural) => visible_queries.select(&:is_public?).map { |query| [query.name, query.id] }
}
end
end

Loading…
Cancel
Save