##// END OF EJS Templates
Adds scopes for retrieving the appropriate queries (#14790)....
Jean-Philippe Lang -
r15259:275bd514cd21
parent child
Show More
@@ -279,14 +279,7 module QueriesHelper
279 end
279 end
280
280
281 def sidebar_queries
281 def sidebar_queries
282 unless @sidebar_queries
282 @sidebar_queries ||= IssueQuery.visible.global_or_on_project(@project).sorted.to_a
283 @sidebar_queries = IssueQuery.visible.
284 order("#{Query.table_name}.name ASC").
285 # Project specific queries and global queries
286 where(@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id]).
287 to_a
288 end
289 @sidebar_queries
290 end
283 end
291
284
292 def query_links(title, queries)
285 def query_links(title, queries)
@@ -234,6 +234,13 class Query < ActiveRecord::Base
234 # Permission required to view the queries, set on subclasses.
234 # Permission required to view the queries, set on subclasses.
235 class_attribute :view_permission
235 class_attribute :view_permission
236
236
237 # Scope of queries that are global or on the given project
238 scope :global_or_on_project, lambda {|project|
239 where(:project_id => (project.nil? ? nil : [nil, project.id]))
240 }
241
242 scope :sorted, lambda {order(:name, :id)}
243
237 # Scope of visible queries, can be used from subclasses only.
244 # Scope of visible queries, can be used from subclasses only.
238 # Unlike other visible scopes, a class methods is used as it
245 # Unlike other visible scopes, a class methods is used as it
239 # let handle inheritance more nicely than scope DSL.
246 # let handle inheritance more nicely than scope DSL.
General Comments 0
You need to be logged in to leave comments. Login now