##// END OF EJS Templates
refactoring of models names for repoGroup permissions
marcink -
r1633:2c0d35e3 beta
parent child Browse files
Show More
@@ -39,7 +39,7 b' from rhodecode.lib import helpers as h'
39 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
39 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
40 from rhodecode.lib.exceptions import LdapImportError
40 from rhodecode.lib.exceptions import LdapImportError
41 from rhodecode.model.forms import LdapSettingsForm
41 from rhodecode.model.forms import LdapSettingsForm
42 from rhodecode.model.db import RhodeCodeSettings
42 from rhodecode.model.db import RhodeCodeSetting
43
43
44 log = logging.getLogger(__name__)
44 log = logging.getLogger(__name__)
45
45
@@ -83,7 +83,7 b' class LdapSettingsController(BaseControl'
83 super(LdapSettingsController, self).__before__()
83 super(LdapSettingsController, self).__before__()
84
84
85 def index(self):
85 def index(self):
86 defaults = RhodeCodeSettings.get_ldap_settings()
86 defaults = RhodeCodeSetting.get_ldap_settings()
87 c.search_scope_cur = defaults.get('ldap_search_scope')
87 c.search_scope_cur = defaults.get('ldap_search_scope')
88 c.tls_reqcert_cur = defaults.get('ldap_tls_reqcert')
88 c.tls_reqcert_cur = defaults.get('ldap_tls_reqcert')
89 c.tls_kind_cur = defaults.get('ldap_tls_kind')
89 c.tls_kind_cur = defaults.get('ldap_tls_kind')
@@ -107,7 +107,7 b' class LdapSettingsController(BaseControl'
107
107
108 for k, v in form_result.items():
108 for k, v in form_result.items():
109 if k.startswith('ldap_'):
109 if k.startswith('ldap_'):
110 setting = RhodeCodeSettings.get_by_name(k)
110 setting = RhodeCodeSetting.get_by_name(k)
111 setting.app_settings_value = v
111 setting.app_settings_value = v
112 self.sa.add(setting)
112 self.sa.add(setting)
113
113
@@ -39,7 +39,7 b' from rhodecode.lib.auth import LoginRequ'
39 from rhodecode.lib.base import BaseController, render
39 from rhodecode.lib.base import BaseController, render
40 from rhodecode.lib.utils import invalidate_cache, action_logger, repo_name_slug
40 from rhodecode.lib.utils import invalidate_cache, action_logger, repo_name_slug
41 from rhodecode.lib.helpers import get_token
41 from rhodecode.lib.helpers import get_token
42 from rhodecode.model.db import User, Repository, UserFollowing, Group
42 from rhodecode.model.db import User, Repository, UserFollowing, RepoGroup
43 from rhodecode.model.forms import RepoForm
43 from rhodecode.model.forms import RepoForm
44 from rhodecode.model.scm import ScmModel
44 from rhodecode.model.scm import ScmModel
45 from rhodecode.model.repo import RepoModel
45 from rhodecode.model.repo import RepoModel
@@ -63,7 +63,7 b' class ReposController(BaseController):'
63 super(ReposController, self).__before__()
63 super(ReposController, self).__before__()
64
64
65 def __load_defaults(self):
65 def __load_defaults(self):
66 c.repo_groups = Group.groups_choices()
66 c.repo_groups = RepoGroup.groups_choices()
67 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
67 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
68
68
69 repo_model = RepoModel()
69 repo_model = RepoModel()
@@ -14,7 +14,7 b' from sqlalchemy.exc import IntegrityErro'
14 from rhodecode.lib import helpers as h
14 from rhodecode.lib import helpers as h
15 from rhodecode.lib.auth import LoginRequired, HasPermissionAnyDecorator
15 from rhodecode.lib.auth import LoginRequired, HasPermissionAnyDecorator
16 from rhodecode.lib.base import BaseController, render
16 from rhodecode.lib.base import BaseController, render
17 from rhodecode.model.db import Group
17 from rhodecode.model.db import RepoGroup
18 from rhodecode.model.repos_group import ReposGroupModel
18 from rhodecode.model.repos_group import ReposGroupModel
19 from rhodecode.model.forms import ReposGroupForm
19 from rhodecode.model.forms import ReposGroupForm
20
20
@@ -32,7 +32,7 b' class ReposGroupsController(BaseControll'
32 super(ReposGroupsController, self).__before__()
32 super(ReposGroupsController, self).__before__()
33
33
34 def __load_defaults(self):
34 def __load_defaults(self):
35 c.repo_groups = Group.groups_choices()
35 c.repo_groups = RepoGroup.groups_choices()
36 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
36 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
37
37
38 def __load_data(self, group_id):
38 def __load_data(self, group_id):
@@ -43,7 +43,7 b' class ReposGroupsController(BaseControll'
43 """
43 """
44 self.__load_defaults()
44 self.__load_defaults()
45
45
46 repo_group = Group.get(group_id)
46 repo_group = RepoGroup.get(group_id)
47
47
48 data = repo_group.get_dict()
48 data = repo_group.get_dict()
49
49
@@ -57,7 +57,7 b' class ReposGroupsController(BaseControll'
57 # url('repos_groups')
57 # url('repos_groups')
58
58
59 sk = lambda g:g.parents[0].group_name if g.parents else g.group_name
59 sk = lambda g:g.parents[0].group_name if g.parents else g.group_name
60 c.groups = sorted(Group.query().all(), key=sk)
60 c.groups = sorted(RepoGroup.query().all(), key=sk)
61 return render('admin/repos_groups/repos_groups_show.html')
61 return render('admin/repos_groups/repos_groups_show.html')
62
62
63 @HasPermissionAnyDecorator('hg.admin')
63 @HasPermissionAnyDecorator('hg.admin')
@@ -108,7 +108,7 b' class ReposGroupsController(BaseControll'
108 # url('repos_group', id=ID)
108 # url('repos_group', id=ID)
109
109
110 self.__load_defaults()
110 self.__load_defaults()
111 c.repos_group = Group.get(id)
111 c.repos_group = RepoGroup.get(id)
112
112
113 repos_group_model = ReposGroupModel()
113 repos_group_model = ReposGroupModel()
114 repos_group_form = ReposGroupForm(edit=True,
114 repos_group_form = ReposGroupForm(edit=True,
@@ -148,7 +148,7 b' class ReposGroupsController(BaseControll'
148 # url('repos_group', id=ID)
148 # url('repos_group', id=ID)
149
149
150 repos_group_model = ReposGroupModel()
150 repos_group_model = ReposGroupModel()
151 gr = Group.get(id)
151 gr = RepoGroup.get(id)
152 repos = gr.repositories.all()
152 repos = gr.repositories.all()
153 if repos:
153 if repos:
154 h.flash(_('This group contains %s repositores and cannot be '
154 h.flash(_('This group contains %s repositores and cannot be '
@@ -179,14 +179,14 b' class ReposGroupsController(BaseControll'
179 return redirect(url('repos_groups'))
179 return redirect(url('repos_groups'))
180
180
181 def show_by_name(self, group_name):
181 def show_by_name(self, group_name):
182 id_ = Group.get_by_group_name(group_name).group_id
182 id_ = RepoGroup.get_by_group_name(group_name).group_id
183 return self.show(id_)
183 return self.show(id_)
184
184
185 def show(self, id, format='html'):
185 def show(self, id, format='html'):
186 """GET /repos_groups/id: Show a specific item"""
186 """GET /repos_groups/id: Show a specific item"""
187 # url('repos_group', id=ID)
187 # url('repos_group', id=ID)
188
188
189 c.group = Group.get(id)
189 c.group = RepoGroup.get(id)
190
190
191 if c.group:
191 if c.group:
192 c.group_repos = c.group.repositories.all()
192 c.group_repos = c.group.repositories.all()
@@ -201,8 +201,8 b' class ReposGroupsController(BaseControll'
201
201
202 c.repo_cnt = 0
202 c.repo_cnt = 0
203
203
204 c.groups = self.sa.query(Group).order_by(Group.group_name)\
204 c.groups = self.sa.query(RepoGroup).order_by(RepoGroup.group_name)\
205 .filter(Group.group_parent_id == id).all()
205 .filter(RepoGroup.group_parent_id == id).all()
206
206
207 return render('admin/repos_groups/repos_groups.html')
207 return render('admin/repos_groups/repos_groups.html')
208
208
@@ -213,7 +213,7 b' class ReposGroupsController(BaseControll'
213
213
214 id_ = int(id)
214 id_ = int(id)
215
215
216 c.repos_group = Group.get(id_)
216 c.repos_group = RepoGroup.get(id_)
217 defaults = self.__load_data(id_)
217 defaults = self.__load_data(id_)
218
218
219 # we need to exclude this group from the group list for editing
219 # we need to exclude this group from the group list for editing
@@ -40,8 +40,8 b' from rhodecode.lib.base import BaseContr'
40 from rhodecode.lib.celerylib import tasks, run_task
40 from rhodecode.lib.celerylib import tasks, run_task
41 from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \
41 from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \
42 set_rhodecode_config, repo_name_slug
42 set_rhodecode_config, repo_name_slug
43 from rhodecode.model.db import RhodeCodeUi, Repository, Group, \
43 from rhodecode.model.db import RhodeCodeUi, Repository, RepoGroup, \
44 RhodeCodeSettings
44 RhodeCodeSetting
45 from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \
45 from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \
46 ApplicationUiSettingsForm
46 ApplicationUiSettingsForm
47 from rhodecode.model.scm import ScmModel
47 from rhodecode.model.scm import ScmModel
@@ -69,7 +69,7 b' class SettingsController(BaseController)'
69 """GET /admin/settings: All items in the collection"""
69 """GET /admin/settings: All items in the collection"""
70 # url('admin_settings')
70 # url('admin_settings')
71
71
72 defaults = RhodeCodeSettings.get_app_settings()
72 defaults = RhodeCodeSetting.get_app_settings()
73 defaults.update(self.get_hg_ui_settings())
73 defaults.update(self.get_hg_ui_settings())
74 return htmlfill.render(
74 return htmlfill.render(
75 render('admin/settings/settings.html'),
75 render('admin/settings/settings.html'),
@@ -124,15 +124,15 b' class SettingsController(BaseController)'
124 form_result = application_form.to_python(dict(request.POST))
124 form_result = application_form.to_python(dict(request.POST))
125
125
126 try:
126 try:
127 hgsettings1 = RhodeCodeSettings.get_by_name('title')
127 hgsettings1 = RhodeCodeSetting.get_by_name('title')
128 hgsettings1.app_settings_value = \
128 hgsettings1.app_settings_value = \
129 form_result['rhodecode_title']
129 form_result['rhodecode_title']
130
130
131 hgsettings2 = RhodeCodeSettings.get_by_name('realm')
131 hgsettings2 = RhodeCodeSetting.get_by_name('realm')
132 hgsettings2.app_settings_value = \
132 hgsettings2.app_settings_value = \
133 form_result['rhodecode_realm']
133 form_result['rhodecode_realm']
134
134
135 hgsettings3 = RhodeCodeSettings.get_by_name('ga_code')
135 hgsettings3 = RhodeCodeSetting.get_by_name('ga_code')
136 hgsettings3.app_settings_value = \
136 hgsettings3.app_settings_value = \
137 form_result['rhodecode_ga_code']
137 form_result['rhodecode_ga_code']
138
138
@@ -366,7 +366,7 b' class SettingsController(BaseController)'
366 def create_repository(self):
366 def create_repository(self):
367 """GET /_admin/create_repository: Form to create a new item"""
367 """GET /_admin/create_repository: Form to create a new item"""
368
368
369 c.repo_groups = Group.groups_choices()
369 c.repo_groups = RepoGroup.groups_choices()
370 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
370 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
371
371
372 new_repo = request.GET.get('repo', '')
372 new_repo = request.GET.get('repo', '')
@@ -38,7 +38,7 b' from rhodecode.lib import helpers as h'
38 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
38 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
39 from rhodecode.lib.base import BaseController, render
39 from rhodecode.lib.base import BaseController, render
40
40
41 from rhodecode.model.db import User, RepoToPerm, UserToPerm, Permission
41 from rhodecode.model.db import User, UserRepoToPerm, UserToPerm, Permission
42 from rhodecode.model.forms import UserForm
42 from rhodecode.model.forms import UserForm
43 from rhodecode.model.user import UserModel
43 from rhodecode.model.user import UserModel
44
44
@@ -6,7 +6,7 b' from rhodecode.lib.auth import HasPermis'
6 HasPermissionAnyDecorator
6 HasPermissionAnyDecorator
7 from rhodecode.model.scm import ScmModel
7 from rhodecode.model.scm import ScmModel
8
8
9 from rhodecode.model.db import User, UsersGroup, Group, Repository
9 from rhodecode.model.db import User, UsersGroup, RepoGroup, Repository
10 from rhodecode.model.repo import RepoModel
10 from rhodecode.model.repo import RepoModel
11 from rhodecode.model.user import UserModel
11 from rhodecode.model.user import UserModel
12 from rhodecode.model.repo_permission import RepositoryPermissionModel
12 from rhodecode.model.repo_permission import RepositoryPermissionModel
@@ -325,7 +325,7 b' class ApiController(JSONRPCController):'
325 groups = groups[:-1]
325 groups = groups[:-1]
326 parent_id = None
326 parent_id = None
327 for g in groups:
327 for g in groups:
328 group = Group.get_by_group_name(g)
328 group = RepoGroup.get_by_group_name(g)
329 if not group:
329 if not group:
330 group = ReposGroupModel().create(dict(group_name=g,
330 group = ReposGroupModel().create(dict(group_name=g,
331 group_description='',
331 group_description='',
@@ -30,7 +30,7 b' from paste.httpexceptions import HTTPBad'
30
30
31 from rhodecode.lib.auth import LoginRequired
31 from rhodecode.lib.auth import LoginRequired
32 from rhodecode.lib.base import BaseController, render
32 from rhodecode.lib.base import BaseController, render
33 from rhodecode.model.db import Group, Repository
33 from rhodecode.model.db import RepoGroup, Repository
34
34
35 log = logging.getLogger(__name__)
35 log = logging.getLogger(__name__)
36
36
@@ -45,7 +45,7 b' class HomeController(BaseController):'
45
45
46 c.repos_list = self.scm_model.get_repos()
46 c.repos_list = self.scm_model.get_repos()
47
47
48 c.groups = Group.query().filter(Group.group_parent_id == None).all()
48 c.groups = RepoGroup.query().filter(RepoGroup.group_parent_id == None).all()
49
49
50 return render('/index.html')
50 return render('/index.html')
51
51
@@ -42,7 +42,7 b' from rhodecode.lib.utils import invalida'
42
42
43 from rhodecode.model.forms import RepoSettingsForm, RepoForkForm
43 from rhodecode.model.forms import RepoSettingsForm, RepoForkForm
44 from rhodecode.model.repo import RepoModel
44 from rhodecode.model.repo import RepoModel
45 from rhodecode.model.db import Group
45 from rhodecode.model.db import RepoGroup
46
46
47 log = logging.getLogger(__name__)
47 log = logging.getLogger(__name__)
48
48
@@ -54,7 +54,7 b' class SettingsController(BaseRepoControl'
54 super(SettingsController, self).__before__()
54 super(SettingsController, self).__before__()
55
55
56 def __load_defaults(self):
56 def __load_defaults(self):
57 c.repo_groups = Group.groups_choices()
57 c.repo_groups = RepoGroup.groups_choices()
58 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
58 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
59
59
60 repo_model = RepoModel()
60 repo_model = RepoModel()
@@ -48,7 +48,7 b' from rhodecode.lib.auth_ldap import Auth'
48
48
49 from rhodecode.model import meta
49 from rhodecode.model import meta
50 from rhodecode.model.user import UserModel
50 from rhodecode.model.user import UserModel
51 from rhodecode.model.db import Permission, RhodeCodeSettings, User
51 from rhodecode.model.db import Permission, RhodeCodeSetting, User
52
52
53 log = logging.getLogger(__name__)
53 log = logging.getLogger(__name__)
54
54
@@ -184,7 +184,7 b' def authenticate(username, password):'
184 log.debug('this user already exists as non ldap')
184 log.debug('this user already exists as non ldap')
185 return False
185 return False
186
186
187 ldap_settings = RhodeCodeSettings.get_ldap_settings()
187 ldap_settings = RhodeCodeSetting.get_ldap_settings()
188 #======================================================================
188 #======================================================================
189 # FALLBACK TO LDAP AUTH IF ENABLE
189 # FALLBACK TO LDAP AUTH IF ENABLE
190 #======================================================================
190 #======================================================================
@@ -37,7 +37,7 b' from rhodecode.lib.auth import get_crypt'
37 from rhodecode.lib.utils import ask_ok
37 from rhodecode.lib.utils import ask_ok
38 from rhodecode.model import init_model
38 from rhodecode.model import init_model
39 from rhodecode.model.db import User, Permission, RhodeCodeUi, \
39 from rhodecode.model.db import User, Permission, RhodeCodeUi, \
40 RhodeCodeSettings, UserToPerm, DbMigrateVersion
40 RhodeCodeSetting, UserToPerm, DbMigrateVersion
41
41
42 from sqlalchemy.engine import create_engine
42 from sqlalchemy.engine import create_engine
43
43
@@ -210,7 +210,7 b' class DbManage(object):'
210 """Fixes rhodecode settings adds ga_code key for google analytics
210 """Fixes rhodecode settings adds ga_code key for google analytics
211 """
211 """
212
212
213 hgsettings3 = RhodeCodeSettings('ga_code', '')
213 hgsettings3 = RhodeCodeSetting('ga_code', '')
214
214
215 try:
215 try:
216 self.sa.add(hgsettings3)
216 self.sa.add(hgsettings3)
@@ -321,10 +321,10 b' class DbManage(object):'
321 ('ldap_attr_login', ''), ('ldap_attr_firstname', ''),
321 ('ldap_attr_login', ''), ('ldap_attr_firstname', ''),
322 ('ldap_attr_lastname', ''), ('ldap_attr_email', '')]:
322 ('ldap_attr_lastname', ''), ('ldap_attr_email', '')]:
323
323
324 if skip_existing and RhodeCodeSettings.get_by_name(k) != None:
324 if skip_existing and RhodeCodeSetting.get_by_name(k) != None:
325 log.debug('Skipping option %s' % k)
325 log.debug('Skipping option %s' % k)
326 continue
326 continue
327 setting = RhodeCodeSettings(k, v)
327 setting = RhodeCodeSetting(k, v)
328 self.sa.add(setting)
328 self.sa.add(setting)
329 self.sa.commit()
329 self.sa.commit()
330 except:
330 except:
@@ -391,9 +391,9 b' class DbManage(object):'
391 paths.ui_key = '/'
391 paths.ui_key = '/'
392 paths.ui_value = path
392 paths.ui_value = path
393
393
394 hgsettings1 = RhodeCodeSettings('realm', 'RhodeCode authentication')
394 hgsettings1 = RhodeCodeSetting('realm', 'RhodeCode authentication')
395 hgsettings2 = RhodeCodeSettings('title', 'RhodeCode')
395 hgsettings2 = RhodeCodeSetting('title', 'RhodeCode')
396 hgsettings3 = RhodeCodeSettings('ga_code', '')
396 hgsettings3 = RhodeCodeSetting('ga_code', '')
397
397
398 try:
398 try:
399 self.sa.add(web1)
399 self.sa.add(web1)
@@ -45,8 +45,8 b' from vcs.exceptions import VCSError'
45
45
46 from rhodecode.model import meta
46 from rhodecode.model import meta
47 from rhodecode.model.caching_query import FromCache
47 from rhodecode.model.caching_query import FromCache
48 from rhodecode.model.db import Repository, User, RhodeCodeUi, UserLog, Group, \
48 from rhodecode.model.db import Repository, User, RhodeCodeUi, UserLog, RepoGroup, \
49 RhodeCodeSettings
49 RhodeCodeSetting
50 from rhodecode.model.repo import RepoModel
50 from rhodecode.model.repo import RepoModel
51
51
52 log = logging.getLogger(__name__)
52 log = logging.getLogger(__name__)
@@ -290,7 +290,7 b' def set_rhodecode_config(config):'
290
290
291 :param config:
291 :param config:
292 """
292 """
293 hgsettings = RhodeCodeSettings.get_app_settings()
293 hgsettings = RhodeCodeSetting.get_app_settings()
294
294
295 for k, v in hgsettings.items():
295 for k, v in hgsettings.items():
296 config[k] = v
296 config[k] = v
@@ -366,10 +366,10 b' def map_groups(groups):'
366
366
367 for lvl, group_name in enumerate(groups):
367 for lvl, group_name in enumerate(groups):
368 group_name = '/'.join(groups[:lvl] + [group_name])
368 group_name = '/'.join(groups[:lvl] + [group_name])
369 group = sa.query(Group).filter(Group.group_name == group_name).scalar()
369 group = sa.query(RepoGroup).filter(RepoGroup.group_name == group_name).scalar()
370
370
371 if group is None:
371 if group is None:
372 group = Group(group_name, parent)
372 group = RepoGroup(group_name, parent)
373 sa.add(group)
373 sa.add(group)
374 sa.commit()
374 sa.commit()
375 parent = group
375 parent = group
@@ -391,7 +391,7 b' def repo2db_mapper(initial_repo_list, re'
391 added = []
391 added = []
392 # fixup groups paths to new format on the fly
392 # fixup groups paths to new format on the fly
393 # TODO: remove this in future
393 # TODO: remove this in future
394 for g in Group.query().all():
394 for g in RepoGroup.query().all():
395 g.group_name = g.get_new_name(g.name)
395 g.group_name = g.get_new_name(g.name)
396 sa.add(g)
396 sa.add(g)
397 for name, repo in initial_repo_list.items():
397 for name, repo in initial_repo_list.items():
@@ -139,7 +139,7 b' class BaseModel(object):'
139 Session.commit()
139 Session.commit()
140
140
141
141
142 class RhodeCodeSettings(Base, BaseModel):
142 class RhodeCodeSetting(Base, BaseModel):
143 __tablename__ = 'rhodecode_settings'
143 __tablename__ = 'rhodecode_settings'
144 __table_args__ = (UniqueConstraint('app_settings_name'), {'extend_existing':True})
144 __table_args__ = (UniqueConstraint('app_settings_name'), {'extend_existing':True})
145 app_settings_id = Column("app_settings_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
145 app_settings_id = Column("app_settings_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
@@ -280,7 +280,7 b' class User(Base, BaseModel):'
280
280
281 repositories = relationship('Repository')
281 repositories = relationship('Repository')
282 user_followers = relationship('UserFollowing', primaryjoin='UserFollowing.follows_user_id==User.user_id', cascade='all')
282 user_followers = relationship('UserFollowing', primaryjoin='UserFollowing.follows_user_id==User.user_id', cascade='all')
283 repo_to_perm = relationship('RepoToPerm', primaryjoin='RepoToPerm.user_id==User.user_id', cascade='all')
283 repo_to_perm = relationship('UserRepoToPerm', primaryjoin='UserRepoToPerm.user_id==User.user_id', cascade='all')
284
284
285 group_member = relationship('UsersGroupMember', cascade='all')
285 group_member = relationship('UsersGroupMember', cascade='all')
286
286
@@ -447,7 +447,7 b' class UsersGroup(Base, BaseModel):'
447 users_group_id).all()
447 users_group_id).all()
448
448
449 if assigned_groups:
449 if assigned_groups:
450 raise UsersGroupsAssignedException('Group assigned to %s' %
450 raise UsersGroupsAssignedException('RepoGroup assigned to %s' %
451 assigned_groups)
451 assigned_groups)
452
452
453 users_group = cls.get(users_group_id, cache=False)
453 users_group = cls.get(users_group_id, cache=False)
@@ -503,8 +503,8 b' class Repository(Base, BaseModel):'
503
503
504 user = relationship('User')
504 user = relationship('User')
505 fork = relationship('Repository', remote_side=repo_id)
505 fork = relationship('Repository', remote_side=repo_id)
506 group = relationship('Group')
506 group = relationship('RepoGroup')
507 repo_to_perm = relationship('RepoToPerm', cascade='all', order_by='RepoToPerm.repo_to_perm_id')
507 repo_to_perm = relationship('UserRepoToPerm', cascade='all', order_by='UserRepoToPerm.repo_to_perm_id')
508 users_group_to_perm = relationship('UsersGroupRepoToPerm', cascade='all')
508 users_group_to_perm = relationship('UsersGroupRepoToPerm', cascade='all')
509 stats = relationship('Statistics', cascade='all', uselist=False)
509 stats = relationship('Statistics', cascade='all', uselist=False)
510
510
@@ -717,7 +717,7 b' class Repository(Base, BaseModel):'
717 return repo
717 return repo
718
718
719
719
720 class Group(Base, BaseModel):
720 class RepoGroup(Base, BaseModel):
721 __tablename__ = 'groups'
721 __tablename__ = 'groups'
722 __table_args__ = (UniqueConstraint('group_name', 'group_parent_id'),
722 __table_args__ = (UniqueConstraint('group_name', 'group_parent_id'),
723 CheckConstraint('group_id != group_parent_id'), {'extend_existing':True},)
723 CheckConstraint('group_id != group_parent_id'), {'extend_existing':True},)
@@ -728,7 +728,7 b' class Group(Base, BaseModel):'
728 group_parent_id = Column("group_parent_id", Integer(), ForeignKey('groups.group_id'), nullable=True, unique=None, default=None)
728 group_parent_id = Column("group_parent_id", Integer(), ForeignKey('groups.group_id'), nullable=True, unique=None, default=None)
729 group_description = Column("group_description", String(length=10000, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
729 group_description = Column("group_description", String(length=10000, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
730
730
731 parent_group = relationship('Group', remote_side=group_id)
731 parent_group = relationship('RepoGroup', remote_side=group_id)
732
732
733
733
734 def __init__(self, group_name='', parent_group=None):
734 def __init__(self, group_name='', parent_group=None):
@@ -795,11 +795,11 b' class Group(Base, BaseModel):'
795
795
796 @property
796 @property
797 def children(self):
797 def children(self):
798 return Group.query().filter(Group.parent_group == self)
798 return RepoGroup.query().filter(RepoGroup.parent_group == self)
799
799
800 @property
800 @property
801 def name(self):
801 def name(self):
802 return self.group_name.split(Group.url_sep())[-1]
802 return self.group_name.split(RepoGroup.url_sep())[-1]
803
803
804 @property
804 @property
805 def full_path(self):
805 def full_path(self):
@@ -807,7 +807,7 b' class Group(Base, BaseModel):'
807
807
808 @property
808 @property
809 def full_path_splitted(self):
809 def full_path_splitted(self):
810 return self.group_name.split(Group.url_sep())
810 return self.group_name.split(RepoGroup.url_sep())
811
811
812 @property
812 @property
813 def repositories(self):
813 def repositories(self):
@@ -835,7 +835,7 b' class Group(Base, BaseModel):'
835 """
835 """
836 path_prefix = (self.parent_group.full_path_splitted if
836 path_prefix = (self.parent_group.full_path_splitted if
837 self.parent_group else [])
837 self.parent_group else [])
838 return Group.url_sep().join(path_prefix + [group_name])
838 return RepoGroup.url_sep().join(path_prefix + [group_name])
839
839
840
840
841 class Permission(Base, BaseModel):
841 class Permission(Base, BaseModel):
@@ -853,7 +853,7 b' class Permission(Base, BaseModel):'
853 def get_by_key(cls, key):
853 def get_by_key(cls, key):
854 return cls.query().filter(cls.permission_name == key).scalar()
854 return cls.query().filter(cls.permission_name == key).scalar()
855
855
856 class RepoToPerm(Base, BaseModel):
856 class UserRepoToPerm(Base, BaseModel):
857 __tablename__ = 'repo_to_perm'
857 __tablename__ = 'repo_to_perm'
858 __table_args__ = (UniqueConstraint('user_id', 'repository_id'), {'extend_existing':True})
858 __table_args__ = (UniqueConstraint('user_id', 'repository_id'), {'extend_existing':True})
859 repo_to_perm_id = Column("repo_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
859 repo_to_perm_id = Column("repo_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
@@ -973,7 +973,7 b' class UsersGroupToPerm(Base, BaseModel):'
973 Session.rollback()
973 Session.rollback()
974
974
975
975
976 class GroupToPerm(Base, BaseModel):
976 class UserRepoGroupToPerm(Base, BaseModel):
977 __tablename__ = 'group_to_perm'
977 __tablename__ = 'group_to_perm'
978 __table_args__ = (UniqueConstraint('group_id', 'permission_id'), {'extend_existing':True})
978 __table_args__ = (UniqueConstraint('group_id', 'permission_id'), {'extend_existing':True})
979
979
@@ -984,7 +984,20 b' class GroupToPerm(Base, BaseModel):'
984
984
985 user = relationship('User')
985 user = relationship('User')
986 permission = relationship('Permission')
986 permission = relationship('Permission')
987 group = relationship('Group')
987 group = relationship('RepoGroup')
988
989 class UsersGroupRepoGroupToPerm(Base, BaseModel):
990 __tablename__ = 'users_group_repo_group_to_perm'
991 __table_args__ = (UniqueConstraint('group_id', 'permission_id'), {'extend_existing':True})
992
993 users_group_repo_group_to_perm_id = Column("users_group_repo_group_to_perm_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
994 users_group_id = Column("users_group_id", Integer(), ForeignKey('users_groups.users_group_id'), nullable=False, unique=None, default=None)
995 permission_id = Column("permission_id", Integer(), ForeignKey('permissions.permission_id'), nullable=False, unique=None, default=None)
996 group_id = Column("group_id", Integer(), ForeignKey('groups.group_id'), nullable=False, unique=None, default=None)
997
998 users_group = relationship('UsersGroup')
999 permission = relationship('Permission')
1000 group = relationship('RepoGroup')
988
1001
989 class Statistics(Base, BaseModel):
1002 class Statistics(Base, BaseModel):
990 __tablename__ = 'statistics'
1003 __tablename__ = 'statistics'
@@ -38,7 +38,7 b' from rhodecode.lib.auth import authentic'
38 from rhodecode.lib.exceptions import LdapImportError
38 from rhodecode.lib.exceptions import LdapImportError
39 from rhodecode.model.user import UserModel
39 from rhodecode.model.user import UserModel
40 from rhodecode.model.repo import RepoModel
40 from rhodecode.model.repo import RepoModel
41 from rhodecode.model.db import User, UsersGroup, Group
41 from rhodecode.model.db import User, UsersGroup, RepoGroup
42 from rhodecode import BACKENDS
42 from rhodecode import BACKENDS
43
43
44 log = logging.getLogger(__name__)
44 log = logging.getLogger(__name__)
@@ -107,7 +107,7 b' def ValidUsersGroup(edit, old_data):'
107
107
108
108
109 if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None:
109 if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None:
110 raise formencode.Invalid(_('Group name may only contain '
110 raise formencode.Invalid(_('RepoGroup name may only contain '
111 'alphanumeric characters '
111 'alphanumeric characters '
112 'underscores, periods or dashes '
112 'underscores, periods or dashes '
113 'and must begin with alphanumeric '
113 'and must begin with alphanumeric '
@@ -136,13 +136,13 b' def ValidReposGroup(edit, old_data):'
136
136
137 old_gname = None
137 old_gname = None
138 if edit:
138 if edit:
139 old_gname = Group.get(
139 old_gname = RepoGroup.get(
140 old_data.get('group_id')).group_name
140 old_data.get('group_id')).group_name
141
141
142 if old_gname != group_name or not edit:
142 if old_gname != group_name or not edit:
143 # check filesystem
143 # check filesystem
144 gr = Group.query().filter(Group.group_name == slug)\
144 gr = RepoGroup.query().filter(RepoGroup.group_name == slug)\
145 .filter(Group.group_parent_id == group_parent_id).scalar()
145 .filter(RepoGroup.group_parent_id == group_parent_id).scalar()
146
146
147 if gr:
147 if gr:
148 e_dict = {'group_name':_('This group already exists')}
148 e_dict = {'group_name':_('This group already exists')}
@@ -248,12 +248,12 b' def ValidRepoName(edit, old_data):'
248
248
249
249
250 if value.get('repo_group'):
250 if value.get('repo_group'):
251 gr = Group.get(value.get('repo_group'))
251 gr = RepoGroup.get(value.get('repo_group'))
252 group_path = gr.full_path
252 group_path = gr.full_path
253 # value needs to be aware of group name in order to check
253 # value needs to be aware of group name in order to check
254 # db key This is an actual just the name to store in the
254 # db key This is an actual just the name to store in the
255 # database
255 # database
256 repo_name_full = group_path + Group.url_sep() + repo_name
256 repo_name_full = group_path + RepoGroup.url_sep() + repo_name
257
257
258 else:
258 else:
259 group_path = ''
259 group_path = ''
@@ -272,7 +272,7 b' def ValidRepoName(edit, old_data):'
272 gr.group_name}
272 gr.group_name}
273 raise formencode.Invalid('', value, state,
273 raise formencode.Invalid('', value, state,
274 error_dict=e_dict)
274 error_dict=e_dict)
275 elif Group.get_by_group_name(repo_name_full):
275 elif RepoGroup.get_by_group_name(repo_name_full):
276 e_dict = {'repo_name':_('There is a group with this'
276 e_dict = {'repo_name':_('There is a group with this'
277 ' name already "%s"') %
277 ' name already "%s"') %
278 repo_name_full}
278 repo_name_full}
@@ -29,7 +29,7 b' import traceback'
29 from sqlalchemy.exc import DatabaseError
29 from sqlalchemy.exc import DatabaseError
30
30
31 from rhodecode.model import BaseModel
31 from rhodecode.model import BaseModel
32 from rhodecode.model.db import User, Permission, UserToPerm, RepoToPerm
32 from rhodecode.model.db import User, Permission, UserToPerm, UserRepoToPerm
33 from rhodecode.model.caching_query import FromCache
33 from rhodecode.model.caching_query import FromCache
34
34
35 log = logging.getLogger(__name__)
35 log = logging.getLogger(__name__)
@@ -95,8 +95,8 b' class PermissionModel(BaseModel):'
95
95
96 #stage 2 update all default permissions for repos if checked
96 #stage 2 update all default permissions for repos if checked
97 if form_result['overwrite_default'] == True:
97 if form_result['overwrite_default'] == True:
98 for r2p in self.sa.query(RepoToPerm)\
98 for r2p in self.sa.query(UserRepoToPerm)\
99 .filter(RepoToPerm.user == perm_user).all():
99 .filter(UserRepoToPerm.user == perm_user).all():
100 r2p.permission = self.get_permission_by_name(
100 r2p.permission = self.get_permission_by_name(
101 form_result['default_perm'])
101 form_result['default_perm'])
102 self.sa.add(r2p)
102 self.sa.add(r2p)
@@ -37,8 +37,8 b' from rhodecode.lib import safe_str'
37
37
38 from rhodecode.model import BaseModel
38 from rhodecode.model import BaseModel
39 from rhodecode.model.caching_query import FromCache
39 from rhodecode.model.caching_query import FromCache
40 from rhodecode.model.db import Repository, RepoToPerm, User, Permission, \
40 from rhodecode.model.db import Repository, UserRepoToPerm, User, Permission, \
41 Statistics, UsersGroup, UsersGroupRepoToPerm, RhodeCodeUi, Group
41 Statistics, UsersGroup, UsersGroupRepoToPerm, RhodeCodeUi, RepoGroup
42 from rhodecode.model.user import UserModel
42 from rhodecode.model.user import UserModel
43
43
44 log = logging.getLogger(__name__)
44 log = logging.getLogger(__name__)
@@ -141,9 +141,9 b' class RepoModel(BaseModel):'
141 # update permissions
141 # update permissions
142 for member, perm, member_type in form_data['perms_updates']:
142 for member, perm, member_type in form_data['perms_updates']:
143 if member_type == 'user':
143 if member_type == 'user':
144 r2p = self.sa.query(RepoToPerm)\
144 r2p = self.sa.query(UserRepoToPerm)\
145 .filter(RepoToPerm.user == User.get_by_username(member))\
145 .filter(UserRepoToPerm.user == User.get_by_username(member))\
146 .filter(RepoToPerm.repository == cur_repo)\
146 .filter(UserRepoToPerm.repository == cur_repo)\
147 .one()
147 .one()
148
148
149 r2p.permission = self.sa.query(Permission)\
149 r2p.permission = self.sa.query(Permission)\
@@ -165,7 +165,7 b' class RepoModel(BaseModel):'
165 # set new permissions
165 # set new permissions
166 for member, perm, member_type in form_data['perms_new']:
166 for member, perm, member_type in form_data['perms_new']:
167 if member_type == 'user':
167 if member_type == 'user':
168 r2p = RepoToPerm()
168 r2p = UserRepoToPerm()
169 r2p.repository = cur_repo
169 r2p.repository = cur_repo
170 r2p.user = User.get_by_username(member)
170 r2p.user = User.get_by_username(member)
171
171
@@ -191,7 +191,7 b' class RepoModel(BaseModel):'
191 elif k == 'repo_name':
191 elif k == 'repo_name':
192 pass
192 pass
193 elif k == 'repo_group':
193 elif k == 'repo_group':
194 cur_repo.group = Group.get(v)
194 cur_repo.group = RepoGroup.get(v)
195
195
196 else:
196 else:
197 setattr(cur_repo, k, v)
197 setattr(cur_repo, k, v)
@@ -249,7 +249,7 b' class RepoModel(BaseModel):'
249 self.sa.add(new_repo)
249 self.sa.add(new_repo)
250
250
251 #create default permission
251 #create default permission
252 repo_to_perm = RepoToPerm()
252 repo_to_perm = UserRepoToPerm()
253 default = 'repository.read'
253 default = 'repository.read'
254 for p in User.get_by_username('default').user_perms:
254 for p in User.get_by_username('default').user_perms:
255 if p.permission.permission_name.startswith('repository.'):
255 if p.permission.permission_name.startswith('repository.'):
@@ -300,10 +300,10 b' class RepoModel(BaseModel):'
300
300
301 def delete_perm_user(self, form_data, repo_name):
301 def delete_perm_user(self, form_data, repo_name):
302 try:
302 try:
303 self.sa.query(RepoToPerm)\
303 self.sa.query(UserRepoToPerm)\
304 .filter(RepoToPerm.repository \
304 .filter(UserRepoToPerm.repository \
305 == self.get_by_repo_name(repo_name))\
305 == self.get_by_repo_name(repo_name))\
306 .filter(RepoToPerm.user_id == form_data['user_id']).delete()
306 .filter(UserRepoToPerm.user_id == form_data['user_id']).delete()
307 self.sa.commit()
307 self.sa.commit()
308 except:
308 except:
309 log.error(traceback.format_exc())
309 log.error(traceback.format_exc())
@@ -348,7 +348,7 b' class RepoModel(BaseModel):'
348 from rhodecode.lib.utils import is_valid_repo, is_valid_repos_group
348 from rhodecode.lib.utils import is_valid_repo, is_valid_repos_group
349
349
350 if new_parent_id:
350 if new_parent_id:
351 paths = Group.get(new_parent_id).full_path.split(Group.url_sep())
351 paths = RepoGroup.get(new_parent_id).full_path.split(RepoGroup.url_sep())
352 new_parent_path = os.sep.join(paths)
352 new_parent_path = os.sep.join(paths)
353 else:
353 else:
354 new_parent_path = ''
354 new_parent_path = ''
@@ -24,16 +24,16 b''
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25
25
26 import logging
26 import logging
27 from rhodecode.model.db import BaseModel, RepoToPerm, Permission
27 from rhodecode.model.db import BaseModel, UserRepoToPerm, Permission
28 from rhodecode.model.meta import Session
28 from rhodecode.model.meta import Session
29
29
30 log = logging.getLogger(__name__)
30 log = logging.getLogger(__name__)
31
31
32 class RepositoryPermissionModel(BaseModel):
32 class RepositoryPermissionModel(BaseModel):
33 def get_user_permission(self, repository, user):
33 def get_user_permission(self, repository, user):
34 return RepoToPerm.query() \
34 return UserRepoToPerm.query() \
35 .filter(RepoToPerm.user == user) \
35 .filter(UserRepoToPerm.user == user) \
36 .filter(RepoToPerm.repository == repository) \
36 .filter(UserRepoToPerm.repository == repository) \
37 .scalar()
37 .scalar()
38
38
39 def update_user_permission(self, repository, user, permission):
39 def update_user_permission(self, repository, user, permission):
@@ -43,7 +43,7 b' class RepositoryPermissionModel(BaseMode'
43 if not current.permission is permission:
43 if not current.permission is permission:
44 current.permission = permission
44 current.permission = permission
45 else:
45 else:
46 p = RepoToPerm()
46 p = UserRepoToPerm()
47 p.user = user
47 p.user = user
48 p.repository = repository
48 p.repository = repository
49 p.permission = permission
49 p.permission = permission
@@ -33,8 +33,7 b' from pylons.i18n.translation import _'
33 from vcs.utils.lazy import LazyProperty
33 from vcs.utils.lazy import LazyProperty
34
34
35 from rhodecode.model import BaseModel
35 from rhodecode.model import BaseModel
36 from rhodecode.model.caching_query import FromCache
36 from rhodecode.model.db import RepoGroup, RhodeCodeUi
37 from rhodecode.model.db import Group, RhodeCodeUi
38
37
39 log = logging.getLogger(__name__)
38 log = logging.getLogger(__name__)
40
39
@@ -96,7 +95,7 b' class ReposGroupModel(BaseModel):'
96
95
97 :param group: instance of group from database
96 :param group: instance of group from database
98 """
97 """
99 paths = group.full_path.split(Group.url_sep())
98 paths = group.full_path.split(RepoGroup.url_sep())
100 paths = os.sep.join(paths)
99 paths = os.sep.join(paths)
101
100
102 rm_path = os.path.join(self.repos_path, paths)
101 rm_path = os.path.join(self.repos_path, paths)
@@ -106,9 +105,9 b' class ReposGroupModel(BaseModel):'
106
105
107 def create(self, form_data):
106 def create(self, form_data):
108 try:
107 try:
109 new_repos_group = Group()
108 new_repos_group = RepoGroup()
110 new_repos_group.group_description = form_data['group_description']
109 new_repos_group.group_description = form_data['group_description']
111 new_repos_group.parent_group = Group.get(form_data['group_parent_id'])
110 new_repos_group.parent_group = RepoGroup.get(form_data['group_parent_id'])
112 new_repos_group.group_name = new_repos_group.get_new_name(form_data['group_name'])
111 new_repos_group.group_name = new_repos_group.get_new_name(form_data['group_name'])
113
112
114 self.sa.add(new_repos_group)
113 self.sa.add(new_repos_group)
@@ -125,12 +124,12 b' class ReposGroupModel(BaseModel):'
125 def update(self, repos_group_id, form_data):
124 def update(self, repos_group_id, form_data):
126
125
127 try:
126 try:
128 repos_group = Group.get(repos_group_id)
127 repos_group = RepoGroup.get(repos_group_id)
129 old_path = repos_group.full_path
128 old_path = repos_group.full_path
130
129
131 # change properties
130 # change properties
132 repos_group.group_description = form_data['group_description']
131 repos_group.group_description = form_data['group_description']
133 repos_group.parent_group = Group.get(form_data['group_parent_id'])
132 repos_group.parent_group = RepoGroup.get(form_data['group_parent_id'])
134 repos_group.group_name = repos_group.get_new_name(form_data['group_name'])
133 repos_group.group_name = repos_group.get_new_name(form_data['group_name'])
135
134
136 new_path = repos_group.full_path
135 new_path = repos_group.full_path
@@ -154,7 +153,7 b' class ReposGroupModel(BaseModel):'
154
153
155 def delete(self, users_group_id):
154 def delete(self, users_group_id):
156 try:
155 try:
157 users_group = Group.get(users_group_id)
156 users_group = RepoGroup.get(users_group_id)
158 self.sa.delete(users_group)
157 self.sa.delete(users_group)
159 self.__delete_group(users_group)
158 self.__delete_group(users_group)
160 self.sa.commit()
159 self.sa.commit()
@@ -31,7 +31,7 b' from pylons.i18n.translation import _'
31 from rhodecode.lib import safe_unicode
31 from rhodecode.lib import safe_unicode
32 from rhodecode.model import BaseModel
32 from rhodecode.model import BaseModel
33 from rhodecode.model.caching_query import FromCache
33 from rhodecode.model.caching_query import FromCache
34 from rhodecode.model.db import User, RepoToPerm, Repository, Permission, \
34 from rhodecode.model.db import User, UserRepoToPerm, Repository, Permission, \
35 UserToPerm, UsersGroupRepoToPerm, UsersGroupToPerm, UsersGroupMember
35 UserToPerm, UsersGroupRepoToPerm, UsersGroupToPerm, UsersGroupMember
36 from rhodecode.lib.exceptions import DefaultUserException, \
36 from rhodecode.lib.exceptions import DefaultUserException, \
37 UserOwnsReposException
37 UserOwnsReposException
@@ -303,12 +303,12 b' class UserModel(BaseModel):'
303 #======================================================================
303 #======================================================================
304 default_user = self.get_by_username('default', cache=True)
304 default_user = self.get_by_username('default', cache=True)
305
305
306 default_perms = self.sa.query(RepoToPerm, Repository, Permission)\
306 default_perms = self.sa.query(UserRepoToPerm, Repository, Permission)\
307 .join((Repository, RepoToPerm.repository_id ==
307 .join((Repository, UserRepoToPerm.repository_id ==
308 Repository.repo_id))\
308 Repository.repo_id))\
309 .join((Permission, RepoToPerm.permission_id ==
309 .join((Permission, UserRepoToPerm.permission_id ==
310 Permission.permission_id))\
310 Permission.permission_id))\
311 .filter(RepoToPerm.user == default_user).all()
311 .filter(UserRepoToPerm.user == default_user).all()
312
312
313 if user.is_admin:
313 if user.is_admin:
314 #==================================================================
314 #==================================================================
@@ -318,7 +318,7 b' class UserModel(BaseModel):'
318
318
319 for perm in default_perms:
319 for perm in default_perms:
320 p = 'repository.admin'
320 p = 'repository.admin'
321 user.permissions['repositories'][perm.RepoToPerm.
321 user.permissions['repositories'][perm.UserRepoToPerm.
322 repository.repo_name] = p
322 repository.repo_name] = p
323
323
324 else:
324 else:
@@ -346,7 +346,7 b' class UserModel(BaseModel):'
346 else:
346 else:
347 p = perm.Permission.permission_name
347 p = perm.Permission.permission_name
348
348
349 user.permissions['repositories'][perm.RepoToPerm.
349 user.permissions['repositories'][perm.UserRepoToPerm.
350 repository.repo_name] = p
350 repository.repo_name] = p
351
351
352 #==================================================================
352 #==================================================================
@@ -363,13 +363,13 b' class UserModel(BaseModel):'
363 permission_name)
363 permission_name)
364
364
365 #user repositories
365 #user repositories
366 user_repo_perms = self.sa.query(RepoToPerm, Permission,
366 user_repo_perms = self.sa.query(UserRepoToPerm, Permission,
367 Repository)\
367 Repository)\
368 .join((Repository, RepoToPerm.repository_id ==
368 .join((Repository, UserRepoToPerm.repository_id ==
369 Repository.repo_id))\
369 Repository.repo_id))\
370 .join((Permission, RepoToPerm.permission_id ==
370 .join((Permission, UserRepoToPerm.permission_id ==
371 Permission.permission_id))\
371 Permission.permission_id))\
372 .filter(RepoToPerm.user_id == uid).all()
372 .filter(UserRepoToPerm.user_id == uid).all()
373
373
374 for perm in user_repo_perms:
374 for perm in user_repo_perms:
375 # set admin if owner
375 # set admin if owner
@@ -377,7 +377,7 b' class UserModel(BaseModel):'
377 p = 'repository.admin'
377 p = 'repository.admin'
378 else:
378 else:
379 p = perm.Permission.permission_name
379 p = perm.Permission.permission_name
380 user.permissions['repositories'][perm.RepoToPerm.
380 user.permissions['repositories'][perm.UserRepoToPerm.
381 repository.repo_name] = p
381 repository.repo_name] = p
382
382
383 #==================================================================
383 #==================================================================
@@ -32,7 +32,7 b''
32 <tr>
32 <tr>
33 <th class="left"><a href="#">${_('Group name')}</a></th>
33 <th class="left"><a href="#">${_('Group name')}</a></th>
34 <th class="left"><a href="#">${_('Description')}</a></th>
34 <th class="left"><a href="#">${_('Description')}</a></th>
35 <th class="left"><a href="#">${_('Number of repositories')}</a></th>
35 <th class="left"><a href="#">${_('Number of toplevel repositories')}</a></th>
36 <th class="left">${_('action')}</th>
36 <th class="left">${_('action')}</th>
37 </tr>
37 </tr>
38 </thead>
38 </thead>
@@ -1,5 +1,5 b''
1 from rhodecode.tests import *
1 from rhodecode.tests import *
2 from rhodecode.model.db import RhodeCodeSettings
2 from rhodecode.model.db import RhodeCodeSetting
3 from nose.plugins.skip import SkipTest
3 from nose.plugins.skip import SkipTest
4
4
5 skip_ldap_test = False
5 skip_ldap_test = False
@@ -41,7 +41,7 b' class TestLdapSettingsController(TestCon'
41 'ldap_attr_lastname':'tester',
41 'ldap_attr_lastname':'tester',
42 'ldap_attr_email':'test@example.com' })
42 'ldap_attr_email':'test@example.com' })
43
43
44 new_settings = RhodeCodeSettings.get_ldap_settings()
44 new_settings = RhodeCodeSetting.get_ldap_settings()
45 self.assertEqual(new_settings['ldap_host'], u'dc.example.com',
45 self.assertEqual(new_settings['ldap_host'], u'dc.example.com',
46 'fail db write compare')
46 'fail db write compare')
47
47
@@ -1,7 +1,7 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 from rhodecode.lib.auth import get_crypt_password, check_password
3 from rhodecode.lib.auth import get_crypt_password, check_password
4 from rhodecode.model.db import User, RhodeCodeSettings
4 from rhodecode.model.db import User, RhodeCodeSetting
5 from rhodecode.tests import *
5 from rhodecode.tests import *
6
6
7 class TestAdminSettingsController(TestController):
7 class TestAdminSettingsController(TestController):
@@ -63,7 +63,7 b' class TestAdminSettingsController(TestCo'
63
63
64 self.checkSessionFlash(response, 'Updated application settings')
64 self.checkSessionFlash(response, 'Updated application settings')
65
65
66 self.assertEqual(RhodeCodeSettings
66 self.assertEqual(RhodeCodeSetting
67 .get_app_settings()['rhodecode_ga_code'], new_ga_code)
67 .get_app_settings()['rhodecode_ga_code'], new_ga_code)
68
68
69 response = response.follow()
69 response = response.follow()
@@ -85,7 +85,7 b' class TestAdminSettingsController(TestCo'
85
85
86 self.assertTrue('Updated application settings' in
86 self.assertTrue('Updated application settings' in
87 response.session['flash'][0][1])
87 response.session['flash'][0][1])
88 self.assertEqual(RhodeCodeSettings
88 self.assertEqual(RhodeCodeSetting
89 .get_app_settings()['rhodecode_ga_code'], new_ga_code)
89 .get_app_settings()['rhodecode_ga_code'], new_ga_code)
90
90
91 response = response.follow()
91 response = response.follow()
@@ -109,7 +109,7 b' class TestAdminSettingsController(TestCo'
109 ))
109 ))
110
110
111 self.checkSessionFlash(response, 'Updated application settings')
111 self.checkSessionFlash(response, 'Updated application settings')
112 self.assertEqual(RhodeCodeSettings
112 self.assertEqual(RhodeCodeSetting
113 .get_app_settings()['rhodecode_title'],
113 .get_app_settings()['rhodecode_title'],
114 new_title.decode('utf-8'))
114 new_title.decode('utf-8'))
115
115
@@ -4,7 +4,7 b' from rhodecode.tests import *'
4
4
5 from rhodecode.model.repos_group import ReposGroupModel
5 from rhodecode.model.repos_group import ReposGroupModel
6 from rhodecode.model.repo import RepoModel
6 from rhodecode.model.repo import RepoModel
7 from rhodecode.model.db import Group, User
7 from rhodecode.model.db import RepoGroup, User
8 from sqlalchemy.exc import IntegrityError
8 from sqlalchemy.exc import IntegrityError
9
9
10 class TestReposGroups(unittest.TestCase):
10 class TestReposGroups(unittest.TestCase):
@@ -28,7 +28,7 b' class TestReposGroups(unittest.TestCase)'
28 def __make_group(self, path, desc='desc', parent_id=None,
28 def __make_group(self, path, desc='desc', parent_id=None,
29 skip_if_exists=False):
29 skip_if_exists=False):
30
30
31 gr = Group.get_by_group_name(path)
31 gr = RepoGroup.get_by_group_name(path)
32 if gr and skip_if_exists:
32 if gr and skip_if_exists:
33 return gr
33 return gr
34
34
@@ -77,13 +77,13 b' class TestReposGroups(unittest.TestCase)'
77 sg1 = self.__make_group('deleteme')
77 sg1 = self.__make_group('deleteme')
78 self.__delete_group(sg1.group_id)
78 self.__delete_group(sg1.group_id)
79
79
80 self.assertEqual(Group.get(sg1.group_id), None)
80 self.assertEqual(RepoGroup.get(sg1.group_id), None)
81 self.assertFalse(self.__check_path('deteteme'))
81 self.assertFalse(self.__check_path('deteteme'))
82
82
83 sg1 = self.__make_group('deleteme', parent_id=self.g1.group_id)
83 sg1 = self.__make_group('deleteme', parent_id=self.g1.group_id)
84 self.__delete_group(sg1.group_id)
84 self.__delete_group(sg1.group_id)
85
85
86 self.assertEqual(Group.get(sg1.group_id), None)
86 self.assertEqual(RepoGroup.get(sg1.group_id), None)
87 self.assertFalse(self.__check_path('test1', 'deteteme'))
87 self.assertFalse(self.__check_path('test1', 'deteteme'))
88
88
89
89
@@ -92,7 +92,7 b' class TestReposGroups(unittest.TestCase)'
92
92
93 new_sg1 = self.__update_group(sg1.group_id, 'after')
93 new_sg1 = self.__update_group(sg1.group_id, 'after')
94 self.assertTrue(self.__check_path('after'))
94 self.assertTrue(self.__check_path('after'))
95 self.assertEqual(Group.get_by_group_name('initial'), None)
95 self.assertEqual(RepoGroup.get_by_group_name('initial'), None)
96
96
97
97
98 def test_update_group_parent(self):
98 def test_update_group_parent(self):
@@ -101,18 +101,18 b' class TestReposGroups(unittest.TestCase)'
101
101
102 new_sg1 = self.__update_group(sg1.group_id, 'after', parent_id=self.g1.group_id)
102 new_sg1 = self.__update_group(sg1.group_id, 'after', parent_id=self.g1.group_id)
103 self.assertTrue(self.__check_path('test1', 'after'))
103 self.assertTrue(self.__check_path('test1', 'after'))
104 self.assertEqual(Group.get_by_group_name('test1/initial'), None)
104 self.assertEqual(RepoGroup.get_by_group_name('test1/initial'), None)
105
105
106
106
107 new_sg1 = self.__update_group(sg1.group_id, 'after', parent_id=self.g3.group_id)
107 new_sg1 = self.__update_group(sg1.group_id, 'after', parent_id=self.g3.group_id)
108 self.assertTrue(self.__check_path('test3', 'after'))
108 self.assertTrue(self.__check_path('test3', 'after'))
109 self.assertEqual(Group.get_by_group_name('test3/initial'), None)
109 self.assertEqual(RepoGroup.get_by_group_name('test3/initial'), None)
110
110
111
111
112 new_sg1 = self.__update_group(sg1.group_id, 'hello')
112 new_sg1 = self.__update_group(sg1.group_id, 'hello')
113 self.assertTrue(self.__check_path('hello'))
113 self.assertTrue(self.__check_path('hello'))
114
114
115 self.assertEqual(Group.get_by_group_name('hello'), new_sg1)
115 self.assertEqual(RepoGroup.get_by_group_name('hello'), new_sg1)
116
116
117
117
118
118
General Comments 0
You need to be logged in to leave comments. Login now