Skip to content

Commit

Permalink
done with uri list view
Browse files Browse the repository at this point in the history
  • Loading branch information
csae8092 committed Dec 8, 2023
1 parent 145f137 commit c1720b8
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 106 deletions.
18 changes: 5 additions & 13 deletions apis_core/apis_entities/list_view_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
PersonEventRelation,
EventEventRelation,
EventType,
EventWorkRelation
EventWorkRelation,
)
from apis_core.helper_functions.utils import get_child_classes

Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down
30 changes: 21 additions & 9 deletions apis_core/apis_entities/list_view_uris.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"<a href='{{ record.entity.get_absolute_url }}'>{{ record.entity }}</a>",
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"}


Expand All @@ -33,6 +42,7 @@ def __init__(self, *args, **kwargs):
"Eigenschaften",
"uri",
"domain",
"entity__name",
css_id="more",
)
)
Expand All @@ -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"
Expand Down
26 changes: 0 additions & 26 deletions apis_core/apis_metainfo/filters.py

This file was deleted.

18 changes: 1 addition & 17 deletions apis_core/apis_metainfo/forms.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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",
)
22 changes: 0 additions & 22 deletions apis_core/apis_metainfo/tables.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
"<a href='{{ record.entity.get_absolute_url }}'>{{ record.entity }}</a>",
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"}
20 changes: 2 additions & 18 deletions apis_core/apis_metainfo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
--work: #668cb9;
--event: #5c8c7c;
--institution: #c57f7f;
--uri: #e7e1bf;
--uri: #e80d0d;
}


Expand Down

0 comments on commit c1720b8

Please sign in to comment.