Skip to content

Commit

Permalink
don't use private method in view
Browse files Browse the repository at this point in the history
  • Loading branch information
lukavdplas authored and jgonggrijp committed Dec 12, 2024
1 parent 55a2079 commit fbd22f7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions backend/collect/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
from rest_framework.views import Request
from rest_framework.exceptions import NotFound
from rdf.views import RDFView
from rdflib import URIRef, RDF, Graph, RDFS
from rdflib import URIRef, RDF, Graph, BNode, Literal
from django.conf import settings

from projects.api import user_projects
from collect.rdf_models import EDPOPCollection
from collect.utils import collection_exists, collection_graph
from triplestore.constants import EDPOPCOL
from triplestore.constants import EDPOPCOL, AS
from collect.serializers import CollectionSerializer
from collect.permissions import CollectionPermission
from collect.graphs import list_to_graph_collection

class CollectionViewSet(ModelViewSet):
'''
Expand Down Expand Up @@ -58,7 +59,12 @@ def get_graph(self, request: Request, collection: str, **kwargs) -> Graph:
collection_obj = EDPOPCollection(collection_graph(collection_uri), collection_uri)

g = Graph()
g += collection_obj._class_triples()
g += EDPOPCollection.records._stored_triples(collection_obj)
g.add((collection_obj.uri, RDF.type, EDPOPCOL.Collection))
g.add((collection_obj.uri, RDF.type, AS.Collection))

items_node = BNode()
g.add((collection_obj.uri, AS.items, items_node))
g.add((collection_obj.uri, AS.totalItems, Literal(len(collection_obj.records))))
g += list_to_graph_collection(collection_obj.records, items_node)

return g

0 comments on commit fbd22f7

Please sign in to comment.