From 309401f7550afe44d50a26f1dcdc0e474290f32b Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Wed, 12 Aug 2015 22:59:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B0=8F=E7=BB=84=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- group/views.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/group/views.py b/group/views.py index 79ccbd4..a9ec8d2 100644 --- a/group/views.py +++ b/group/views.py @@ -94,6 +94,7 @@ class GroupAdminAPIView(APIView, GroupAPIViewBase): response_serializer: GroupSerializer """ group_id = request.GET.get("group_id", None) + # 根据 id 查询小组信息 if group_id: try: group = self.get_group(request, group_id) @@ -102,8 +103,15 @@ class GroupAdminAPIView(APIView, GroupAPIViewBase): return error_response(u"小组不存在") else: groups = self.get_groups(request) + # 搜索小组 if request.GET.get("keyword", None): groups = groups.filter(name__contains=request.GET["keyword"]) + # 只返回我创建的小组 适用于超级管理员 + if request.GET.get("my_group", None): + groups = groups.filter(admin=request.user) + # 只返回指定用户的小组 适用于管理员 + elif request.GET.get("admin_id", None): + groups = groups.filter(admin__id=request.GET["admin_id"]) return paginate(request, groups, GroupSerializer)