diff --git a/kallithea/controllers/api/api.py b/kallithea/controllers/api/api.py --- a/kallithea/controllers/api/api.py +++ b/kallithea/controllers/api/api.py @@ -48,7 +48,7 @@ from kallithea.model.user_group import U from kallithea.model.gist import GistModel from kallithea.model.db import ( Repository, Setting, UserIpMap, Permission, User, Gist, - RepoGroup) + RepoGroup, UserGroup) from kallithea.lib.compat import json from kallithea.lib.exceptions import ( DefaultUserException, UserGroupsAssignedException) @@ -885,7 +885,7 @@ class ApiController(JSONRPCController): result = [] _perms = ('usergroup.read', 'usergroup.write', 'usergroup.admin',) extras = {'user': apiuser} - for user_group in UserGroupList(UserGroupModel().get_all(), + for user_group in UserGroupList(UserGroup.get_all(), perm_set=_perms, extra_kwargs=extras): result.append(user_group.get_api_data()) return result @@ -1323,7 +1323,7 @@ class ApiController(JSONRPCController): if not HasPermissionAnyApi('hg.admin')(user=apiuser): repos = RepoModel().get_all_user_repos(user=apiuser) else: - repos = RepoModel().get_all() + repos = Repository.get_all() for repo in repos: result.append(repo.get_api_data()) diff --git a/kallithea/model/__init__.py b/kallithea/model/__init__.py --- a/kallithea/model/__init__.py +++ b/kallithea/model/__init__.py @@ -132,10 +132,3 @@ class BaseModel(object): from kallithea.model.db import Permission return self._get_instance(Permission, permission, callback=Permission.get_by_key) - - @classmethod - def get_all(cls): - """ - Returns all instances of what is defined in `cls` class variable - """ - return cls.cls.get_all() diff --git a/kallithea/tests/api/api_base.py b/kallithea/tests/api/api_base.py --- a/kallithea/tests/api/api_base.py +++ b/kallithea/tests/api/api_base.py @@ -880,7 +880,7 @@ class _BaseTestApi(object): response = api_call(self, params) result = [] - for repo in RepoModel().get_all(): + for repo in Repository.get_all(): result.append(repo.get_api_data()) ret = jsonify(result) diff --git a/kallithea/tests/fixture.py b/kallithea/tests/fixture.py --- a/kallithea/tests/fixture.py +++ b/kallithea/tests/fixture.py @@ -18,7 +18,7 @@ Helpers for fixture generation import os import time from kallithea.tests import * -from kallithea.model.db import Repository, User, RepoGroup, UserGroup +from kallithea.model.db import Repository, User, RepoGroup, UserGroup, Gist from kallithea.model.meta import Session from kallithea.model.repo import RepoModel from kallithea.model.user import UserModel @@ -252,7 +252,7 @@ class Fixture(object): return gist def destroy_gists(self, gistid=None): - for g in GistModel.cls.get_all(): + for g in Gist.get_all(): if gistid: if gistid == g.gist_access_id: GistModel().delete(g) diff --git a/kallithea/tests/models/test_user_groups.py b/kallithea/tests/models/test_user_groups.py --- a/kallithea/tests/models/test_user_groups.py +++ b/kallithea/tests/models/test_user_groups.py @@ -1,4 +1,4 @@ -from kallithea.model.db import User +from kallithea.model.db import User, UserGroup from kallithea.tests import * from kallithea.tests.fixture import Fixture @@ -14,7 +14,7 @@ class TestUserGroups(TestController): def teardown_method(self, method): # delete all groups - for gr in UserGroupModel.get_all(): + for gr in UserGroup.get_all(): fixture.destroy_user_group(gr) Session().commit() @@ -30,7 +30,7 @@ class TestUserGroups(TestController): def test_enforce_groups(self, pre_existing, regular_should_be, external_should_be, groups, expected): # delete all groups - for gr in UserGroupModel.get_all(): + for gr in UserGroup.get_all(): fixture.destroy_user_group(gr) Session().commit()