(refs $#498)Don't show private repo user doesn't have permission

This fix in the dashboard pull request view
But this fix still has a problem show wrong count number pull request.
This commit is contained in:
Tomofumi Tanaka
2014-09-29 11:27:48 +09:00
parent e16d3c823b
commit d78315695b
2 changed files with 13 additions and 3 deletions

View File

@@ -166,8 +166,18 @@ trait RepositoryService { self: AccountService =>
}
}
def getAllRepositories()(implicit s: Session): List[(String, String)] = {
Repositories.sortBy(_.lastActivityDate desc).map{ t =>
/**
* Returns the repositories without private repository that user does not have access right.
* Include public repository, private own repository and private but collaborator repository.
*
* @param userName the user name of collaborator
* @return the repository infomation list
*/
def getAllRepositories(userName: String)(implicit s: Session): List[(String, String)] = {
Repositories.filter { t1 =>
(t1.isPrivate === false.bind) ||
(Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) && (t2.collaboratorName === userName.bind)} exists)
}.sortBy(_.lastActivityDate desc).map{ t =>
(t.userName, t.repositoryName)
}.list
}