""" @author p.dolata """ from rest_framework import status from rest_framework.generics import CreateAPIView from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from smartpicasso.app.project.serializers import ProjectSerializer class ProjectsView(CreateAPIView): """ View for project endpoints """ permission_classes = (IsAuthenticated,) serializer_class = ProjectSerializer def post(self, request): serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) project = serializer.save(user=request.user) status_code = status.HTTP_201_CREATED response = { 'success': 'True', 'status_code': status_code, 'data': { 'id': project.id } } return Response(response, status=status_code)