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


Python Group.add_channel_admin方法代码示例

本文整理汇总了Python中models.Group.add_channel_admin方法的典型用法代码示例。如果您正苦于以下问题:Python Group.add_channel_admin方法的具体用法?Python Group.add_channel_admin怎么用?Python Group.add_channel_admin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Group的用法示例。


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

示例1: dummy_groups

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import add_channel_admin [as 别名]
def dummy_groups():
    deepak = User.objects.get(pk=3)
    susan = User.objects.get(pk=24)
    james = User.objects.get(pk=25)
    donna = User.objects.get(pk=29)

    g = Group(id=1, name="friends", membership=3, creator_id=3)
    g.save()

    g1 = Group(creator=deepak, name="modi bhakts", membership=1)
    g1.save()
    g1.add_member(deepak)
    g1.add_member(susan)
    g1.add_member(james)
    g1.add_member(donna)

    g2 = Group(creator=deepak, name="times now", membership=2)
    g2.save()
    # g2.add_member(deepak)
    g2.add_member(susan)
    g2.add_channel_admin(deepak, deepak)
    g2.add_channel_admin(donna, deepak)

    g3 = Group(creator=deepak, name="core team", membership=3)
    g3.save()
    g3.add_member(deepak, deepak)
    g3.add_member(susan, deepak)
    g3.approve_member(susan)
    g3.add_member(donna, deepak)
开发者ID:krdeepak,项目名称:djmysite,代码行数:31,代码来源:util.py

示例2: api_group_create

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import add_channel_admin [as 别名]
def api_group_create(request):
    api_result = {"api": "group_create", "status": "success"}

    try:
        token = request.POST["token"]
        user = get_user_from_token(token)
        name = request.POST["name"]
        group_type = int(request.POST["group_type"])

        if group_type == 1 or group_type == 2:
            try:
                existing_group = Group.objects.filter(name=name)
                if len(existing_group) >= 1:
                    api_result["status"] = "failure"
                    api_result["error"] = "Group already exists"
                else:
                    g = Group(creator=user, name=name, membership=group_type)
                    g.save()
                    if group_type == 2:
                        g.add_channel_admin(user, user)
                    elif group_type == 1:
                        g.add_member(user)
                    api_result["id"] = g.id
            except Exception as e:
                api_result["status"] = "failure"
                api_result["error"] = e.message

        elif group_type == 3:
            try:
                existing_group = Group.objects.filter(creator=user, name=name, membership=3)
                if len(existing_group) >= 1:
                    api_result["status"] = "failure"
                    api_result["error"] = "Group already exists"
                else:
                    g = Group(creator=user, name=name, membership=3)
                    g.save()
                    g.add_member(user, user)
                    g.approve_member(user)
                    api_result["id"] = g.id
            except Exception as e:
                api_result["status"] = "failure"
                api_result["error"] = e.message

    except Exception as e:
        api_result["status"] = "failure"
        api_result["error"] = e.message
        pass

    return JsonResponse(api_result)
开发者ID:krdeepak,项目名称:djmysite,代码行数:51,代码来源:views.py


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