mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 03:49:24 +00:00
Refactoring mailings
This commit is contained in:
@ -48,5 +48,6 @@ urlpatterns = [
|
||||
url(r'^', include(router.urls)),
|
||||
url(r'^login/', include('rest_framework.urls', namespace='rest_framework')),
|
||||
url(r'^markdown$', RenderMarkdown, name='api_markdown'),
|
||||
url(r'^mailings$', FetchMailingLists, name='mailings_fetch')
|
||||
|
||||
]
|
||||
|
@ -22,9 +22,15 @@
|
||||
#
|
||||
#
|
||||
|
||||
from rest_framework.response import Response
|
||||
from rest_framework import serializers
|
||||
from rest_framework.decorators import api_view, renderer_classes
|
||||
from rest_framework.renderers import StaticHTMLRenderer
|
||||
|
||||
from club.models import Club
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
from club.models import Club, Mailing
|
||||
|
||||
from api.views import RightModelViewSet
|
||||
|
||||
@ -43,3 +49,15 @@ class ClubViewSet(RightModelViewSet):
|
||||
|
||||
serializer_class = ClubSerializer
|
||||
queryset = Club.objects.all()
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
@renderer_classes((StaticHTMLRenderer,))
|
||||
def FetchMailingLists(request):
|
||||
key = request.GET.get('key', '')
|
||||
if key != settings.SITH_MAILING_FETCH_KEY:
|
||||
raise PermissionDenied
|
||||
data = ''
|
||||
for mailing in Mailing.objects.all():
|
||||
data += mailing.fetch_format()
|
||||
return Response(data)
|
||||
|
Reference in New Issue
Block a user