##// END OF EJS Templates
model: inline BaseModel.get_all...
Søren Løvborg -
r6080:974d6470 default
parent child Browse files
Show More
@@ -48,7 +48,7 b' from kallithea.model.user_group import U'
48 48 from kallithea.model.gist import GistModel
49 49 from kallithea.model.db import (
50 50 Repository, Setting, UserIpMap, Permission, User, Gist,
51 RepoGroup)
51 RepoGroup, UserGroup)
52 52 from kallithea.lib.compat import json
53 53 from kallithea.lib.exceptions import (
54 54 DefaultUserException, UserGroupsAssignedException)
@@ -885,7 +885,7 b' class ApiController(JSONRPCController):'
885 885 result = []
886 886 _perms = ('usergroup.read', 'usergroup.write', 'usergroup.admin',)
887 887 extras = {'user': apiuser}
888 for user_group in UserGroupList(UserGroupModel().get_all(),
888 for user_group in UserGroupList(UserGroup.get_all(),
889 889 perm_set=_perms, extra_kwargs=extras):
890 890 result.append(user_group.get_api_data())
891 891 return result
@@ -1323,7 +1323,7 b' class ApiController(JSONRPCController):'
1323 1323 if not HasPermissionAnyApi('hg.admin')(user=apiuser):
1324 1324 repos = RepoModel().get_all_user_repos(user=apiuser)
1325 1325 else:
1326 repos = RepoModel().get_all()
1326 repos = Repository.get_all()
1327 1327
1328 1328 for repo in repos:
1329 1329 result.append(repo.get_api_data())
@@ -132,10 +132,3 b' class BaseModel(object):'
132 132 from kallithea.model.db import Permission
133 133 return self._get_instance(Permission, permission,
134 134 callback=Permission.get_by_key)
135
136 @classmethod
137 def get_all(cls):
138 """
139 Returns all instances of what is defined in `cls` class variable
140 """
141 return cls.cls.get_all()
@@ -880,7 +880,7 b' class _BaseTestApi(object):'
880 880 response = api_call(self, params)
881 881
882 882 result = []
883 for repo in RepoModel().get_all():
883 for repo in Repository.get_all():
884 884 result.append(repo.get_api_data())
885 885 ret = jsonify(result)
886 886
@@ -18,7 +18,7 b' Helpers for fixture generation'
18 18 import os
19 19 import time
20 20 from kallithea.tests import *
21 from kallithea.model.db import Repository, User, RepoGroup, UserGroup
21 from kallithea.model.db import Repository, User, RepoGroup, UserGroup, Gist
22 22 from kallithea.model.meta import Session
23 23 from kallithea.model.repo import RepoModel
24 24 from kallithea.model.user import UserModel
@@ -252,7 +252,7 b' class Fixture(object):'
252 252 return gist
253 253
254 254 def destroy_gists(self, gistid=None):
255 for g in GistModel.cls.get_all():
255 for g in Gist.get_all():
256 256 if gistid:
257 257 if gistid == g.gist_access_id:
258 258 GistModel().delete(g)
@@ -1,4 +1,4 b''
1 from kallithea.model.db import User
1 from kallithea.model.db import User, UserGroup
2 2
3 3 from kallithea.tests import *
4 4 from kallithea.tests.fixture import Fixture
@@ -14,7 +14,7 b' class TestUserGroups(TestController):'
14 14
15 15 def teardown_method(self, method):
16 16 # delete all groups
17 for gr in UserGroupModel.get_all():
17 for gr in UserGroup.get_all():
18 18 fixture.destroy_user_group(gr)
19 19 Session().commit()
20 20
@@ -30,7 +30,7 b' class TestUserGroups(TestController):'
30 30 def test_enforce_groups(self, pre_existing, regular_should_be,
31 31 external_should_be, groups, expected):
32 32 # delete all groups
33 for gr in UserGroupModel.get_all():
33 for gr in UserGroup.get_all():
34 34 fixture.destroy_user_group(gr)
35 35 Session().commit()
36 36
General Comments 0
You need to be logged in to leave comments. Login now