当前位置: 首页>>代码示例>>Python>>正文


Python users_logic.UsersLogic类代码示例

本文整理汇总了Python中coprs.logic.users_logic.UsersLogic的典型用法代码示例。如果您正苦于以下问题:Python UsersLogic类的具体用法?Python UsersLogic怎么用?Python UsersLogic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UsersLogic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: activate_group

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,
        )
开发者ID:evilkost,项目名称:copr,代码行数:35,代码来源:groups_general.py

示例2: copr_edit_package_post

def copr_edit_package_post(copr, package_name):
    UsersLogic.raise_if_cant_build_in_copr(
        flask.g.user, copr, "You don't have permissions to edit this package.")

    url_on_success = helpers.copr_url("coprs_ns.copr_packages", copr)
    return process_save_package(copr, package_name, view="coprs_ns.copr_edit_package",
                                view_method=copr_edit_package, url_on_success=url_on_success)
开发者ID:0-T-0,项目名称:copr,代码行数:7,代码来源:coprs_packages.py

示例3: remove_copr_chroot

    def remove_copr_chroot(cls, user, copr_chroot):
        """
        :param models.CoprChroot chroot:
        """
        UsersLogic.raise_if_cant_update_copr(
            user, copr_chroot.copr,
            "Only owners and admins may update their projects.")

        db.session.delete(copr_chroot)
开发者ID:jhdulaney,项目名称:copr,代码行数:9,代码来源:coprs_logic.py

示例4: remove_comps

    def remove_comps(cls, user, copr_chroot):
        UsersLogic.raise_if_cant_update_copr(
            user, copr_chroot.copr,
            "Only owners and admins may update their projects.")

        copr_chroot.comps_name = None
        copr_chroot.comps_zlib = None
        ActionsLogic.send_update_comps(copr_chroot)
        db.session.add(copr_chroot)
开发者ID:jhdulaney,项目名称:copr,代码行数:9,代码来源:coprs_logic.py

示例5: test_group_add_alias_with_space

 def test_group_add_alias_with_space(self, f_users, f_fas_groups, f_db):
     fas_name = f_fas_groups[0]
     alias = "alias_1 foo bar"
     assert not UsersLogic.group_alias_exists(alias)
     r = self.test_client.post(
         "/groups/activate/{}".format(fas_name),
         data={"name": alias},
         follow_redirects=True
     )
     assert not UsersLogic.group_alias_exists(alias)
开发者ID:0-T-0,项目名称:copr,代码行数:10,代码来源:test_groups_general.py

示例6: test_group_add_not_in_fas_group

 def test_group_add_not_in_fas_group(self, f_users, f_fas_groups, f_db):
     fas_name = f_fas_groups[3]
     alias = "alias_1"
     assert not UsersLogic.group_alias_exists(alias)
     r = self.test_client.post(
         "/groups/activate/{}".format(fas_name),
         data={"name": alias},
         follow_redirects=True
     )
     # assert r.status_code == 403
     assert not UsersLogic.group_alias_exists(alias)
开发者ID:0-T-0,项目名称:copr,代码行数:11,代码来源:test_groups_general.py

示例7: coprs_migration_report

def coprs_migration_report(username=None):
    if not username and not flask.g.user:
        return generic_error("You are not logged in")
    elif not username:
        username = flask.g.user.name
    user = UsersLogic.get(username).first()

    coprs = CoprsLogic.filter_without_group_projects(CoprsLogic.get_multiple_owned_by_username(username)).all()
    for group in UsersLogic.get_groups_by_fas_names_list(user.user_teams).all():
        coprs.extend(CoprsLogic.get_multiple_by_group_id(group.id).all())

    return render_migration_report(coprs, user=user)
开发者ID:danvratil,项目名称:copr,代码行数:12,代码来源:misc.py

示例8: update_chroot

    def update_chroot(cls, user, copr_chroot,
                      buildroot_pkgs, comps=None, comps_name=None):
        """
        :type user: models.User
        :type copr_chroot: models.CoprChroot
        """
        UsersLogic.raise_if_cant_update_copr(
            user, copr_chroot.copr,
            "Only owners and admins may update their projects.")

        cls._update_chroot(buildroot_pkgs, comps, comps_name, copr_chroot)
        db.session.add(copr_chroot)

        return copr_chroot
开发者ID:jhdulaney,项目名称:copr,代码行数:14,代码来源:coprs_logic.py

示例9: create_chroot

    def create_chroot(cls, user, copr, mock_chroot,
                      buildroot_pkgs=None, comps=None, comps_name=None):
        """
        :type user: models.User
        :type mock_chroot: models.MockChroot
        """
        if buildroot_pkgs is None:
            buildroot_pkgs = ""
        UsersLogic.raise_if_cant_update_copr(
            user, copr,
            "Only owners and admins may update their projects.")

        chroot = models.CoprChroot(copr=copr, mock_chroot=mock_chroot)
        cls._update_chroot(buildroot_pkgs, comps, comps_name, chroot)
        return chroot
开发者ID:jhdulaney,项目名称:copr,代码行数:15,代码来源:coprs_logic.py

示例10: get_active_groups_by_user

 def get_active_groups_by_user(user_name):
     names = flask.g.user.user_groups
     if names:
         query = UsersLogic.get_groups_by_names_list(names)
         return query.filter(User.name == user_name)
     else:
         return []
开发者ID:tkdchen,项目名称:copr,代码行数:7,代码来源:complex_logic.py

示例11: get_group_by_name_safe

 def get_group_by_name_safe(group_name):
     try:
         group = UsersLogic.get_group_by_alias(group_name).one()
     except sqlalchemy.orm.exc.NoResultFound:
         raise ObjectNotFound(
             message="Group {} does not exist.".format(group_name))
     return group
开发者ID:tkdchen,项目名称:copr,代码行数:7,代码来源:complex_logic.py

示例12: decorated_function

    def decorated_function(*args, **kwargs):
        token = None
        apt_login = None
        if "Authorization" in flask.request.headers:
            base64string = flask.request.headers["Authorization"]
            base64string = base64string.split()[1].strip()
            userstring = base64.b64decode(base64string)
            (apt_login, token) = userstring.decode("utf-8").split(":")
        token_auth = False
        if token and apt_login:
            user = UsersLogic.get_by_api_login(apt_login).first()
            if (user and user.api_token == token and
                    user.api_token_expiration >= datetime.date.today()):

                token_auth = True
                flask.g.user = user
        if not token_auth:
            output = {
                "output": "notok",
                "error": "Login invalid/expired. "
                         "Please visit https://copr.fedoraproject.org/api "
                         "get or renew your API token.",
            }
            jsonout = flask.jsonify(output)
            jsonout.status_code = 500
            return jsonout
        return f(*args, **kwargs)
开发者ID:danvratil,项目名称:copr,代码行数:27,代码来源:misc.py

示例13: list_user_groups

def list_user_groups():
    teams = flask.g.user.user_teams
    active_map = {
        group.fas_name: group.name for group in
        UsersLogic.get_groups_by_fas_names_list(teams).all()
    }

    teams = UsersLogic.filter_blacklisted_teams(teams)
    copr_groups = {
        fas_name: active_map.get(fas_name)
        for fas_name in teams
    }
    return render_template(
        "groups/user_fas_groups.html",
        user=flask.g.user,
        teams=teams,
        copr_groups=copr_groups)
开发者ID:evilkost,项目名称:copr,代码行数:17,代码来源:groups_general.py

示例14: test_group_add_twice

 def test_group_add_twice(self, f_users, f_fas_groups, f_db):
     fas_name = f_fas_groups[0]
     alias = "alias_1"
     assert not UsersLogic.group_alias_exists(alias)
     self.test_client.post(
         "/groups/activate/{}".format(fas_name),
         data={"name": alias},
         follow_redirects=True
     )
     assert UsersLogic.group_alias_exists(alias)
     assert len(models.Group.query.all()) == 1
     self.test_client.post(
         "/groups/activate/{}".format(fas_name),
         data={"name": alias},
         follow_redirects=True
     )
     assert len(models.Group.query.all()) == 1
开发者ID:0-T-0,项目名称:copr,代码行数:17,代码来源:test_groups_general.py

示例15: add

    def add(cls, user, name, selected_chroots, repos=None, description=None,
            instructions=None, check_for_duplicates=False, group=None, **kwargs):
        copr = models.Copr(name=name,
                           repos=repos or u"",
                           owner_id=user.id,
                           description=description or u"",
                           instructions=instructions or u"",
                           created_on=int(time.time()),
                           **kwargs)

        if group is not None:
            UsersLogic.raise_if_not_in_group(user, group)
            copr.group = group

        # form validation checks for duplicates
        CoprsLogic.new(user, copr,
                       check_for_duplicates=check_for_duplicates)
        CoprChrootsLogic.new_from_names(copr, selected_chroots)
        return copr
开发者ID:seocam,项目名称:copr,代码行数:19,代码来源:coprs_logic.py


注:本文中的coprs.logic.users_logic.UsersLogic类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。