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.permissions import IsAuthenticated
|
2020-12-15 16:28:25 +01:00
|
|
|
from rest_framework.viewsets import ModelViewSet
|
2020-12-14 20:29:38 +01:00
|
|
|
|
|
|
|
from smartpicasso.app.project.serializers import ProjectSerializer
|
2020-12-15 16:33:28 +01:00
|
|
|
from smartpicasso.app.project.models import Project
|
2020-12-14 20:29:38 +01:00
|
|
|
|
|
|
|
|
2020-12-15 16:28:25 +01:00
|
|
|
class ProjectsView(ModelViewSet):
|
2020-12-14 20:29:38 +01:00
|
|
|
"""
|
|
|
|
View for project endpoints
|
|
|
|
"""
|
|
|
|
permission_classes = (IsAuthenticated,)
|
|
|
|
serializer_class = ProjectSerializer
|
|
|
|
|
2020-12-15 16:28:25 +01:00
|
|
|
def perform_create(self, serializer):
|
|
|
|
serializer.save(user=self.request.user)
|
2020-12-15 16:33:28 +01:00
|
|
|
|
|
|
|
def get_queryset(self):
|
|
|
|
user = self.request.user
|
|
|
|
return Project.objects.filter(user=user)
|