8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-26 17:03:45 +00:00

Merge branch 'mailing_groups' into 'dev'

Add group mailings

See merge request federez/re2o!482
This commit is contained in:
chirac 2020-03-29 01:31:43 +01:00
commit eb48572162

View file

@ -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)