From dc3ec7243248cb5392b92a278ab9b641d3ddc00c Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 2 Oct 2013 13:29:18 -0400 Subject: [PATCH] Fix handling of repositories list when not signed in --- data/model.py | 7 ++++++- static/js/controllers.js | 6 +++++- static/partials/repo-list.html | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/data/model.py b/data/model.py index 0ad1ddc5b..04f34e6fc 100644 --- a/data/model.py +++ b/data/model.py @@ -97,6 +97,9 @@ def get_token(code): def get_visible_repositories(username=None, include_public=True, limit=None, sort=False): + if not username and not include_public: + return [] + query = Repository.select().distinct().join(Visibility) or_clauses = [] if include_public: @@ -112,7 +115,9 @@ def get_visible_repositories(username=None, include_public=True, limit=None, sor with_images = query.switch(Repository).join(Image, JOIN_LEFT_OUTER) query = with_images.order_by(Image.created.desc()) - query = query.where(reduce(operator.or_, or_clauses)) + if (or_clauses): + query = query.where(reduce(operator.or_, or_clauses)) + if limit: query = query.limit(limit) diff --git a/static/js/controllers.js b/static/js/controllers.js index 988fe4a31..7b947f9b2 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -80,7 +80,11 @@ function HeaderCtrl($scope, UserService) { function GuideCtrl($scope, Restangular) { } -function RepoListCtrl($scope, Restangular) { +function RepoListCtrl($scope, Restangular, UserService) { + $scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) { + $scope.user = currentUser; + }, true); + $scope.getCommentFirstLine = function(commentString) { return getMarkedDown(getFirstTextLine(commentString)); }; diff --git a/static/partials/repo-list.html b/static/partials/repo-list.html index e261a4101..8365122b1 100644 --- a/static/partials/repo-list.html +++ b/static/partials/repo-list.html @@ -3,7 +3,7 @@
-
+

Your Repositories