Add grammar to tags. Also: respect custom tag slugs on publishing.
[wolnelektury.git] / src / picture / api / views.py
1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
3 #
4 import json
5 from django.http import Http404
6 from rest_framework.permissions import DjangoModelPermissions
7 from rest_framework.response import Response
8 from rest_framework import status
9 from rest_framework.views import APIView
10 from picture.forms import PictureImportForm
11 from picture.models import Picture
12
13
14 class PicturesView(APIView):
15     permission_classes = [DjangoModelPermissions]
16     queryset = Picture.objects.none()  # Required for DjangoModelPermissions
17
18     def post(self, request):
19         data = json.loads(request.POST.get('data'))
20         form = PictureImportForm(data)
21         if form.is_valid():
22             form.save()
23             return Response({}, status=status.HTTP_201_CREATED)
24         else:
25             raise Http404