Ejemplo n.º 1
0
def html_view(request, uuid):
    ocitem = OCitem()
    ocitem.get_item(uuid)
    if ocitem.manifest is not False:
        rp = RootPath()
        base_url = rp.get_baseurl()
        temp_item = TemplateItem(request)
        temp_item.read_jsonld_dict(ocitem.json_ld)
        template = loader.get_template("media/view.html")
        if temp_item.view_permitted:
            req_neg = RequestNegotiation("text/html")
            req_neg.supported_types = ["application/json", "application/ld+json"]
            if "HTTP_ACCEPT" in request.META:
                req_neg.check_request_support(request.META["HTTP_ACCEPT"])
            if req_neg.supported:
                if "json" in req_neg.use_response_type:
                    # content negotiation requested JSON or JSON-LD
                    return HttpResponse(
                        json.dumps(ocitem.json_ld, ensure_ascii=False, indent=4),
                        content_type=req_neg.use_response_type + "; charset=utf8",
                    )
                else:
                    context = RequestContext(request, {"item": temp_item, "fullview": False, "base_url": base_url})
                    return HttpResponse(template.render(context))
            else:
                # client wanted a mimetype we don't support
                return HttpResponse(
                    req_neg.error_message, content_type=req_neg.use_response_type + "; charset=utf8", status=415
                )
        else:
            template = loader.get_template("items/view401.html")
            context = RequestContext(request, {"item": temp_item, "base_url": base_url})
            return HttpResponse(template.render(context), status=401)
    else:
        raise Http404
Ejemplo n.º 2
0
def check_list_view(request, uuid):
    """ Displays the HTML item editing interface """
    ocitem = OCitem()
    ocitem.get_item(uuid)
    if ocitem.manifest is not False:
        if ocitem.manifest.item_type == 'projects':
            rp = RootPath()
            base_url = rp.get_baseurl()
            temp_item = TemplateItem(request)
            temp_item.check_edit_permitted = True
            temp_item.read_jsonld_dict(ocitem.json_ld)
            if temp_item.edit_permitted:
                template = loader.get_template('edit/check-list.html')
                context = RequestContext(
                    request, {
                        'item': temp_item,
                        'super_user': request.user.is_superuser,
                        'icons': ItemBasicEdit.UI_ICONS,
                        'base_url': base_url
                    })
                return HttpResponse(template.render(context))
            else:
                template = loader.get_template('edit/view401.html')
                context = RequestContext(request, {
                    'item': temp_item,
                    'base_url': base_url
                })
                return HttpResponse(template.render(context), status=401)
        else:
            raise Http404
    else:
        raise Http404
Ejemplo n.º 3
0
def status(request, project_uuid):
    """ View of the project status """
    ocitem = OCitem()
    ocitem.get_item(project_uuid)
    ok_view = False
    if ocitem.manifest is not False:
        if ocitem.manifest.item_type == 'projects':
            ok_view = True
    if ok_view:
        rp = RootPath()
        base_url = rp.get_baseurl()
        temp_item = TemplateItem(request)
        temp_item.check_edit_permitted = True
        temp_item.read_jsonld_dict(ocitem.json_ld)
        if temp_item.edit_permitted:
            p_o = ProjectOverview(project_uuid)
            p_o.get_manifest_summary()
            p_o.get_person_list()
            # p_o. get_data_type_summary()
            template = loader.get_template('edit/project-status.html')
            context = {
                'item': temp_item,
                'super_user': request.user.is_superuser,
                'icons': ItemBasicEdit.UI_ICONS,
                'status': p_o,
                'base_url': base_url,
                'user': request.user
            }
            return HttpResponse(template.render(context, request))
        else:
            template = loader.get_template('edit/view401.html')
            context = {'item': temp_item, 'base_url': base_url}
            return HttpResponse(template.render(context, request), status=401)
    else:
        raise Http404
Ejemplo n.º 4
0
def html_view(request, uuid):
    ocitem = OCitem()
    ocitem.get_item(uuid, True)
    if(ocitem.manifest is not False):
        rp = RootPath()
        base_url = rp.get_baseurl()
        temp_item = TemplateItem()
        temp_item.read_jsonld_dict(ocitem.json_ld)
        template = loader.get_template('projects/view.html')
        req_neg = RequestNegotiation('text/html')
        req_neg.supported_types = ['application/json',
                                   'application/ld+json']
        if 'HTTP_ACCEPT' in request.META:
            req_neg.check_request_support(request.META['HTTP_ACCEPT'])
        if req_neg.supported:
            if 'json' in req_neg.use_response_type:
                # content negotiation requested JSON or JSON-LD
                return HttpResponse(json.dumps(ocitem.json_ld,
                                    ensure_ascii=False, indent=4),
                                    content_type=req_neg.use_response_type + "; charset=utf8")
            else:
                context = RequestContext(request,
                                         {'item': temp_item,
                                          'base_url': base_url})
                return HttpResponse(template.render(context))
        else:
                # client wanted a mimetype we don't support
                return HttpResponse(req_neg.error_message,
                                    content_type=req_neg.use_response_type + "; charset=utf8",
                                    status=415)
    else:
        raise Http404
Ejemplo n.º 5
0
def html_view(request, uuid):
    ocitem = OCitem()
    ocitem.get_item(uuid, True)
    if (ocitem.manifest is not False):
        rp = RootPath()
        base_url = rp.get_baseurl()
        temp_item = TemplateItem()
        temp_item.read_jsonld_dict(ocitem.json_ld)
        template = loader.get_template('projects/view.html')
        req_neg = RequestNegotiation('text/html')
        req_neg.supported_types = ['application/json', 'application/ld+json']
        if 'HTTP_ACCEPT' in request.META:
            req_neg.check_request_support(request.META['HTTP_ACCEPT'])
        if req_neg.supported:
            if 'json' in req_neg.use_response_type:
                # content negotiation requested JSON or JSON-LD
                return HttpResponse(json.dumps(ocitem.json_ld,
                                               ensure_ascii=False,
                                               indent=4),
                                    content_type=req_neg.use_response_type +
                                    "; charset=utf8")
            else:
                context = RequestContext(request, {
                    'item': temp_item,
                    'base_url': base_url
                })
                return HttpResponse(template.render(context))
        else:
            # client wanted a mimetype we don't support
            return HttpResponse(req_neg.error_message,
                                content_type=req_neg.use_response_type +
                                "; charset=utf8",
                                status=415)
    else:
        raise Http404
Ejemplo n.º 6
0
def html_view(request, uuid):
    request = RequestNegotiation().anonymize_request(request)
    # Handle some content negotiation for the item.    
    req_neg = RequestNegotiation('text/html')
    req_neg.supported_types = []
    if 'HTTP_ACCEPT' in request.META:
        req_neg.check_request_support(request.META['HTTP_ACCEPT'])
    if not req_neg.supported:
        # The client may be wanting a non-HTML representation, so
        # use the following function to get it.
        return items_graph(request, uuid, item_type=ITEM_TYPE)
    # Proceed with constructing the HTML item
    ocitem = OCitem()
    if 'hashes' in request.GET:
        ocitem.assertion_hashes = True
    ocitem.get_item(uuid, True)
    if not ocitem.manifest:
        # Did not find a record for the table, check for redirects
        r_url = RedirectURL()
        r_ok = r_url.get_direct_by_type_id(ITEM_TYPE, uuid)
        if r_ok:
            # found a redirect!!
            return redirect(r_url.redirect, permanent=r_url.permanent)
        # raise Http404
        raise Http404
    # Construnct item the JSON-LD
    request.uuid = ocitem.manifest.uuid
    request.project_uuid = ocitem.manifest.project_uuid
    request.item_type = ocitem.manifest.item_type
    ts = TypeSupplement(ocitem.json_ld)
    ocitem.json_ld = ts.get_arachne_comparanda()
    rp = RootPath()
    base_url = rp.get_baseurl()
    temp_item = TemplateItem(request)
    temp_item.read_jsonld_dict(ocitem.json_ld)
    if not temp_item.view_permitted:
        # The client is not allowed to see this.
        template = loader.get_template('items/view401.html')
        context = {
            'item': temp_item,
            'base_url': base_url,
            'user': request.user
        }
        return HttpResponse(template.render(context, request), status=401)
    # Now add templated item to the a response object
    template = loader.get_template('types/view.html')
    context = {
        'item': temp_item,
        'base_url': base_url,
        'user': request.user
    }
    response = HttpResponse(template.render(context, request))
    patch_vary_headers(response, ['accept', 'Accept', 'content-type'])
    return response
Ejemplo n.º 7
0
def html_view(request, uuid, full_view=False):
    request = RequestNegotiation().anonymize_request(request)
    # Handle some content negotiation for the item.    
    req_neg = RequestNegotiation('text/html')
    req_neg.supported_types = []
    if 'HTTP_ACCEPT' in request.META:
        req_neg.check_request_support(request.META['HTTP_ACCEPT'])
    if not req_neg.supported:
        # The client may be wanting a non-HTML representation, so
        # use the following function to get it.
        return items_graph(request, uuid, item_type=ITEM_TYPE)
    # Construnct the item
    ocitem = OCitem()
    ocitem.get_item(uuid)
    if not ocitem.manifest:
        # Did not find a record for the table, check for redirects
        r_url = RedirectURL()
        r_ok = r_url.get_direct_by_type_id(ITEM_TYPE, uuid)
        if r_ok:
            # found a redirect!!
            return redirect(r_url.redirect, permanent=r_url.permanent)
        # raise Http404
        raise Http404
    request.uuid = ocitem.manifest.uuid
    request.project_uuid = ocitem.manifest.project_uuid
    request.item_type = ocitem.manifest.item_type
    rp = RootPath()
    base_url = rp.get_baseurl()
    temp_item = TemplateItem(request)
    temp_item.read_jsonld_dict(ocitem.json_ld)
    if full_view:
        template = loader.get_template('media/full.html')
    else:
        template = loader.get_template('media/view.html')
    if not temp_item.view_permitted:
        # The client is not allowed to see this.
        template = loader.get_template('items/view401.html')
        context = {
            'item': temp_item,
            'base_url': base_url,
            'user': request.user
        }
        return HttpResponse(template.render(context, request), status=401)
    # Now add templated item to the a response object
    context = {
        'item': temp_item,
        'fullview': full_view,
        'base_url': base_url,
        'user': request.user
    }
    response = HttpResponse(template.render(context, request))
    patch_vary_headers(response, ['accept', 'Accept', 'content-type'])
    return response
Ejemplo n.º 8
0
def html_view(request, uuid):
    request = RequestNegotiation().anonymize_request(request)
    # Handle some content negotiation for the item.
    req_neg = RequestNegotiation('text/html')
    req_neg.supported_types = []
    if 'HTTP_ACCEPT' in request.META:
        req_neg.check_request_support(request.META['HTTP_ACCEPT'])
    if not req_neg.supported:
        # The client may be wanting a non-HTML representation, so
        # use the following function to get it.
        return items_graph(request, uuid, item_type=ITEM_TYPE)
    ocitem = OCitem()
    ocitem.get_item(uuid)
    if not ocitem.manifest:
        # Did not find a record for the table, check for redirects
        r_url = RedirectURL()
        r_ok = r_url.get_direct_by_type_id(ITEM_TYPE, uuid)
        if r_ok:
            # found a redirect!!
            return redirect(r_url.redirect, permanent=r_url.permanent)
        # raise Http404
        raise Http404
    # check to see if there's related data via API calls. Add if so.
    request.uuid = ocitem.manifest.uuid
    request.project_uuid = ocitem.manifest.project_uuid
    request.item_type = ocitem.manifest.item_type
    subj_s = SubjectSupplement(ocitem.json_ld)
    ocitem.json_ld = subj_s.get_catal_related()
    rp = RootPath()
    base_url = rp.get_baseurl()
    temp_item = TemplateItem(request)
    temp_item.read_jsonld_dict(ocitem.json_ld)
    template = loader.get_template('subjects/view.html')
    if not temp_item.view_permitted:
        # The client is not allowed to see this.
        template = loader.get_template('items/view401.html')
        context = {
            'item': temp_item,
            'base_url': base_url,
            'user': request.user
        }
        return HttpResponse(template.render(context, request), status=401)
    # The client is allowd to see the current item.
    context = {'item': temp_item, 'base_url': base_url, 'user': request.user}
    response = HttpResponse(template.render(context, request))
    patch_vary_headers(response, ['accept', 'Accept', 'content-type'])
    return response
Ejemplo n.º 9
0
def html_view(request, uuid):
    ocitem = OCitem()
    ocitem.get_item(uuid)
    if (ocitem.manifest is not False):
        # check to see if there's related data via API calls. Add if so.
        subj_s = SubjectSupplement(ocitem.json_ld)
        ocitem.json_ld = subj_s.get_catal_related()
        rp = RootPath()
        base_url = rp.get_baseurl()
        temp_item = TemplateItem(request)
        temp_item.read_jsonld_dict(ocitem.json_ld)
        template = loader.get_template('subjects/view.html')
        if temp_item.view_permitted:
            req_neg = RequestNegotiation('text/html')
            req_neg.supported_types = [
                'application/json', 'application/ld+json'
            ]
            if 'HTTP_ACCEPT' in request.META:
                req_neg.check_request_support(request.META['HTTP_ACCEPT'])
            if req_neg.supported:
                if 'json' in req_neg.use_response_type:
                    # content negotiation requested JSON or JSON-LD
                    return HttpResponse(
                        json.dumps(ocitem.json_ld,
                                   ensure_ascii=False,
                                   indent=4),
                        content_type=req_neg.use_response_type +
                        "; charset=utf8")
                else:
                    context = RequestContext(request, {
                        'item': temp_item,
                        'base_url': base_url
                    })
                    return HttpResponse(template.render(context))
            else:
                # client wanted a mimetype we don't support
                return HttpResponse(req_neg.error_message,
                                    content_type=req_neg.use_response_type +
                                    "; charset=utf8",
                                    status=415)
        else:
            template = loader.get_template('items/view401.html')
            context = RequestContext(request, {'item': temp_item})
            return HttpResponse(template.render(context), status=401)
    else:
        raise Http404
Ejemplo n.º 10
0
def html_view(request, uuid):
    """ Displays the HTML item editing interface """
    ocitem = OCitem()
    ocitem.get_item(uuid)
    if (ocitem.manifest is not False):
        rp = RootPath()
        base_url = rp.get_baseurl()
        temp_item = TemplateItem(request)
        temp_item.check_edit_permitted = True
        temp_item.read_jsonld_dict(ocitem.json_ld)
        if temp_item.edit_permitted:
            if 'alt' in request.GET:
                template = loader.get_template('edit/item-edit.html')
            else:
                template = loader.get_template('edit/view.html')
            context = RequestContext(
                request, {
                    'item': temp_item,
                    'profile': check_profile_use(ocitem.manifest),
                    'super_user': request.user.is_superuser,
                    'icons': ItemBasicEdit.UI_ICONS,
                    'base_url': base_url
                })
            return HttpResponse(template.render(context))
        else:
            template = loader.get_template('edit/view401.html')
            context = RequestContext(request, {
                'item': temp_item,
                'base_url': base_url
            })
            return HttpResponse(template.render(context), status=401)
    else:
        # not in the manifest, check to see if this is an data entry input profile
        ipt = InputProfileTemplating()
        exists = ipt.check_exists(uuid)
        if exists:
            rp = RootPath()
            base_url = rp.get_baseurl()
            return redirect(base_url + '/edit/inputs/profiles/' + uuid +
                            '/edit')
        else:
            raise Http404
Ejemplo n.º 11
0
def html_view(request, uuid):
    ocitem = OCitem()
    ocitem.get_item(uuid)
    if ocitem.manifest is not False:
        # check to see if there's related data via API calls. Add if so.
        subj_s = SubjectSupplement(ocitem.json_ld)
        ocitem.json_ld = subj_s.get_catal_related()
        rp = RootPath()
        base_url = rp.get_baseurl()
        temp_item = TemplateItem(request)
        temp_item.read_jsonld_dict(ocitem.json_ld)
        template = loader.get_template('subjects/view.html')
        if temp_item.view_permitted:
            req_neg = RequestNegotiation('text/html')
            req_neg.supported_types = ['application/json',
                                       'application/ld+json',
                                       'application/vnd.geo+json']
            if 'HTTP_ACCEPT' in request.META:
                req_neg.check_request_support(request.META['HTTP_ACCEPT'])
            if req_neg.supported:
                if 'json' in req_neg.use_response_type:
                    # content negotiation requested JSON or JSON-LD
                    return HttpResponse(json.dumps(ocitem.json_ld,
                                        ensure_ascii=False, indent=4),
                                        content_type=req_neg.use_response_type + "; charset=utf8")
                else:
                    context = RequestContext(request,
                                             {'item': temp_item,
                                              'base_url': base_url})
                    return HttpResponse(template.render(context))
            else:
                # client wanted a mimetype we don't support
                return HttpResponse(req_neg.error_message,
                                    content_type=req_neg.use_response_type + "; charset=utf8",
                                    status=415)
        else:
            template = loader.get_template('items/view401.html')
            context = RequestContext(request,
                                     {'item': temp_item})
            return HttpResponse(template.render(context), status=401)
    else:
        raise Http404
Ejemplo n.º 12
0
def html_view(request, uuid):
    """ Displays the HTML item editing interface """
    ocitem = OCitem()
    ocitem.get_item(uuid)
    if(ocitem.manifest is not False):
        temp_item = TemplateItem(request)
        temp_item.check_edit_permitted = True
        temp_item.read_jsonld_dict(ocitem.json_ld)
        if temp_item.edit_permitted:
            template = loader.get_template('edit/view.html')
            context = RequestContext(request,
                                     {'item': temp_item})
            return HttpResponse(template.render(context))
        else:
            template = loader.get_template('edit/view401.html')
            context = RequestContext(request,
                                     {'item': temp_item})
            return HttpResponse(template.render(context), status=401)
    else:
        raise Http404
Ejemplo n.º 13
0
def html_view(request, uuid):
    request = RequestNegotiation().anonymize_request(request)
    # Handle some content negotiation for the item.
    req_neg = RequestNegotiation('text/html')
    req_neg.supported_types = []
    if 'HTTP_ACCEPT' in request.META:
        req_neg.check_request_support(request.META['HTTP_ACCEPT'])
    if not req_neg.supported:
        # The client may be wanting a non-HTML representation, so
        # use the following function to get it.
        return items_graph(request, uuid, item_type=ITEM_TYPE)
    if request.GET.get('new') is not None:
        return html_view_new(request, uuid)
    ocitem = OCitem()
    ocitem.get_item(uuid, True)
    if not ocitem.manifest:
        # Did not find a record for the table, check for redirects
        r_url = RedirectURL()
        r_ok = r_url.get_direct_by_type_id(ITEM_TYPE, uuid)
        if r_ok:
            # found a redirect!!
            return redirect(r_url.redirect, permanent=r_url.permanent)
        # raise Http404
        raise Http404
    # Construnct item the JSON-LD
    request.uuid = ocitem.manifest.uuid
    request.project_uuid = ocitem.manifest.project_uuid
    request.item_type = ocitem.manifest.item_type
    rp = RootPath()
    base_url = rp.get_baseurl()
    proj_content = ProjectContent(ocitem.manifest.uuid, ocitem.manifest.slug,
                                  ocitem.json_ld)
    temp_item = TemplateItem()
    temp_item.proj_content = proj_content.get_project_content()
    temp_item.read_jsonld_dict(ocitem.json_ld)
    template = loader.get_template('projects/view.html')
    context = {'item': temp_item, 'base_url': base_url, 'user': request.user}
    response = HttpResponse(template.render(context, request))
    patch_vary_headers(response, ['accept', 'Accept', 'content-type'])
    return response
Ejemplo n.º 14
0
def status(request, project_uuid):
    """ View of the project status """
    ocitem = OCitem()
    ocitem.get_item(project_uuid)
    ok_view = False
    if ocitem.manifest is not False:
        if ocitem.manifest.item_type == 'projects':
            ok_view = True
    if ok_view:
        rp = RootPath()
        base_url = rp.get_baseurl()
        temp_item = TemplateItem(request)
        temp_item.check_edit_permitted = True
        temp_item.read_jsonld_dict(ocitem.json_ld)
        if temp_item.edit_permitted:
            p_o = ProjectOverview(project_uuid)
            p_o.get_manifest_summary()
            p_o.get_person_list()
            # p_o. get_data_type_summary()
            template = loader.get_template('edit/project-status.html')
            context = {
                'item': temp_item,
                'super_user': request.user.is_superuser,
                'icons': ItemBasicEdit.UI_ICONS,
                'status': p_o,
                'base_url': base_url,
                'user': request.user
            }
            return HttpResponse(template.render(context, request))
        else:
            template = loader.get_template('edit/view401.html')
            context = {
                'item': temp_item,
                'base_url': base_url
            }
            return HttpResponse(template.render(context, request), status=401)
    else:
        raise Http404
Ejemplo n.º 15
0
def status(request, project_uuid):
    """ View of the project status """
    ocitem = OCitem()
    ocitem.get_item(project_uuid)
    ok_view = False
    if ocitem.manifest is not False:
        if ocitem.manifest.item_type == "projects":
            ok_view = True
    if ok_view:
        rp = RootPath()
        base_url = rp.get_baseurl()
        temp_item = TemplateItem(request)
        temp_item.check_edit_permitted = True
        temp_item.read_jsonld_dict(ocitem.json_ld)
        if temp_item.edit_permitted:
            p_o = ProjectOverview(project_uuid)
            p_o.get_manifest_summary()
            # p_o. get_data_type_summary()
            template = loader.get_template("edit/project-status.html")
            context = RequestContext(
                request,
                {
                    "item": temp_item,
                    "super_user": request.user.is_superuser,
                    "icons": ItemBasicEdit.UI_ICONS,
                    "status": p_o,
                    "base_url": base_url,
                },
            )
            return HttpResponse(template.render(context))
        else:
            template = loader.get_template("edit/view401.html")
            context = RequestContext(request, {"item": temp_item, "base_url": base_url})
            return HttpResponse(template.render(context), status=401)
    else:
        raise Http404