def project_annotations_ttl(request, identifier): """ Returns RDF open annotation assertions conforming to Pelagios specifications that link Open Context resources with place entities in gazetteers, in the turtle format """ ent = Entity() found = ent.dereference(identifier) if found: if ent.item_type == 'projects': pp = ProjectPermissions(ent.uuid) permitted = pp.view_allowed(request) if permitted: pelagios = PelagiosGraph() pelagios.project_uuids = [ent.uuid] pelagios.test_limit = None pelagios.make_graph() # default to outputting in turtle output = pelagios.g.serialize(format='turtle') return HttpResponse(output, content_type='text/turtle; charset=utf8') else: return HttpResponse('Not authorized to get this resource', content_type='text/html; charset=utf8', status=401) else: found = False if found is False: raise Http404
def check_permissions(self, request): """ checks permissions """ if request is not None and self.manifest is not False: # check to make sure edit permissions OK pp = ProjectPermissions(self.manifest.project_uuid) self.edit_permitted = pp.edit_allowed(request) self.view_permitted = pp.view_allowed(request)
def check_view_permission(self, project_uuid): """ Checkes to see if viewing the item is permitted """ permitted = True # default if self.request is not False: pp = ProjectPermissions(project_uuid) permitted = pp.view_allowed(self.request) return permitted
def project_annotations(request, identifier): """ Returns RDF open annotation assertions conforming to Pelagios specifications that link Open Context resources with place entities in gazetteers """ ent = Entity() found = ent.dereference(identifier) if found or identifier == 'web': if ent.item_type == 'projects' or identifier == 'web': pelagios = PelagiosGraph() pelagios.test_limit = None if 'refresh' in request.GET: # we're going to refresh the cache pelagios.refresh_cache = True if identifier != 'web': pp = ProjectPermissions(ent.uuid) permitted = pp.view_allowed(request) pelagios.project_uuids = [ent.uuid] else: # we're doing web annotations pelagios.do_web_annotations = True permitted = True if permitted: pelagios.get_graph() req_neg = RequestNegotiation('text/turtle') req_neg.supported_types = [ 'application/rdf+xml', 'text/n3', 'application/n-triples' ] if 'HTTP_ACCEPT' in request.META: req_neg.check_request_support(request.META['HTTP_ACCEPT']) if req_neg.supported: content_type = req_neg.use_response_type + '; charset=utf8' output = pelagios.g.serialize( format=req_neg.use_response_type) return HttpResponse(output, content_type=content_type) else: # client wanted a mimetype we don't support return HttpResponse( req_neg.error_message, content_type="text/plain; charset=utf8", status=415) else: # default to outputting in turtle output = pelagios.g.serialize(format='turtle') return HttpResponse( output, content_type='text/turtle; charset=utf8') else: return HttpResponse('Not authorized to get this resource', content_type='text/html; charset=utf8', status=401) else: found = False if found is False: raise Http404
def project_annotations(request, identifier): """ Returns RDF open annotation assertions conforming to Pelagios specifications that link Open Context resources with place entities in gazetteers """ ent = Entity() found = ent.dereference(identifier) if found or identifier == 'web': if ent.item_type == 'projects' or identifier == 'web': pelagios = PelagiosGraph() pelagios.test_limit = None if 'refresh' in request.GET: # we're going to refresh the cache pelagios.refresh_cache = True if identifier != 'web': pp = ProjectPermissions(ent.uuid) permitted = pp.view_allowed(request) pelagios.project_uuids = [ent.uuid] else: # we're doing web annotations pelagios.do_web_annotations = True permitted = True if permitted: pelagios.get_graph() req_neg = RequestNegotiation('text/turtle') req_neg.supported_types = ['application/rdf+xml', 'text/n3', 'application/n-triples'] if 'HTTP_ACCEPT' in request.META: req_neg.check_request_support(request.META['HTTP_ACCEPT']) if req_neg.supported: content_type = req_neg.use_response_type + '; charset=utf8' output = pelagios.g.serialize(format=req_neg.use_response_type) return HttpResponse(output, content_type=content_type) else: # client wanted a mimetype we don't support return HttpResponse(req_neg.error_message, content_type="text/plain; charset=utf8", status=415) else: # default to outputting in turtle output = pelagios.g.serialize(format='turtle') return HttpResponse(output, content_type='text/turtle; charset=utf8') else: return HttpResponse('Not authorized to get this resource', content_type='text/html; charset=utf8', status=401) else: found = False if found is False: raise Http404
def project_annotations_ttl(request, identifier): """ Returns RDF open annotation assertions conforming to Pelagios specifications that link Open Context resources with place entities in gazetteers, in the turtle format """ ent = Entity() found = ent.dereference(identifier) if found or identifier == 'web': if ent.item_type == 'projects' or identifier == 'web': pelagios = PelagiosGraph() pelagios.test_limit = None if 'refresh' in request.GET: # we're going to refresh the cache pelagios.refresh_cache = True if identifier != 'web': pp = ProjectPermissions(ent.uuid) permitted = pp.view_allowed(request) pelagios.project_uuids = [ent.uuid] else: # we're doing web annotations pelagios.do_web_annotations = True permitted = True if permitted: pelagios.get_graph() # default to outputting in turtle output = pelagios.g.serialize(format='turtle') return HttpResponse(output, content_type='text/turtle; charset=utf8') else: return HttpResponse('Not authorized to get this resource', content_type='text/html; charset=utf8', status=401) else: found = False if found is False: raise Http404