From 9726152f197f8a5d6e968663744a3912fe4f8deb Mon Sep 17 00:00:00 2001 From: csae8092 Date: Thu, 14 Dec 2023 12:48:04 +0100 Subject: [PATCH 1/6] removed not needed things from entity detail view --- apis_core/apis_entities/detail_views.py | 43 ++----------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/apis_core/apis_entities/detail_views.py b/apis_core/apis_entities/detail_views.py index e35139f..996c7e9 100644 --- a/apis_core/apis_entities/detail_views.py +++ b/apis_core/apis_entities/detail_views.py @@ -1,12 +1,10 @@ from django.conf import settings -from django.contrib.auth.mixins import UserPassesTestMixin from django.db.models import Q from django.http import HttpResponse, Http404 from django.shortcuts import get_object_or_404 from django.template.loader import select_template from django.views import View from django_tables2 import RequestConfig -from django.urls import reverse from django.shortcuts import redirect from apis_core.apis_labels.models import Label @@ -15,10 +13,8 @@ from apis_core.apis_relations.tables import ( get_generic_relations_table, LabelTableBase, -) # , EntityDetailViewLabelTable -from apis_core.helper_functions.utils import access_for_all +) from .models import TempEntityClass, BASE_URI -from .views import get_highlighted_texts def get_object_from_pk_or_uri(request, pk): @@ -45,13 +41,9 @@ def get_object_from_pk_or_uri(request, pk): return instance -class GenericEntitiesDetailView(UserPassesTestMixin, View): +class GenericEntitiesDetailView(View): # login_url = '/accounts/login/' - def test_func(self): - access = access_for_all(self, viewtype="detail") - return access - def get(self, request, *args, **kwargs): entity = kwargs["entity"].lower() pk = kwargs["pk"] @@ -109,7 +101,6 @@ def get(self, request, *args, **kwargs): ) ) object_lod = Uri.objects.filter(entity=instance) - object_texts, ann_proj_form = get_highlighted_texts(request, instance) object_labels = Label.objects.filter(temp_entity=instance) tb_label = LabelTableBase(data=object_labels, prefix=entity.title()[:2] + "L-") tb_label_open = request.GET.get("PL-page", None) @@ -121,26 +112,6 @@ def get(self, request, *args, **kwargs): "apis_entities/detail_views/entity_detail_generic.html", ] ) - tei = getattr(settings, "APIS_TEI_TEXTS", []) - if tei: - tei = set(tei) & set([x.kind.name for x in instance.text.all()]) - ceteicean_css = getattr(settings, "APIS_CETEICEAN_CSS", None) - ceteicean_js = getattr(settings, "APIS_CETEICEAN_JS", None) - openseadragon_js = getattr(settings, "APIS_OSD_JS", None) - openseadragon_img = getattr(settings, "APIS_OSD_IMG_PREFIX", None) - iiif_field = getattr(settings, "APIS_IIIF_WORK_KIND", None) - if iiif_field: - try: - if "{}".format(instance.kind) == "{}".format(iiif_field): - iiif = True - else: - iiif = False - except AttributeError: - iiif = False - else: - iiif = False - iiif_server = getattr(settings, "APIS_IIIF_SERVER", None) - iiif_info_json = instance.name try: no_merge_labels = [ x for x in object_labels if not x.label_type.name.startswith("Legacy") @@ -153,16 +124,6 @@ def get(self, request, *args, **kwargs): "right_card": side_bar, "no_merge_labels": no_merge_labels, "object_lables": object_labels, - "object_texts": object_texts, "object_lod": object_lod, - "tei": tei, - "ceteicean_css": ceteicean_css, - "ceteicean_js": ceteicean_js, - "iiif": iiif, - "openseadragon_js": openseadragon_js, - "openseadragon_img": openseadragon_img, - "iiif_field": iiif_field, - "iiif_info_json": iiif_info_json, - "iiif_server": iiif_server, } return HttpResponse(template.render(request=request, context=context)) From b484242b7ccf82eba32f3d3152780488906f9b10 Mon Sep 17 00:00:00 2001 From: csae8092 Date: Thu, 14 Dec 2023 13:05:23 +0100 Subject: [PATCH 2/6] wip detail view template --- .../detail_views/entity_detail_generic.html | 503 ++++++++---------- .../detail_views/person_detail_generic.html | 2 +- .../apis_entities/entity_edit_generic.html | 3 - templates/base.html | 2 + templates/partials/head.html | 2 - 5 files changed, 213 insertions(+), 299 deletions(-) diff --git a/apis_core/apis_entities/templates/apis_entities/detail_views/entity_detail_generic.html b/apis_core/apis_entities/templates/apis_entities/detail_views/entity_detail_generic.html index 1a1cdc5..77b38f9 100644 --- a/apis_core/apis_entities/templates/apis_entities/detail_views/entity_detail_generic.html +++ b/apis_core/apis_entities/templates/apis_entities/detail_views/entity_detail_generic.html @@ -2,311 +2,228 @@ {% load static %} {% load django_tables2 %} {% block title %} {{ object }} {% endblock %} -{% block scriptHeader %} -{{ block.super }} -{% if tei %} - - -{% endif %} -{% if iiif %} - -{% endif %} -{% endblock scriptHeader %} {% block content %} -
-
-
-
-
- {% if object.get_prev_url %} -

- - - + +
+ +
+ +
+

+ {% if object.get_listview_url %} + + {{ entity_type }}s + + {% else %} + {{ entity_type }}s + {% endif %} + {{ object }} + {% if user.is_authenticated %} + {% if object.get_edit_url %} + + + + -

{% endif %} -
-
-

- {% if object.get_listview_url %} - - {{ entity_type }}s + {% if object.get_delete_url %} + | + + + + + - {% else %} - {{ entity_type }}s - {% endif %} - {{ object }} - {% if user.is_authenticated %} - {% if object.get_edit_url %} - - - - - - - {% endif %} - {% if object.get_delete_url %} - | - - - - - - - {% endif %} - {% endif %} - {% if "apis_ampel" in APPS and show_ampel %} - {% include "ampel/ampel_inline_template.html" with instance=object %} - {% endif %} -

-
-
- {% if object.get_next_url %} -

- - - - - -

+ {% endif %} {% endif %} -
-
+

-
-
-
-
-
-

- General Info - - - - - - - - - - {% if entity_type != 'event' %}| TEI{% endif %} -

-
-
- {% block info-table %} - - - - - - - - - - - - - - - - - - {% if object.start_date or object.end_date %} - - - - - {% endif %} - {% if object.lat %} - - - - - {% endif %} -
- Titel - - {{ object.name }} -
- Labels - - {% for x in no_merge_labels %} -
  • - {{ x.label_type }}: {{ x.label }} -
  • - {% endfor %} -
    - ID - - {{ object.id }} -
    - Type - - {{ object.kind}} -
    - Date - - {% if object.start_date_written %} - {{ object.start_date_written }} - {% endif %} - {% if object.end_date %} - - {{ object.end_date_written }} - {% endif %} -
    - Lat/Lng - - {{ object.lat }} / {{ object.lng }} -
    - {% endblock info-table %} - {% block info-metadata %} - - - - - - - - - - {% if object.notes %} - - - - - {% endif %} - {% if object.references %} - - - - - {% endif %} -
    - Collection(s) - - {% for x in object.collection.all %} -
  • - {{ x }} -
  • - {% endfor %} -
    - Uri(s) - - {% for x in object.uri_set.all %} - {{ x }}
    - {% endfor %} -
    - Notes - - {{ object.notes }} -
    - References - - {{ object.references }} -
    - {% endblock info-metadata %} - {% block left-pane-additional %} - {% endblock left-pane-additional %} -
    -
    -
    -
    -
    -
    -

    Relations

    -
    -
    - {% block relations %} - {% for obj in right_card %} - {% if obj.1.data|length > 0 %} -
    -
    -

    {{ obj.0 }}

    -
    -
    -
    - {% render_table obj.1 %} -
    -
    -
    - {% endif %} - {% endfor %} - {% endblock relations %} -
    -
    -
    -
    +
    + {% if object.get_next_url %} +

    + + + + + +

    + {% endif %}
    -
    -
    -

    Texts

    + +
    +
    +

    + General Info + + + + + + + + + + {% if entity_type != 'event' %}| TEI{% endif %} +

    + {% block info-table %} + + + + + + + + + + + + + + + + + + {% if object.start_date or object.end_date %} + + + + + {% endif %} + {% if object.lat %} + + + + + {% endif %} +
    + Titel + + {{ object.name }} +
    + Labels + + {% for x in no_merge_labels %} +
  • + {{ x.label_type }}: {{ x.label }} +
  • + {% endfor %} +
    + ID + + {{ object.id }} +
    + Type + + {{ object.kind}} +
    + Date + + {% if object.start_date_written %} + {{ object.start_date_written }} + {% endif %} + {% if object.end_date %} + - {{ object.end_date_written }} + {% endif %} +
    + Lat/Lng + + {{ object.lat }} / {{ object.lng }} +
    + {% endblock info-table %} + {% block info-metadata %} + + + + + + + + + + {% if object.notes %} + + + + + {% endif %} + {% if object.references %} + + + + + {% endif %} +
    + Collection(s) + + {% for x in object.collection.all %} +
  • + {{ x }} +
  • + {% endfor %} +
    + Uri(s) + + {% for x in object.uri_set.all %} + {{ x }}
    + {% endfor %} +
    + Notes + + {{ object.notes }} +
    + References + + {{ object.references }} +
    + {% endblock info-metadata %} + {% block left-pane-additional %} + {% endblock left-pane-additional %}
    -
    - {% if object.text.all %} -
    - - Texts - - {% for x in object.text.all %} -
    -
    - {% if x.kind.name in tei %} -

    TEI

    - {% else %} -

    {{ x.kind }}

    - {% endif %} -
    - {% if x.kind.name in tei %} -
    - {{ x.text }} -
    -
    - -
    - {% else %} -
    - {{ x.text }} -
    - {% endif %} +
    +

    Relations

    + {% block relations %} + {% for obj in right_card %} + {% if obj.1.data|length > 0 %} +

    {{ obj.0 }}

    + +
    + {% render_table obj.1 %}
    - {% endfor %} -
    - {% else %} -
    - No text provided for this {{entity}} -
    - {% endif %} - {% if iiif %} -
    -
    -
    - {% endif %} + {% endif %} + {% endfor %} + {% endblock relations %}
    {% endblock content %} -{% block scripts %} - {{block.super}} - {% if tei %} - - {% endif %} - {% if iiif %} - - {% endif %} -{% endblock scripts %} + diff --git a/apis_core/apis_entities/templates/apis_entities/detail_views/person_detail_generic.html b/apis_core/apis_entities/templates/apis_entities/detail_views/person_detail_generic.html index 6a73ea7..e4a8d5a 100644 --- a/apis_core/apis_entities/templates/apis_entities/detail_views/person_detail_generic.html +++ b/apis_core/apis_entities/templates/apis_entities/detail_views/person_detail_generic.html @@ -1,5 +1,5 @@ {% extends "apis_entities/detail_views/entity_detail_generic.html" %} -{% block Titel %} {{ object.id }} {% endblock %} +{% block titel %} {{ object.id }} {% endblock %} {% block info-table %} diff --git a/apis_core/apis_entities/templates/apis_entities/entity_edit_generic.html b/apis_core/apis_entities/templates/apis_entities/entity_edit_generic.html index 22f764c..2b1bcdb 100644 --- a/apis_core/apis_entities/templates/apis_entities/entity_edit_generic.html +++ b/apis_core/apis_entities/templates/apis_entities/entity_edit_generic.html @@ -6,9 +6,6 @@ {% load django_tables2 %} {% load crispy_forms_tags %} -