# HG changeset patch # User Mads Kiilerich # Date 2018-04-23 00:44:13 # Node ID af938280e76aae5109f9fc3e78c0366edee1d4e8 # Parent 1b737e25266c8970d277a7eb054bae9d4ed09da5 repos: document get_repos_as_dict parameters - repos_list is mandatory diff --git a/kallithea/controllers/admin/my_account.py b/kallithea/controllers/admin/my_account.py --- a/kallithea/controllers/admin/my_account.py +++ b/kallithea/controllers/admin/my_account.py @@ -82,8 +82,7 @@ class MyAccountController(BaseController .filter(Repository.owner_id == request.authuser.user_id).all() - return RepoModel().get_repos_as_dict(repos_list=repos_list, - admin=admin) + return RepoModel().get_repos_as_dict(repos_list, admin=admin) def my_account(self): c.active = 'profile' diff --git a/kallithea/controllers/admin/repo_groups.py b/kallithea/controllers/admin/repo_groups.py --- a/kallithea/controllers/admin/repo_groups.py +++ b/kallithea/controllers/admin/repo_groups.py @@ -295,9 +295,9 @@ class RepoGroupsController(BaseControlle repo_groups_list = self.scm_model.get_repo_groups(groups) repos_list = Repository.query(sorted=True).filter_by(group=c.group).all() - c.data = RepoModel().get_repos_as_dict(repos_list=repos_list, + c.data = RepoModel().get_repos_as_dict(repos_list, repo_groups_list=repo_groups_list, - admin=False, short_name=True) + short_name=True) return render('admin/repo_groups/repo_group_show.html') diff --git a/kallithea/controllers/admin/repos.py b/kallithea/controllers/admin/repos.py --- a/kallithea/controllers/admin/repos.py +++ b/kallithea/controllers/admin/repos.py @@ -102,7 +102,7 @@ class ReposController(BaseRepoController c.repos_list = RepoList(_list, perm_level='admin') # the repo list will be filtered to only show repos where the user has read permissions - repos_data = RepoModel().get_repos_as_dict(repos_list=c.repos_list, admin=True) + repos_data = RepoModel().get_repos_as_dict(c.repos_list, admin=True) # data used to render the grid c.data = repos_data diff --git a/kallithea/controllers/home.py b/kallithea/controllers/home.py --- a/kallithea/controllers/home.py +++ b/kallithea/controllers/home.py @@ -57,9 +57,9 @@ class HomeController(BaseController): repo_groups_list = self.scm_model.get_repo_groups() repos_list = Repository.query(sorted=True).filter_by(group=None).all() - c.data = RepoModel().get_repos_as_dict(repos_list=repos_list, + c.data = RepoModel().get_repos_as_dict(repos_list, repo_groups_list=repo_groups_list, - admin=False, short_name=True) + short_name=True) return render('/index.html') diff --git a/kallithea/controllers/journal.py b/kallithea/controllers/journal.py --- a/kallithea/controllers/journal.py +++ b/kallithea/controllers/journal.py @@ -214,8 +214,7 @@ class JournalController(BaseController): repos_list = Repository.query(sorted=True) \ .filter_by(owner_id=request.authuser.user_id).all() - repos_data = RepoModel().get_repos_as_dict(repos_list=repos_list, - admin=True) + repos_data = RepoModel().get_repos_as_dict(repos_list, admin=True) # data used to render the grid c.data = repos_data diff --git a/kallithea/model/repo.py b/kallithea/model/repo.py --- a/kallithea/model/repo.py +++ b/kallithea/model/repo.py @@ -149,9 +149,14 @@ class RepoModel(object): kwargs.update(dict(_=_, h=h, c=c, request=request)) return tmpl.render(*args, **kwargs) - def get_repos_as_dict(self, repos_list=None, repo_groups_list=None, + def get_repos_as_dict(self, repos_list, repo_groups_list=None, admin=False, short_name=False): + """Return repository list for use by DataTable. + repos_list: list of repositories - but will be filtered for read permission. + repo_groups_list: added at top of list without permission check. + admin: return data for action column. + """ _render = self._render_datatable from tg import tmpl_context as c