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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCiro Santilli <ciro.santilli@gmail.com>2014-10-02 13:38:21 +0400
committerCiro Santilli <ciro.santilli@gmail.com>2014-10-02 16:07:21 +0400
commitda99560ecbc105c8a98ce2f0e47415634420040f (patch)
treeb3967f42fb32f6aa5a5aebf59543742d07d9fafb /app/helpers/dashboard_helper.rb
parentb0349915e2615617aff9c5291f7e305d59ea3992 (diff)
Factor dashboard helper methods.
Diffstat (limited to 'app/helpers/dashboard_helper.rb')
-rw-r--r--app/helpers/dashboard_helper.rb33
1 files changed, 12 insertions, 21 deletions
diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb
index c4e33e3308f..acc0eeb76b3 100644
--- a/app/helpers/dashboard_helper.rb
+++ b/app/helpers/dashboard_helper.rb
@@ -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)
- end
-
- items.count
+ items = current_user.send(entity.pluralize)
+ get_count(items, scope)
end
def authorized_entities_count(current_user, entity, scope = nil)
- items = entity.classify.constantize.opened
+ items = entity.classify.constantize
+ get_count(items, scope, true, current_user)
+ end
+
+ 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