Commit ac7fab73 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #7938 from cirosantilli/factor-dashboard-helper

Factor dashboard helper methods.
parents cf1aa36a da99560e
......@@ -37,40 +37,31 @@ module DashboardHelper
end
def assigned_entities_count(current_user, entity, scope = nil)
items = current_user.send("assigned_" + entity.pluralize).opened
if scope.kind_of?(Group)
items = items.of_group(scope)
elsif scope.kind_of?(Project)
items = items.of_projects(scope)
end
items.count
items = current_user.send('assigned_' + entity.pluralize)
get_count(items, scope)
end
def authored_entities_count(current_user, entity, scope = nil)
items = current_user.send(entity.pluralize).opened
if scope.kind_of?(Group)
items = items.of_group(scope)
elsif scope.kind_of?(Project)
items = items.of_projects(scope)
items = current_user.send(entity.pluralize)
get_count(items, scope)
end
items.count
def authorized_entities_count(current_user, entity, scope = nil)
items = entity.classify.constantize
get_count(items, scope, true, current_user)
end
def authorized_entities_count(current_user, entity, scope = nil)
items = entity.classify.constantize.opened
protected
def get_count(items, scope, get_authorized = false, current_user = nil)
items = items.opened
if scope.kind_of?(Group)
items = items.of_group(scope)
elsif scope.kind_of?(Project)
items = items.of_projects(scope)
else
elsif get_authorized
items = items.of_projects(current_user.authorized_projects)
end
items.count
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment