2020-12-14 20:29:38 +01:00
|
|
|
"""
|
|
|
|
@author p.dolata
|
|
|
|
"""
|
2020-12-14 20:01:40 +01:00
|
|
|
|
2020-12-14 20:29:38 +01:00
|
|
|
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)
|