Skip to content

Commit

Permalink
Add preliminary DRF viewset for SemanticQuery model (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgonggrijp committed Jul 13, 2021
1 parent 64c919d commit e57b0c1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/items/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from rest_framework.response import Response
from rest_framework.status import *
from rest_framework.exceptions import ValidationError, NotFound, PermissionDenied
from rest_framework.viewsets import GenericViewSet
from rest_framework.mixins import CreateModelMixin, ListModelMixin, RetrieveModelMixin

from rdflib import Graph, URIRef, BNode, Literal
from rdflib.query import ResultException
Expand All @@ -24,8 +26,9 @@
from sources import namespace as source
from . import namespace as my
from .graph import graph, history
from .models import ItemCounter, EditCounter
from .models import ItemCounter, EditCounter, SemanticQuery
from .permissions import *
from .serializers import SemanticQuerySerializer

MUST_SINGLE_BLANK_400 = 'POST requires exactly one subject which must be a blank node.'
MUST_EQUAL_IDENTIFIER_400 = 'PUT must affect exactly the resource URI.'
Expand Down Expand Up @@ -304,3 +307,11 @@ def get_graph(self, request, category, **kwargs):
break
[user_items.add(triple) for triple in items.triples((s, None, None))]
return user_items


class SemanticQueryViewSet(
CreateModelMixin, ListModelMixin, RetrieveModelMixin,
GenericViewSet,
):
queryset = SemanticQuery.objects.all()
serializer_class = SemanticQuerySerializer

0 comments on commit e57b0c1

Please sign in to comment.