From 15cec0c7f304f947f0ed954f66a68eaecc3e2281 Mon Sep 17 00:00:00 2001 From: Yoann Pietri Date: Sat, 25 Jan 2020 23:37:17 +0100 Subject: [PATCH] Add group mailings --- api/views.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/views.py b/api/views.py index b53ee974..4077eeeb 100644 --- a/api/views.py +++ b/api/views.py @@ -30,6 +30,7 @@ import datetime from django.conf import settings from django.db.models import Q +from django.contrib.auth.models import Group from rest_framework import viewsets, generics, views from rest_framework.authtoken.models import Token from rest_framework.authtoken.views import ObtainAuthToken @@ -759,7 +760,15 @@ class StandardMailingView(views.APIView): adherents_data = serializers.MailingMemberSerializer( all_has_access(), many=True ).data + data = [{"name": "adherents", "members": adherents_data}] + groups = Group.objects.all() + for group in groups: + group_data = serializers.MailingMemberSerializer( + group.user_set.all(), many=True + ).data + data.append({"name": group.name, "members": group_data}) + paginator = self.pagination_class() paginator.paginate_queryset(data, request) return paginator.get_paginated_response(data)