本文整理匯總了Python中coprs.logic.users_logic.UsersLogic.get_group_by_fas_name_or_create方法的典型用法代碼示例。如果您正苦於以下問題:Python UsersLogic.get_group_by_fas_name_or_create方法的具體用法?Python UsersLogic.get_group_by_fas_name_or_create怎麽用?Python UsersLogic.get_group_by_fas_name_or_create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類coprs.logic.users_logic.UsersLogic
的用法示例。
在下文中一共展示了UsersLogic.get_group_by_fas_name_or_create方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: activate_group
# 需要導入模塊: from coprs.logic.users_logic import UsersLogic [as 別名]
# 或者: from coprs.logic.users_logic.UsersLogic import get_group_by_fas_name_or_create [as 別名]
def activate_group(fas_group):
form = ActivateFasGroupForm()
if form.validate_on_submit():
if UsersLogic.is_blacklisted_group(fas_group):
flask.flash("This group is blacklisted and cannot be added.")
return flask.redirect(url_for(
"groups_ns.list_user_groups"))
if fas_group not in flask.g.user.user_teams:
raise InsufficientRightsException(
"User '{}' doesn't have access to fas group {}"
.format(flask.g.user.username, fas_group))
alias = form.name.data
group = UsersLogic.get_group_by_fas_name_or_create(
fas_group, alias)
db.session.add(group)
db.session.commit()
flask.flash(
"FAS group {} is activated in the Copr under the alias {} "
.format(fas_group, alias)
)
return flask.redirect(url_for(
"groups_ns.list_projects_by_group", group_name=alias))
else:
return flask.render_template(
"groups/activate_fas_group.html",
fas_group=fas_group,
form=form,
user=flask.g.user,
)