remove 'include_starred' option on repo listings
This commit is contained in:
parent
5a484cfe11
commit
e8cd24781a
3 changed files with 10 additions and 23 deletions
|
@ -778,9 +778,9 @@ def get_visible_repository_count(username=None, include_public=True,
|
|||
|
||||
|
||||
def get_visible_repositories(username=None, include_public=True, page=None,
|
||||
limit=None, sort=False, namespace=None, include_starred=True):
|
||||
limit=None, sort=False, namespace=None):
|
||||
query = _visible_repository_query(username=username, include_public=include_public, page=page,
|
||||
limit=limit, namespace=namespace, include_starred=include_starred,
|
||||
limit=limit, namespace=namespace,
|
||||
select_models=[Repository, Namespace, Visibility])
|
||||
|
||||
if sort:
|
||||
|
@ -793,7 +793,7 @@ def get_visible_repositories(username=None, include_public=True, page=None,
|
|||
|
||||
|
||||
def _visible_repository_query(username=None, include_public=True, limit=None,
|
||||
page=None, namespace=None, include_starred=True, select_models=[]):
|
||||
page=None, namespace=None, select_models=[]):
|
||||
query = (Repository
|
||||
.select(*select_models) # MySQL/RDS complains is there are selected models for counts.
|
||||
.distinct()
|
||||
|
@ -803,7 +803,7 @@ def _visible_repository_query(username=None, include_public=True, limit=None,
|
|||
.switch(Repository)
|
||||
.join(RepositoryPermission, JOIN_LEFT_OUTER))
|
||||
|
||||
query = _filter_to_repos_for_user(query, username, namespace, include_public, include_starred)
|
||||
query = _filter_to_repos_for_user(query, username, namespace, include_public)
|
||||
if page:
|
||||
query = query.paginate(page, limit)
|
||||
elif limit:
|
||||
|
@ -812,8 +812,7 @@ def _visible_repository_query(username=None, include_public=True, limit=None,
|
|||
return query
|
||||
|
||||
|
||||
def _filter_to_repos_for_user(query, username=None, namespace=None,
|
||||
include_public=True, include_starred=True):
|
||||
def _filter_to_repos_for_user(query, username=None, namespace=None, include_public=True):
|
||||
if not include_public and not username:
|
||||
return Repository.select().where(Repository.id == '-1')
|
||||
|
||||
|
@ -824,7 +823,6 @@ def _filter_to_repos_for_user(query, username=None, namespace=None,
|
|||
AdminTeam = Team.alias()
|
||||
AdminTeamMember = TeamMember.alias()
|
||||
AdminUser = User.alias()
|
||||
UserThroughStar = User.alias()
|
||||
|
||||
query = (query
|
||||
.switch(RepositoryPermission)
|
||||
|
@ -844,9 +842,6 @@ def _filter_to_repos_for_user(query, username=None, namespace=None,
|
|||
where_clause = ((User.username == username) | (UserThroughTeam.username == username) |
|
||||
((AdminUser.username == username) & (TeamRole.name == 'admin')))
|
||||
|
||||
if not include_starred:
|
||||
subquery = Repository.select().join(Star).join(User).where(User.username == username).alias()
|
||||
where_clause = where_clause & ~(Repository.id << subquery)
|
||||
if namespace:
|
||||
where_clause = where_clause & (Namespace.username == namespace)
|
||||
|
||||
|
|
|
@ -107,7 +107,6 @@ class RepositoryList(ApiResource):
|
|||
@query_param('sort', 'Whether to sort the results.', type=truthy_bool, default=False)
|
||||
@query_param('count', 'Whether to include a count of the total number of results available.',
|
||||
type=truthy_bool, default=False)
|
||||
@query_param('starred', 'Whether or not to include starred repositories', type=truthy_bool, default=True)
|
||||
def get(self, args):
|
||||
"""Fetch the list of repositories under a variety of situations."""
|
||||
username = None
|
||||
|
@ -124,7 +123,7 @@ class RepositoryList(ApiResource):
|
|||
|
||||
repo_query = model.get_visible_repositories(username, limit=args['limit'], page=args['page'],
|
||||
include_public=args['public'], sort=args['sort'],
|
||||
namespace=args['namespace'], include_starred=args['starred'])
|
||||
namespace=args['namespace'])
|
||||
|
||||
response['repositories'] = [repo_view(repo) for repo in repo_query
|
||||
if (repo.visibility.name == 'public' or
|
||||
|
|
|
@ -236,9 +236,8 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
|||
$scope.page = 1;
|
||||
$scope.publicPageCount = null;
|
||||
|
||||
// Monitor changes in the user.
|
||||
// Grab user namespaces
|
||||
UserService.load(function() {
|
||||
console.log("updateUserIn");
|
||||
var user = UserService.currentUser();
|
||||
$scope.namespaces = [user];
|
||||
for (var i = 0; i < user.organizations.length; i++) {
|
||||
|
@ -246,7 +245,6 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
|||
}
|
||||
loadStarredRepos();
|
||||
loadRepos();
|
||||
console.log($scope.namespaces);
|
||||
});
|
||||
|
||||
|
||||
|
@ -263,11 +261,9 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
|||
'repository': repo.name
|
||||
};
|
||||
ApiService.createStar(data).then(function(result) {
|
||||
loadStarredRepos($scope.namespace);
|
||||
loadRepos($scope.namespace);
|
||||
loadStarredRepos();
|
||||
}, function(result) {
|
||||
loadStarredRepos();
|
||||
loadRepos();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -276,11 +272,9 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
|||
'repository': repo.namespace + '/' + repo.name
|
||||
};
|
||||
ApiService.deleteStar(null, data).then(function(result) {
|
||||
loadStarredRepos($scope.namespace);
|
||||
loadRepos($scope.namespace);
|
||||
loadStarredRepos();
|
||||
}, function(result) {
|
||||
loadStarredRepos($scope.namespace);
|
||||
loadRepos();
|
||||
loadStarredRepos();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -323,7 +317,6 @@ function RepoListCtrl($scope, $sanitize, Restangular, UserService, ApiService) {
|
|||
'public': false,
|
||||
'sort': true,
|
||||
'namespace': namespaceName,
|
||||
'starred': false,
|
||||
};
|
||||
namespace.repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
||||
return resp.repositories;
|
||||
|
|
Reference in a new issue