def field_entity_relations(request, source_id): """ Show HTML form to change relationships for entities to be created / or updated from an import table """ if not request.user.is_superuser: return HttpResponse('Unauthorized', status=401) else: ip = ImportProfile(source_id) if ip.project_uuid is not False: ip.get_fields() if len(ip.fields) > 0: ip.get_field_annotations() ip.jsonify_field_annotations() imnav = ImportNavigation() ip.nav = imnav.set_nav('field-entity-relations', ip.project_uuid, source_id) template = loader.get_template( 'imports/field-entity-relations.html') context = RequestContext(request, {'ip': ip}) return HttpResponse(template.render(context)) else: redirect = '../../imports/field-types/' + source_id return HttpResponseRedirect(redirect) else: raise Http404
def create(request, source_id): """ Classifies one or more fields with posted data """ if not request.user.is_superuser: return HttpResponse('Unauthorized', status=401) else: if request.method == 'POST': ip = ImportProfile(source_id) if ip.project_uuid is not False: ifd = ImportFieldDescribe(source_id) ifd.project_uuid = ip.project_uuid if request.POST['predicate'] == Assertion.PREDICATES_CONTAINS: ifd.update_field_contains(request.POST['field_num'], request.POST['object_field_num']) elif request.POST[ 'predicate'] == ImportFieldAnnotation.PRED_CONTAINED_IN: ifd.update_field_containedin_entity( request.POST['field_num'], request.POST['object_uuid']) elif request.POST[ 'predicate'] == ImportFieldAnnotation.PRED_MEDIA_PART_OF: ifd.update_field_media_part_of_entity( request.POST['field_num'], request.POST['object_field_num']) elif request.POST['predicate'] == Assertion.PREDICATES_LINK: if 'object_field_num' in request.POST: ifd.update_field_links( request.POST['field_num'], request.POST['object_field_num']) elif request.POST[ 'predicate'] == ImportFieldAnnotation.PRED_DESCRIBES: if 'object_field_num' in request.POST: ifd.update_desciption(request.POST['field_num'], request.POST['object_field_num']) elif request.POST[ 'predicate'] == ImportFieldAnnotation.PRED_VALUE_OF: if 'object_field_num' in request.POST: ifd.update_variable_value( request.POST['field_num'], request.POST['object_field_num']) else: if request.POST['predicate'] == '-1': # the predicate is not yet reconciled predicate_id = ifd.make_or_reconcile_link_predicate( request.POST['predicate_label'], ifd.project_uuid) else: predicate_id = request.POST['predicate'] ifd.update_field_custom_predicate( request.POST['field_num'], request.POST['object_field_num'], predicate_id, request.POST['predicate_type']) ip.get_field_annotations() anno_list = ip.jsonify_field_annotations() json_output = json.dumps(anno_list, indent=4, ensure_ascii=False) return HttpResponse( json_output, content_type='application/json; charset=utf8') else: raise Http404 else: return HttpResponseForbidden
def field_complex_descriptions(request, source_id): """ Show HTML form to change group descriptive properties together into groups of complex descriptions """ if not request.user.is_superuser: return HttpResponse('Unauthorized', status=401) else: rp = RootPath() base_url = rp.get_baseurl() ip = ImportProfile(source_id) if ip.project_uuid is not False: ip.get_fields() if len(ip.fields) > 0: ip.get_field_annotations() ip.jsonify_field_annotations() imnav = ImportNavigation() ip.nav = imnav.set_nav('field-entity-relations', ip.project_uuid, source_id) template = loader.get_template('imports/field-entity-relations.html') context = { 'ip': ip, 'base_url': base_url, 'user': request.user } return HttpResponse(template.render(context, request)) else: redirect = '../../imports/field-types/' + source_id return HttpResponseRedirect(redirect) else: raise Http404
def field_entity_relations(request, source_id): """ Show HTML form to change relationships for entities to be created / or updated from an import table """ if not request.user.is_superuser: return HttpResponse('Unauthorized', status=401) else: rp = RootPath() base_url = rp.get_baseurl() ip = ImportProfile(source_id) if ip.project_uuid is not False: ip.get_fields() if len(ip.fields) > 0: ip.get_field_annotations() ip.jsonify_field_annotations() imnav = ImportNavigation() ip.nav = imnav.set_nav('field-entity-relations', ip.project_uuid, source_id) template = loader.get_template('imports/field-entity-relations.html') context = RequestContext(request, {'ip': ip, 'base_url': base_url}) return HttpResponse(template.render(context)) else: redirect = '../../imports/field-types/' + source_id return HttpResponseRedirect(redirect) else: raise Http404
def field_complex_descriptions(request, source_id): """ Show HTML form to change group descriptive properties together into groups of complex descriptions """ if not request.user.is_superuser: return HttpResponse('Unauthorized', status=401) else: rp = RootPath() base_url = rp.get_baseurl() ip = ImportProfile(source_id) if ip.project_uuid is not False: ip.get_fields() if len(ip.fields) > 0: ip.get_field_annotations() ip.jsonify_field_annotations() imnav = ImportNavigation() ip.nav = imnav.set_nav('field-entity-relations', ip.project_uuid, source_id) template = loader.get_template( 'imports/field-entity-relations.html') context = { 'ip': ip, 'base_url': base_url, 'user': request.user } return HttpResponse(template.render(context, request)) else: redirect = '../../imports/field-types/' + source_id return HttpResponseRedirect(redirect) else: raise Http404
def create(request, source_id): """ Classifies one or more fields with posted data """ if not request.user.is_superuser: return HttpResponse('Unauthorized', status=401) else: if request.method == 'POST': ip = ImportProfile(source_id) if ip.project_uuid is not False: ifd = ImportFieldDescribe(source_id) ifd.project_uuid = ip.project_uuid if request.POST['predicate'] == Assertion.PREDICATES_CONTAINS: ifd.update_field_contains(request.POST['field_num'], request.POST['object_field_num']) elif request.POST['predicate'] == ImportFieldAnnotation.PRED_CONTAINED_IN: ifd.update_field_containedin_entity(request.POST['field_num'], request.POST['object_uuid']) elif request.POST['predicate'] == ImportFieldAnnotation.PRED_MEDIA_PART_OF: ifd.update_field_media_part_of_entity(request.POST['field_num'], request.POST['object_field_num']) elif request.POST['predicate'] == Assertion.PREDICATES_LINK: if 'object_field_num' in request.POST: ifd.update_field_links(request.POST['field_num'], request.POST['object_field_num']) elif request.POST['predicate'] == ImportFieldAnnotation.PRED_DESCRIBES: if 'object_field_num' in request.POST: ifd.update_desciption(request.POST['field_num'], request.POST['object_field_num']) elif request.POST['predicate'] == ImportFieldAnnotation.PRED_VALUE_OF: if 'object_field_num' in request.POST: ifd.update_variable_value(request.POST['field_num'], request.POST['object_field_num']) else: if request.POST['predicate'] == '-1': # the predicate is not yet reconciled predicate_id = ifd.make_or_reconcile_link_predicate(request.POST['predicate_label'], ifd.project_uuid) else: predicate_id = request.POST['predicate'] ifd.update_field_custom_predicate(request.POST['field_num'], request.POST['object_field_num'], predicate_id, request.POST['predicate_type']) ip.get_field_annotations() anno_list = ip.jsonify_field_annotations() json_output = json.dumps(anno_list, indent=4, ensure_ascii=False) return HttpResponse(json_output, content_type='application/json; charset=utf8') else: raise Http404 else: return HttpResponseForbidden
def view(request, source_id): """ Returns JSON data for an identifier in its hierarchy """ if not request.user.is_superuser: return HttpResponse('Unauthorized', status=401) else: ip = ImportProfile(source_id) if ip.project_uuid is not False: ip.get_field_annotations() anno_list = ip.jsonify_field_annotations() json_output = json.dumps(anno_list, indent=4, ensure_ascii=False) return HttpResponse(json_output, content_type='application/json; charset=utf8') else: raise Http404