##// END OF EJS Templates
refactor: renamed get_first_admin to get_first_super_admin which...
marcink -
r278:25d706fe default
parent child Browse files
Show More
@@ -99,7 +99,7 b' class RepoGroupsController(BaseControlle'
99 if repo_group.user:
99 if repo_group.user:
100 data.update({'user': repo_group.user.username})
100 data.update({'user': repo_group.user.username})
101 else:
101 else:
102 replacement_user = User.get_first_admin().username
102 replacement_user = User.get_first_super_admin().username
103 data.update({'user': replacement_user})
103 data.update({'user': replacement_user})
104
104
105 # fill repository group users
105 # fill repository group users
@@ -88,7 +88,7 b' class UserGroupsController(BaseControlle'
88 if user_group.user:
88 if user_group.user:
89 data.update({'user': user_group.user.username})
89 data.update({'user': user_group.user.username})
90 else:
90 else:
91 replacement_user = User.get_first_admin().username
91 replacement_user = User.get_first_super_admin().username
92 data.update({'user': replacement_user})
92 data.update({'user': replacement_user})
93 return data
93 return data
94
94
@@ -403,7 +403,7 b' class UsersController(BaseController):'
403 c.active = 'advanced'
403 c.active = 'advanced'
404 c.perm_user = AuthUser(user_id=user_id, ip_addr=self.ip_addr)
404 c.perm_user = AuthUser(user_id=user_id, ip_addr=self.ip_addr)
405 c.personal_repo_group = RepoGroup.get_by_group_name(user.username)
405 c.personal_repo_group = RepoGroup.get_by_group_name(user.username)
406 c.first_admin = User.get_first_admin()
406 c.first_admin = User.get_first_super_admin()
407 defaults = user.get_dict()
407 defaults = user.get_dict()
408
408
409 # Interim workaround if the user participated on any pull requests as a
409 # Interim workaround if the user participated on any pull requests as a
@@ -492,7 +492,7 b' def map_groups(path):'
492 # last element is repo in nested groups structure
492 # last element is repo in nested groups structure
493 groups = groups[:-1]
493 groups = groups[:-1]
494 rgm = RepoGroupModel(sa)
494 rgm = RepoGroupModel(sa)
495 owner = User.get_first_admin()
495 owner = User.get_first_super_admin()
496 for lvl, group_name in enumerate(groups):
496 for lvl, group_name in enumerate(groups):
497 group_name = '/'.join(groups[:lvl] + [group_name])
497 group_name = '/'.join(groups[:lvl] + [group_name])
498 group = RepoGroup.get_by_group_name(group_name)
498 group = RepoGroup.get_by_group_name(group_name)
@@ -533,7 +533,7 b' def repo2db_mapper(initial_repo_list, re'
533
533
534 sa = meta.Session()
534 sa = meta.Session()
535 repo_model = RepoModel()
535 repo_model = RepoModel()
536 user = User.get_first_admin()
536 user = User.get_first_super_admin()
537 added = []
537 added = []
538
538
539 # creation defaults
539 # creation defaults
@@ -776,8 +776,8 b' class User(Base, BaseModel):'
776 Session().add(self)
776 Session().add(self)
777
777
778 @classmethod
778 @classmethod
779 def get_first_admin(cls):
779 def get_first_super_admin(cls):
780 user = User.query().filter(User.admin == True).first()
780 user = User.query().filter(User.admin == true()).first()
781 if user is None:
781 if user is None:
782 raise Exception('Missing administrative account!')
782 raise Exception('Missing administrative account!')
783 return user
783 return user
@@ -339,7 +339,7 b' class RepoModel(BaseModel):'
339 if repo_info.user:
339 if repo_info.user:
340 defaults.update({'user': repo_info.user.username})
340 defaults.update({'user': repo_info.user.username})
341 else:
341 else:
342 replacement_user = User.get_first_admin().username
342 replacement_user = User.get_first_super_admin().username
343 defaults.update({'user': replacement_user})
343 defaults.update({'user': replacement_user})
344
344
345 # fill repository users
345 # fill repository users
@@ -377,7 +377,7 b' class UserModel(BaseModel):'
377 raise
377 raise
378
378
379 def _handle_user_repos(self, username, repositories, handle_mode=None):
379 def _handle_user_repos(self, username, repositories, handle_mode=None):
380 _superadmin = self.cls.get_first_admin()
380 _superadmin = self.cls.get_first_super_admin()
381 left_overs = True
381 left_overs = True
382
382
383 from rhodecode.model.repo import RepoModel
383 from rhodecode.model.repo import RepoModel
@@ -400,7 +400,7 b' class UserModel(BaseModel):'
400
400
401 def _handle_user_repo_groups(self, username, repository_groups,
401 def _handle_user_repo_groups(self, username, repository_groups,
402 handle_mode=None):
402 handle_mode=None):
403 _superadmin = self.cls.get_first_admin()
403 _superadmin = self.cls.get_first_super_admin()
404 left_overs = True
404 left_overs = True
405
405
406 from rhodecode.model.repo_group import RepoGroupModel
406 from rhodecode.model.repo_group import RepoGroupModel
@@ -422,7 +422,7 b' class UserModel(BaseModel):'
422 return left_overs
422 return left_overs
423
423
424 def _handle_user_user_groups(self, username, user_groups, handle_mode=None):
424 def _handle_user_user_groups(self, username, user_groups, handle_mode=None):
425 _superadmin = self.cls.get_first_admin()
425 _superadmin = self.cls.get_first_super_admin()
426 left_overs = True
426 left_overs = True
427
427
428 from rhodecode.model.user_group import UserGroupModel
428 from rhodecode.model.user_group import UserGroupModel
@@ -498,7 +498,7 b' class UserGroupModel(BaseModel):'
498 self.remove_user_from_group(gr, user)
498 self.remove_user_from_group(gr, user)
499
499
500 # now we calculate in which groups user should be == groups params
500 # now we calculate in which groups user should be == groups params
501 owner = User.get_first_admin().username
501 owner = User.get_first_super_admin().username
502 for gr in set(groups):
502 for gr in set(groups):
503 existing_group = UserGroup.get_by_group_name(gr)
503 existing_group = UserGroup.get_by_group_name(gr)
504 if not existing_group:
504 if not existing_group:
@@ -33,7 +33,7 b' class TestFeedController(TestController)'
33 assert """<rss version="2.0">""" in response
33 assert """<rss version="2.0">""" in response
34
34
35 def test_rss_with_auth_token(self, backend):
35 def test_rss_with_auth_token(self, backend):
36 auth_token = User.get_first_admin().feed_token
36 auth_token = User.get_first_super_admin().feed_token
37 assert auth_token != ''
37 assert auth_token != ''
38 response = self.app.get(url(controller='feed', action='rss',
38 response = self.app.get(url(controller='feed', action='rss',
39 repo_name=backend.repo_name, auth_token=auth_token))
39 repo_name=backend.repo_name, auth_token=auth_token))
@@ -448,7 +448,7 b' class TestLoginController:'
448 assert [] == whitelist['api_access_controllers_whitelist']
448 assert [] == whitelist['api_access_controllers_whitelist']
449 if test_name == 'proper_auth_token':
449 if test_name == 'proper_auth_token':
450 # use builtin if api_key is None
450 # use builtin if api_key is None
451 auth_token = User.get_first_admin().api_key
451 auth_token = User.get_first_super_admin().api_key
452
452
453 with fixture.anon_access(False):
453 with fixture.anon_access(False):
454 self.app.get(url(controller='changeset',
454 self.app.get(url(controller='changeset',
@@ -471,7 +471,7 b' class TestLoginController:'
471 assert ['ChangesetController:changeset_raw'] == \
471 assert ['ChangesetController:changeset_raw'] == \
472 whitelist['api_access_controllers_whitelist']
472 whitelist['api_access_controllers_whitelist']
473 if test_name == 'proper_auth_token':
473 if test_name == 'proper_auth_token':
474 auth_token = User.get_first_admin().api_key
474 auth_token = User.get_first_super_admin().api_key
475
475
476 with fixture.anon_access(False):
476 with fixture.anon_access(False):
477 self.app.get(url(controller='changeset',
477 self.app.get(url(controller='changeset',
General Comments 0
You need to be logged in to leave comments. Login now