本文整理汇总了Python中models.Group.approve_member方法的典型用法代码示例。如果您正苦于以下问题:Python Group.approve_member方法的具体用法?Python Group.approve_member怎么用?Python Group.approve_member使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Group
的用法示例。
在下文中一共展示了Group.approve_member方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dummy_groups
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import approve_member [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)
示例2: api_group_create
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import approve_member [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)