def get_type_html(request, type, id, view): # get site in elasticsearch and render or return 404 # try: if view == "intro": view = "full" type_object = models.get_item(id, type) return render(request, 'tms/'+view+'.html', {'object': type_object, 'type': type})
def get_type_json(request, type, id): try: type_json = json.dumps(models.get_item(id, type)) response = HttpResponse(type_json) add_headers(response) return response except: raise Http404("There was an error getting this item")
def get_type_json(request, type, id): try: type_json = json.dumps(models.get_item(id, type, ES_INDEX)) response = HttpResponse(type_json) add_headers(response) return response except: raise Http404("There was an error getting this item")
def get_type_html(request, type, id): # get site in elasticsearch and render or return 404 try: type_object = models.get_item(id, type) print type, id return render(request, 'tms/'+type+'.html', {'object': type_object}) except: raise Http404("There was an error getting this item")
def get_type_related_items(request, type, id, relation): # get site's related items in elasticsearch and render or return 404 try: type_object = models.get_item(id, type) related_items = type_object['relateditems'][relation] return render(request, 'tms/'+type+'_related.html', {'relateditems': related_items, 'displaytext' : RELATED_DISPLAY_TEXT[relation], 'relation' : relation }) except: raise Http404("There was an error getting this item")
def get_type_html(request, type, id, view): # get site in elasticsearch and render or return 404 # try: if view == "intro": view = "full" type_object = models.get_item(id, type, ES_INDEX) # add form for creating a new collection in modal collection_form = CollectionForm() return render(request, 'pages/' + view + '.html', { 'object': type_object, 'type': type, 'collection_form': collection_form })
def get_manifest_data(request, id): ES_INDEX_IIIF = 'iiif' try: base_uri = request.build_absolute_uri('/manifests/') data = models.get_item(id, "manifest", ES_INDEX_IIIF) manifest = data['manifest'] manifest['@id'] = base_uri + manifest['@id'] if 'startCanvas' in manifest["sequences"][0]: manifest["sequences"][0]['startCanvas'] = base_uri + manifest[ "sequences"][0]['startCanvas'] manifest['sequences'][0][ '@id'] = base_uri + manifest['sequences'][0]['@id'] canvases = manifest['sequences'][0]['canvases'] for canvas in canvases: canvas['@id'] = base_uri + canvas['@id'] for image in canvas['images']: image['@id'] = base_uri + image['@id'] image['on'] = canvas['@id'] return manifest except: return None
def get_type_html(request, type, id, view): # get site in elasticsearch and render or return 404 # try: type_object = models.get_item(id, type) return render(request, "tms/" + view + ".html", {"object": type_object, "type": type})