Commit 73c7887d by Chif Gergő

Filter owned templates and display system templates for everyone

parent 1a9a8829
Pipeline #1046 failed with stage
in 1 minute 28 seconds
......@@ -3,6 +3,7 @@ from rest_framework.viewsets import ModelViewSet
from template.serializers import ImageTemplateModelSerializer, ImageTemplateListItemSerializer
from template.models import ImageTemplate
from django.db.models import Q
class ImageTemplateViewSet(ModelViewSet):
......@@ -41,7 +42,7 @@ class ImageTemplateViewSet(ModelViewSet):
return super(ImageTemplateViewSet, self).update(request, partial=True)
def list(self, request, *args, **kwargs):
# TODO: Filter for owned and shared tempaltes
query = ImageTemplate.objects.all()
# TODO: Filter for shared tempaltes
query = ImageTemplate.objects.filter(Q(created_by=request.user.id) | Q(type="SYSTEM"))
serializer = ImageTemplateListItemSerializer(query, many=True)
return Response(serializer.data)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment