##// 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 from kallithea.model.gist import GistModel
48 from kallithea.model.gist import GistModel
49 from kallithea.model.db import (
49 from kallithea.model.db import (
50 Repository, Setting, UserIpMap, Permission, User, Gist,
50 Repository, Setting, UserIpMap, Permission, User, Gist,
51 RepoGroup)
51 RepoGroup, UserGroup)
52 from kallithea.lib.compat import json
52 from kallithea.lib.compat import json
53 from kallithea.lib.exceptions import (
53 from kallithea.lib.exceptions import (
54 DefaultUserException, UserGroupsAssignedException)
54 DefaultUserException, UserGroupsAssignedException)
@@ -885,7 +885,7 b' class ApiController(JSONRPCController):'
885 result = []
885 result = []
886 _perms = ('usergroup.read', 'usergroup.write', 'usergroup.admin',)
886 _perms = ('usergroup.read', 'usergroup.write', 'usergroup.admin',)
887 extras = {'user': apiuser}
887 extras = {'user': apiuser}
888 for user_group in UserGroupList(UserGroupModel().get_all(),
888 for user_group in UserGroupList(UserGroup.get_all(),
889 perm_set=_perms, extra_kwargs=extras):
889 perm_set=_perms, extra_kwargs=extras):
890 result.append(user_group.get_api_data())
890 result.append(user_group.get_api_data())
891 return result
891 return result
@@ -1323,7 +1323,7 b' class ApiController(JSONRPCController):'
1323 if not HasPermissionAnyApi('hg.admin')(user=apiuser):
1323 if not HasPermissionAnyApi('hg.admin')(user=apiuser):
1324 repos = RepoModel().get_all_user_repos(user=apiuser)
1324 repos = RepoModel().get_all_user_repos(user=apiuser)
1325 else:
1325 else:
1326 repos = RepoModel().get_all()
1326 repos = Repository.get_all()
1327
1327
1328 for repo in repos:
1328 for repo in repos:
1329 result.append(repo.get_api_data())
1329 result.append(repo.get_api_data())
@@ -132,10 +132,3 b' class BaseModel(object):'
132 from kallithea.model.db import Permission
132 from kallithea.model.db import Permission
133 return self._get_instance(Permission, permission,
133 return self._get_instance(Permission, permission,
134 callback=Permission.get_by_key)
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 response = api_call(self, params)
880 response = api_call(self, params)
881
881
882 result = []
882 result = []
883 for repo in RepoModel().get_all():
883 for repo in Repository.get_all():
884 result.append(repo.get_api_data())
884 result.append(repo.get_api_data())
885 ret = jsonify(result)
885 ret = jsonify(result)
886
886
@@ -18,7 +18,7 b' Helpers for fixture generation'
18 import os
18 import os
19 import time
19 import time
20 from kallithea.tests import *
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 from kallithea.model.meta import Session
22 from kallithea.model.meta import Session
23 from kallithea.model.repo import RepoModel
23 from kallithea.model.repo import RepoModel
24 from kallithea.model.user import UserModel
24 from kallithea.model.user import UserModel
@@ -252,7 +252,7 b' class Fixture(object):'
252 return gist
252 return gist
253
253
254 def destroy_gists(self, gistid=None):
254 def destroy_gists(self, gistid=None):
255 for g in GistModel.cls.get_all():
255 for g in Gist.get_all():
256 if gistid:
256 if gistid:
257 if gistid == g.gist_access_id:
257 if gistid == g.gist_access_id:
258 GistModel().delete(g)
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 from kallithea.tests import *
3 from kallithea.tests import *
4 from kallithea.tests.fixture import Fixture
4 from kallithea.tests.fixture import Fixture
@@ -14,7 +14,7 b' class TestUserGroups(TestController):'
14
14
15 def teardown_method(self, method):
15 def teardown_method(self, method):
16 # delete all groups
16 # delete all groups
17 for gr in UserGroupModel.get_all():
17 for gr in UserGroup.get_all():
18 fixture.destroy_user_group(gr)
18 fixture.destroy_user_group(gr)
19 Session().commit()
19 Session().commit()
20
20
@@ -30,7 +30,7 b' class TestUserGroups(TestController):'
30 def test_enforce_groups(self, pre_existing, regular_should_be,
30 def test_enforce_groups(self, pre_existing, regular_should_be,
31 external_should_be, groups, expected):
31 external_should_be, groups, expected):
32 # delete all groups
32 # delete all groups
33 for gr in UserGroupModel.get_all():
33 for gr in UserGroup.get_all():
34 fixture.destroy_user_group(gr)
34 fixture.destroy_user_group(gr)
35 Session().commit()
35 Session().commit()
36
36
General Comments 0
You need to be logged in to leave comments. Login now