本文整理汇总了Python中rhodecode.model.db.RepoGroup.query方法的典型用法代码示例。如果您正苦于以下问题:Python RepoGroup.query方法的具体用法?Python RepoGroup.query怎么用?Python RepoGroup.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rhodecode.model.db.RepoGroup
的用法示例。
在下文中一共展示了RepoGroup.query方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_repos_groups
# 需要导入模块: from rhodecode.model.db import RepoGroup [as 别名]
# 或者: from rhodecode.model.db.RepoGroup import query [as 别名]
def get_repos_groups(self, all_groups=None):
if all_groups is None:
all_groups = RepoGroup.query()\
.filter(RepoGroup.group_parent_id == None).all()
group_iter = GroupList(all_groups)
return group_iter
示例2: create_repository
# 需要导入模块: from rhodecode.model.db import RepoGroup [as 别名]
# 或者: from rhodecode.model.db.RepoGroup import query [as 别名]
def create_repository(self):
"""GET /_admin/create_repository: Form to create a new item"""
new_repo = request.GET.get('repo', '')
parent_group = request.GET.get('parent_group')
if not HasPermissionAny('hg.admin', 'hg.create.repository')():
#you're not super admin nor have global create permissions,
#but maybe you have at least write permission to a parent group ?
_gr = RepoGroup.get(parent_group)
gr_name = _gr.group_name if _gr else None
if not HasReposGroupPermissionAny('group.admin', 'group.write')(group_name=gr_name):
raise HTTPForbidden
acl_groups = GroupList(RepoGroup.query().all(),
perm_set=['group.write', 'group.admin'])
c.repo_groups = RepoGroup.groups_choices(groups=acl_groups)
c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
choices, c.landing_revs = ScmModel().get_repo_landing_revs()
c.new_repo = repo_name_slug(new_repo)
## apply the defaults from defaults page
defaults = RhodeCodeSetting.get_default_repo_settings(strip_prefix=True)
if parent_group:
defaults.update({'repo_group': parent_group})
return htmlfill.render(
render('admin/repos/repo_add.html'),
defaults=defaults,
errors={},
prefix_error=False,
encoding="UTF-8"
)
示例3: show
# 需要导入模块: from rhodecode.model.db import RepoGroup [as 别名]
# 或者: from rhodecode.model.db.RepoGroup import query [as 别名]
def show(self, group_name, format='html'):
"""GET /repos_groups/group_name: Show a specific item"""
# url('repos_group', group_name=GROUP_NAME)
c.group = c.repos_group = ReposGroupModel()._get_repo_group(group_name)
c.group_repos = c.group.repositories.all()
#overwrite our cached list with current filter
gr_filter = c.group_repos
c.repo_cnt = 0
groups = RepoGroup.query().order_by(RepoGroup.group_name)\
.filter(RepoGroup.group_parent_id == c.group.group_id).all()
c.groups = self.scm_model.get_repos_groups(groups)
c.repos_list = Repository.query()\
.filter(Repository.group_id == c.group.group_id)\
.order_by(func.lower(Repository.repo_name))\
.all()
repos_data = RepoModel().get_repos_as_dict(repos_list=c.repos_list,
admin=False)
#json used to render the grid
c.data = json.dumps(repos_data)
return render('admin/repos_groups/repos_groups.html')
示例4: index
# 需要导入模块: from rhodecode.model.db import RepoGroup [as 别名]
# 或者: from rhodecode.model.db.RepoGroup import query [as 别名]
def index(self, format='html'):
"""GET /repos_groups: All items in the collection"""
# url('repos_groups')
group_iter = GroupList(RepoGroup.query().all(), perm_set=['group.admin'])
sk = lambda g: g.parents[0].group_name if g.parents else g.group_name
c.groups = sorted(group_iter, key=sk)
return render('admin/repos_groups/repos_groups_show.html')
示例5: __load_defaults
# 需要导入模块: from rhodecode.model.db import RepoGroup [as 别名]
# 或者: from rhodecode.model.db.RepoGroup import query [as 别名]
def __load_defaults(self):
acl_groups = RepoGroupList(RepoGroup.query().all(),
perm_set=['group.write', 'group.admin'])
c.repo_groups = RepoGroup.groups_choices(groups=acl_groups)
c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
choices, c.landing_revs = ScmModel().get_repo_landing_revs()
c.landing_revs_choices = choices
c.can_update = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_UPDATE).ui_active
示例6: __load_defaults
# 需要导入模块: from rhodecode.model.db import RepoGroup [as 别名]
# 或者: from rhodecode.model.db.RepoGroup import query [as 别名]
def __load_defaults(self):
acl_groups = GroupList(RepoGroup.query().all(),
perm_set=['group.write', 'group.admin'])
c.repo_groups = RepoGroup.groups_choices(groups=acl_groups)
c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
repo_model = RepoModel()
c.users_array = repo_model.get_users_js()
c.users_groups_array = repo_model.get_users_groups_js()
choices, c.landing_revs = ScmModel().get_repo_landing_revs()
c.landing_revs_choices = choices
示例7: fixup_groups
# 需要导入模块: from rhodecode.model.db import RepoGroup [as 别名]
# 或者: from rhodecode.model.db.RepoGroup import query [as 别名]
def fixup_groups(self):
def_usr = User.get_by_username('default')
for g in RepoGroup.query().all():
g.group_name = g.get_new_name(g.name)
self.sa.add(g)
# get default perm
default = UserRepoGroupToPerm.query()\
.filter(UserRepoGroupToPerm.group == g)\
.filter(UserRepoGroupToPerm.user == def_usr)\
.scalar()
if default is None:
log.debug('missing default permission for group %s adding' % g)
ReposGroupModel()._create_default_perms(g)
示例8: validate_python
# 需要导入模块: from rhodecode.model.db import RepoGroup [as 别名]
# 或者: from rhodecode.model.db.RepoGroup import query [as 别名]
def validate_python(self, value, state):
# TODO WRITE VALIDATIONS
group_name = value.get('group_name')
group_parent_id = value.get('group_parent_id')
# slugify repo group just in case :)
slug = repo_name_slug(group_name)
# check for parent of self
parent_of_self = lambda: (
old_data['group_id'] == int(group_parent_id)
if group_parent_id else False
)
if edit and parent_of_self():
e_dict = {
'group_parent_id': _('Cannot assign this group as parent')
}
raise formencode.Invalid('', value, state,
error_dict=e_dict)
old_gname = None
if edit:
old_gname = RepoGroup.get(old_data.get('group_id')).group_name
if old_gname != group_name or not edit:
# check group
gr = RepoGroup.query()\
.filter(RepoGroup.group_name == slug)\
.filter(RepoGroup.group_parent_id == group_parent_id)\
.scalar()
if gr:
e_dict = {
'group_name': _('This group already exists')
}
raise formencode.Invalid('', value, state,
error_dict=e_dict)
# check for same repo
repo = Repository.query()\
.filter(Repository.repo_name == slug)\
.scalar()
if repo:
e_dict = {
'group_name': _('Repository with this name already exists')
}
raise formencode.Invalid('', value, state,
error_dict=e_dict)
示例9: validate_python
# 需要导入模块: from rhodecode.model.db import RepoGroup [as 别名]
# 或者: from rhodecode.model.db.RepoGroup import query [as 别名]
def validate_python(self, value, state):
# TODO WRITE VALIDATIONS
group_name = value.get('group_name')
group_parent_id = value.get('group_parent_id')
# slugify repo group just in case :)
slug = repo_name_slug(group_name)
# check for parent of self
parent_of_self = lambda: (
old_data['group_id'] == int(group_parent_id)
if group_parent_id else False
)
if edit and parent_of_self():
msg = M(self, 'group_parent_id', state)
raise formencode.Invalid(msg, value, state,
error_dict=dict(group_parent_id=msg)
)
old_gname = None
if edit:
old_gname = RepoGroup.get(old_data.get('group_id')).group_name
if old_gname != group_name or not edit:
# check group
gr = RepoGroup.query()\
.filter(RepoGroup.group_name == slug)\
.filter(RepoGroup.group_parent_id == group_parent_id)\
.scalar()
if gr:
msg = M(self, 'group_exists', state, group_name=slug)
raise formencode.Invalid(msg, value, state,
error_dict=dict(group_name=msg)
)
# check for same repo
repo = Repository.query()\
.filter(Repository.repo_name == slug)\
.scalar()
if repo:
msg = M(self, 'repo_exists', state, group_name=slug)
raise formencode.Invalid(msg, value, state,
error_dict=dict(group_name=msg)
)
示例10: __load_defaults
# 需要导入模块: from rhodecode.model.db import RepoGroup [as 别名]
# 或者: from rhodecode.model.db.RepoGroup import query [as 别名]
def __load_defaults(self, allow_empty_group=False, exclude_group_ids=[]):
if HasPermissionAll('hg.admin')('group edit'):
#we're global admin, we're ok and we can create TOP level groups
allow_empty_group = True
#override the choices for this form, we need to filter choices
#and display only those we have ADMIN right
groups_with_admin_rights = RepoGroupList(RepoGroup.query().all(),
perm_set=['group.admin'])
c.repo_groups = RepoGroup.groups_choices(groups=groups_with_admin_rights,
show_empty_group=allow_empty_group)
# exclude filtered ids
c.repo_groups = filter(lambda x: x[0] not in exclude_group_ids,
c.repo_groups)
c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
repo_model = RepoModel()
c.users_array = repo_model.get_users_js()
c.users_groups_array = repo_model.get_users_groups_js()
示例11: show
# 需要导入模块: from rhodecode.model.db import RepoGroup [as 别名]
# 或者: from rhodecode.model.db.RepoGroup import query [as 别名]
def show(self, id, format='html'):
"""GET /repos_groups/id: Show a specific item"""
# url('repos_group', id=ID)
c.group = RepoGroup.get_or_404(id)
c.group_repos = c.group.repositories.all()
#overwrite our cached list with current filter
gr_filter = c.group_repos
c.cached_repo_list = self.scm_model.get_repos(all_repos=gr_filter)
c.repos_list = c.cached_repo_list
c.repo_cnt = 0
groups = RepoGroup.query().order_by(RepoGroup.group_name)\
.filter(RepoGroup.group_parent_id == id).all()
c.groups = self.scm_model.get_repos_groups(groups)
return render('admin/repos_groups/repos_groups.html')
示例12: show
# 需要导入模块: from rhodecode.model.db import RepoGroup [as 别名]
# 或者: from rhodecode.model.db.RepoGroup import query [as 别名]
def show(self, id, format='html'):
"""GET /repos_groups/id: Show a specific item"""
# url('repos_group', id=ID)
c.group = RepoGroup.get_or_404(id)
c.group_repos = c.group.repositories.all()
#overwrite our cached list with current filter
gr_filter = c.group_repos
c.repo_cnt = 0
groups = RepoGroup.query().order_by(RepoGroup.group_name)\
.filter(RepoGroup.group_parent_id == id).all()
c.groups = self.scm_model.get_repos_groups(groups)
if c.visual.lightweight_dashboard is False:
c.cached_repo_list = self.scm_model.get_repos(all_repos=gr_filter)
c.repos_list = c.cached_repo_list
## lightweight version of dashboard
else:
c.repos_list = Repository.query()\
.filter(Repository.group_id == id)\
.order_by(func.lower(Repository.repo_name))\
.all()
repos_data = []
total_records = len(c.repos_list)
_tmpl_lookup = rhodecode.CONFIG['pylons.app_globals'].mako_lookup
template = _tmpl_lookup.get_template('data_table/_dt_elements.html')
quick_menu = lambda repo_name: (template.get_def("quick_menu")
.render(repo_name, _=_, h=h, c=c))
repo_lnk = lambda name, rtype, private, fork_of: (
template.get_def("repo_name")
.render(name, rtype, private, fork_of, short_name=False,
admin=False, _=_, h=h, c=c))
last_change = lambda last_change: (template.get_def("last_change")
.render(last_change, _=_, h=h, c=c))
rss_lnk = lambda repo_name: (template.get_def("rss")
.render(repo_name, _=_, h=h, c=c))
atom_lnk = lambda repo_name: (template.get_def("atom")
.render(repo_name, _=_, h=h, c=c))
for repo in c.repos_list:
repos_data.append({
"menu": quick_menu(repo.repo_name),
"raw_name": repo.repo_name.lower(),
"name": repo_lnk(repo.repo_name, repo.repo_type,
repo.private, repo.fork),
"last_change": last_change(repo.last_db_change),
"desc": repo.description,
"owner": h.person(repo.user.username),
"rss": rss_lnk(repo.repo_name),
"atom": atom_lnk(repo.repo_name),
})
c.data = json.dumps({
"totalRecords": total_records,
"startIndex": 0,
"sort": "name",
"dir": "asc",
"records": repos_data
})
return render('admin/repos_groups/repos_groups.html')