From c1720b89e20380d392537b9eeb59a4df58a8b2ce Mon Sep 17 00:00:00 2001 From: csae8092 Date: Fri, 8 Dec 2023 15:46:11 +0100 Subject: [PATCH] done with uri list view --- apis_core/apis_entities/list_view_event.py | 18 ++++--------- apis_core/apis_entities/list_view_uris.py | 30 +++++++++++++++------- apis_core/apis_metainfo/filters.py | 26 ------------------- apis_core/apis_metainfo/forms.py | 18 +------------ apis_core/apis_metainfo/tables.py | 22 ---------------- apis_core/apis_metainfo/views.py | 20 ++------------- static/css/style.css | 2 +- 7 files changed, 30 insertions(+), 106 deletions(-) delete mode 100644 apis_core/apis_metainfo/filters.py diff --git a/apis_core/apis_entities/list_view_event.py b/apis_core/apis_entities/list_view_event.py index 605e9a1..37c2b9e 100644 --- a/apis_core/apis_entities/list_view_event.py +++ b/apis_core/apis_entities/list_view_event.py @@ -17,7 +17,7 @@ PersonEventRelation, EventEventRelation, EventType, - EventWorkRelation + EventWorkRelation, ) from apis_core.helper_functions.utils import get_child_classes @@ -40,7 +40,8 @@ for x in PersonEventRelation.objects.all() ] EVENT_PLACE_RELATION_CHOICES = [ - (f"{x.id}", f"{x.label_reverse} (ID: {x.id})") for x in PlaceEventRelation.objects.all() + (f"{x.id}", f"{x.label_reverse} (ID: {x.id})") + for x in PlaceEventRelation.objects.all() ] EVENT_EVENT_RELATION_CHOICES = [ (f"{x.id}", f"{x} (ID: {x.id})") for x in EventEventRelation.objects.all() @@ -165,10 +166,7 @@ class EventTable(tables.Table): transform=lambda x: x.related_place, filter=lambda qs: qs.filter( relation_type__in=get_child_classes( - [ - 1202, - 1369 - ], + [1202, 1369], PlaceEventRelation, ) ), # ToDo: don't hardcode the realtion type id here @@ -185,13 +183,7 @@ class EventListView(GenericListView): filter_class = EventListFilter formhelper_class = EventFilterFormHelper table_class = EventTable - init_columns = [ - "id", - "name", - "start_date", - "kind", - "placeevent_set" - ] + init_columns = ["id", "name", "start_date", "kind", "placeevent_set"] exclude_columns = excluded_cols enable_merge = False template_name = "apis_entities/list_views/list.html" diff --git a/apis_core/apis_entities/list_view_uris.py b/apis_core/apis_entities/list_view_uris.py index d231a40..96287c7 100644 --- a/apis_core/apis_entities/list_view_uris.py +++ b/apis_core/apis_entities/list_view_uris.py @@ -11,12 +11,21 @@ class UriTable(tables.Table): - id = tables.LinkColumn(verbose_name="ID") - uri = tables.columns.Column(verbose_name="URI") + id = tables.LinkColumn() + entity = tables.TemplateColumn( + "{{ record.entity }}", + orderable=True, + verbose_name="related Entity", + ) + ent_type = tables.TemplateColumn( + "{{ record.entity.get_child_class }}", + orderable=False, + verbose_name="Entity Type", + ) class Meta: model = Uri - sequence = ("id", "uri", "domain") + sequence = ("id", "uri") attrs = {"class": "table table-responsive table-hover"} @@ -33,6 +42,7 @@ def __init__(self, *args, **kwargs): "Eigenschaften", "uri", "domain", + "entity__name", css_id="more", ) ) @@ -50,18 +60,20 @@ class UriListFilter(django_filters.FilterSet): label="Domain", help_text="eingegebene Zeichenkette muss in der Domain enthalten sein", ) + entity__name = django_filters.CharFilter( + lookup_expr="icontains", + help_text=Uri._meta.get_field("entity").help_text, + label=Uri._meta.get_field("entity").verbose_name, + ) + class UriListView(GenericListView): model = Uri filter_class = UriListFilter formhelper_class = UriFilterFormHelper table_class = UriTable - init_columns = [ - "id", - "uri", - "domain", - ] - exclude_columns = [] + init_columns = ["id", "uri", "domain", "entity"] + exclude_columns = ["loaded", "loaded_time", "rdf_link"] enable_merge = False template_name = "apis_entities/list_views/list.html" verbose_name = "Uris" diff --git a/apis_core/apis_metainfo/filters.py b/apis_core/apis_metainfo/filters.py deleted file mode 100644 index bb328bf..0000000 --- a/apis_core/apis_metainfo/filters.py +++ /dev/null @@ -1,26 +0,0 @@ -import django_filters - -from .models import * - - -class UriListFilter(django_filters.FilterSet): - - uri = django_filters.CharFilter( - lookup_expr="icontains", - help_text=Uri._meta.get_field("uri").help_text, - label=Uri._meta.get_field("uri").verbose_name, - ) - domain = django_filters.CharFilter( - lookup_expr="icontains", - help_text=Uri._meta.get_field("domain").help_text, - label=Uri._meta.get_field("domain").verbose_name, - ) - entity__name = django_filters.CharFilter( - lookup_expr="icontains", - help_text=Uri._meta.get_field("entity").help_text, - label=Uri._meta.get_field("entity").verbose_name, - ) - - class Meta: - model = Uri - fields = "__all__" diff --git a/apis_core/apis_metainfo/forms.py b/apis_core/apis_metainfo/forms.py index 5351d0c..1211d49 100644 --- a/apis_core/apis_metainfo/forms.py +++ b/apis_core/apis_metainfo/forms.py @@ -1,7 +1,5 @@ -from crispy_forms.bootstrap import AccordionGroup -from crispy_bootstrap5.bootstrap5 import BS5Accordion from crispy_forms.helper import FormHelper -from crispy_forms.layout import Submit, Layout +from crispy_forms.layout import Submit from dal import autocomplete from django import forms @@ -28,17 +26,3 @@ def __init__(self, *args, **kwargs): self.helper.add_input( Submit("submit", "save"), ) - - -class UriFilterFormHelper(FormHelper): - def __init__(self, *args, **kwargs): - super(UriFilterFormHelper, self).__init__(*args, **kwargs) - self.helper = FormHelper() - self.form_class = "genericFilterForm" - self.form_method = "GET" - self.form_tag = False - self.layout = Layout( - "uri", - "domain", - "entity__name", - ) diff --git a/apis_core/apis_metainfo/tables.py b/apis_core/apis_metainfo/tables.py index 66c9025..2c1befe 100644 --- a/apis_core/apis_metainfo/tables.py +++ b/apis_core/apis_metainfo/tables.py @@ -1,9 +1,6 @@ -import django_tables2 as tables from django.db.models import F from django.utils.html import format_html -from .models import Uri - # generic order_FOO methods for start_date_written and end_date_written to be used in all kinds of tables where a queryset is loaded # whose model has start_date_written and end_date_written. These methods order the *_date_written by their corresponding @@ -98,22 +95,3 @@ def generic_render_end_date_written(self, record, value): var_start_date=record.end_start_date, var_end_date=record.end_end_date, ) - - -class UriTable(tables.Table): - id = tables.LinkColumn() - entity = tables.TemplateColumn( - "{{ record.entity }}", - orderable=True, - verbose_name="related Entity", - ) - ent_type = tables.TemplateColumn( - "{{ record.entity.get_child_class }}", - orderable=False, - verbose_name="Entity Type", - ) - - class Meta: - model = Uri - sequence = ("id", "uri") - attrs = {"class": "table table-responsive table-hover"} diff --git a/apis_core/apis_metainfo/views.py b/apis_core/apis_metainfo/views.py index 3cf9bbc..5cb5d3b 100644 --- a/apis_core/apis_metainfo/views.py +++ b/apis_core/apis_metainfo/views.py @@ -6,11 +6,9 @@ from django.views.generic.detail import DetailView from django.views.generic.edit import DeleteView -from browsing.browsing_utils import GenericListView, BaseCreateView, BaseUpdateView -from .filters import UriListFilter -from .forms import UriFilterFormHelper, UriForm +from browsing.browsing_utils import BaseCreateView, BaseUpdateView +from .forms import UriForm from .models import Uri -from .tables import UriTable PROJECT_NAME = settings.PROJECT_NAME @@ -28,20 +26,6 @@ def beacon(request): return HttpResponse(result, content_type="text/plain") -class UriListView(GenericListView): - model = Uri - filter_class = UriListFilter - formhelper_class = UriFilterFormHelper - table_class = UriTable - init_columns = [ - "id", - "uri", - "entity", - ] - exclude_columns = ["loaded", "loaded_time", "rdf_link"] - enable_merge = False - - class UriDetailView(DetailView): model = Uri template_name = "apis_metainfo/uri_detail.html" diff --git a/static/css/style.css b/static/css/style.css index ffda65d..dd839e3 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -6,7 +6,7 @@ --work: #668cb9; --event: #5c8c7c; --institution: #c57f7f; - --uri: #e7e1bf; + --uri: #e80d0d; }