diff --git a/apis_core/apis_entities/tests.py b/apis_core/apis_entities/tests.py
index b46ed07..e816910 100644
--- a/apis_core/apis_entities/tests.py
+++ b/apis_core/apis_entities/tests.py
@@ -26,6 +26,8 @@
MODELS = list(apps.all_models["apis_entities"].values())
+RELATION_MODELS = list(apps.all_models["apis_relations"].values())
+
class EntitiesTestCase(TestCase):
fixtures = [
@@ -70,6 +72,16 @@ def test_001_list_view(self):
response = client.get(url)
self.assertEqual(response.status_code, 200)
+ def test_001a_relation_list_view(self):
+ for x in RELATION_MODELS:
+ try:
+ url = x.get_listview_url()
+ except AttributeError:
+ url = False
+ if url:
+ response = client.get(url)
+ self.assertEqual(response.status_code, 200)
+
def test_002_detailviews(self):
for x in MODELS:
item = x.objects.first()
diff --git a/apis_core/apis_relations/models.py b/apis_core/apis_relations/models.py
index a356bc6..80e1274 100644
--- a/apis_core/apis_relations/models.py
+++ b/apis_core/apis_relations/models.py
@@ -337,7 +337,21 @@ def get_related_entity_field_nameb(cls):
class PersonPerson(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return reverse_lazy("apis:apis_relations:person_person")
+
+ @classmethod
+ def get_icon(self):
+ return "bi bi-people apis-person"
+
+ @classmethod
+ def get_second_icon(self):
+ return "bi bi-people apis-person"
+
+ @classmethod
+ def get_color(self):
+ return "#720e07"
class PersonPlace(AbstractRelation):
@@ -359,15 +373,33 @@ def get_color(self):
class PersonInstitution(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return None
class PersonEvent(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return None
class PersonWork(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return reverse_lazy("apis:apis_relations:person_work")
+
+ @classmethod
+ def get_icon(self):
+ return "bi bi-people apis-person"
+
+ @classmethod
+ def get_second_icon(self):
+ return "bi bi-book apis-work"
+
+ @classmethod
+ def get_color(self):
+ return "#720e07"
#######################################################################
@@ -378,19 +410,27 @@ class PersonWork(AbstractRelation):
class InstitutionInstitution(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return None
class InstitutionPlace(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return None
class InstitutionEvent(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return None
class InstitutionWork(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return None
#######################################################################
@@ -401,15 +441,21 @@ class InstitutionWork(AbstractRelation):
class PlacePlace(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return None
class PlaceEvent(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return None
class PlaceWork(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return None
#######################################################################
@@ -420,11 +466,15 @@ class PlaceWork(AbstractRelation):
class EventEvent(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return None
class EventWork(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return None
#######################################################################
@@ -435,4 +485,6 @@ class EventWork(AbstractRelation):
class WorkWork(AbstractRelation):
- pass
+ @classmethod
+ def get_listview_url(self):
+ return None
diff --git a/apis_core/apis_relations/person_person_relation_views.py b/apis_core/apis_relations/person_person_relation_views.py
new file mode 100644
index 0000000..7575da6
--- /dev/null
+++ b/apis_core/apis_relations/person_person_relation_views.py
@@ -0,0 +1,139 @@
+from browsing.browsing_utils import GenericListView
+from dal import autocomplete
+from crispy_forms.helper import FormHelper
+from crispy_forms.layout import Layout
+from django.urls import reverse_lazy
+from django_filters import FilterSet, ModelMultipleChoiceFilter, RangeFilter
+import django_tables2 as tables
+
+from apis_core.apis_entities.models import Person
+from apis_core.apis_vocabularies.models import PersonPersonRelation
+
+from .models import PersonPerson
+
+
+excluded_cols = [
+ "start_start_date",
+ "start_end_date",
+ "end_start_date",
+ "end_end_date",
+ "status",
+ "source",
+ "published",
+ "tempentityclass_ptr",
+ "review",
+]
+
+
+class PersonPersonListFilter(FilterSet):
+ related_persona = ModelMultipleChoiceFilter(
+ queryset=Person.objects.all(),
+ help_text="Wähle eine oder mehrere Personen",
+ label="Personen",
+ widget=autocomplete.Select2Multiple(
+ url=reverse_lazy(
+ "apis:apis_entities:generic_entities_autocomplete",
+ kwargs={"entity": "person"},
+ ),
+ attrs={"data-html": True},
+ ),
+ )
+ related_personb = ModelMultipleChoiceFilter(
+ queryset=Person.objects.all(),
+ help_text="Wähle einen oder mehrere Persone",
+ label="Persone",
+ widget=autocomplete.Select2Multiple(
+ url=reverse_lazy(
+ "apis:apis_entities:generic_entities_autocomplete",
+ kwargs={"entity": "person"},
+ ),
+ attrs={"data-html": True},
+ ),
+ )
+ relation_type = ModelMultipleChoiceFilter(
+ queryset=PersonPersonRelation.objects.all().order_by("name"),
+ label="Art der Beziehung",
+ help_text="Mehrfachauswahl möglich",
+ )
+ start_date__year = RangeFilter(
+ label="Anfang (Jahr)",
+ )
+ end_date__year = RangeFilter(
+ label="Ende (Jahr)",
+ )
+
+ class Meta:
+ model = PersonPerson
+ fields = [
+ "related_persona",
+ "related_personb",
+ "relation_type",
+ "start_date__year",
+ "end_date__year",
+ ]
+
+
+class PersonPersonFormHelper(FormHelper):
+ def __init__(self, *args, **kwargs):
+ super(PersonPersonFormHelper, self).__init__(*args, **kwargs)
+ self.helper = FormHelper()
+ self.form_class = "genericFilterForm"
+ self.form_method = "GET"
+ self.form_tag = False
+ self.layout = Layout(
+ "related_persona",
+ "related_personb",
+ "relation_type",
+ "start_date__year",
+ "end_date__year",
+ )
+
+
+class PersonPersonTable(tables.Table):
+ related_persona = tables.TemplateColumn(
+ """{{ record.related_persona }}""",
+ verbose_name="Person",
+ )
+ related_personb = tables.TemplateColumn(
+ """{{ record.related_personb }}""",
+ verbose_name="Person",
+ )
+ relation_type = tables.TemplateColumn(
+ "{{ record.relation_type }}", verbose_name="Art der Beziehung"
+ )
+ start_date_written = tables.TemplateColumn(
+ "{% if record.start_date_written %} {{ record.start_date_written }} {% endif %}",
+ verbose_name="Start",
+ )
+ end_date_written = tables.TemplateColumn(
+ "{% if record.end_date_written %} {{ record.end_date_written }} {% endif %}",
+ verbose_name="End",
+ )
+
+ class Meta:
+ model = PersonPerson
+ sequence = (
+ "id",
+ "related_persona",
+ "relation_type",
+ "related_personb",
+ "start_date_written",
+ )
+
+
+class PersonPersonListView(GenericListView):
+ model = PersonPerson
+ filter_class = PersonPersonListFilter
+ formhelper_class = PersonPersonFormHelper
+ table_class = PersonPersonTable
+ init_columns = [
+ "start_date_written",
+ "end_date_written",
+ "related_persona",
+ "relation_type",
+ "related_personb",
+ ]
+ verbose_name = "Personen und Personen"
+ exclude_columns = excluded_cols
+ enable_merge = False
+ template_name = "apis_relations/list_view.html"
diff --git a/apis_core/apis_relations/relation_views.py b/apis_core/apis_relations/person_place_relation_views.py
similarity index 100%
rename from apis_core/apis_relations/relation_views.py
rename to apis_core/apis_relations/person_place_relation_views.py
diff --git a/apis_core/apis_relations/person_work_relation_views.py b/apis_core/apis_relations/person_work_relation_views.py
new file mode 100644
index 0000000..b8cd27d
--- /dev/null
+++ b/apis_core/apis_relations/person_work_relation_views.py
@@ -0,0 +1,139 @@
+from browsing.browsing_utils import GenericListView
+from dal import autocomplete
+from crispy_forms.helper import FormHelper
+from crispy_forms.layout import Layout
+from django.urls import reverse_lazy
+from django_filters import FilterSet, ModelMultipleChoiceFilter, RangeFilter
+import django_tables2 as tables
+
+from apis_core.apis_entities.models import Person, Work
+from apis_core.apis_vocabularies.models import PersonWorkRelation
+
+from .models import PersonWork
+
+
+excluded_cols = [
+ "start_start_date",
+ "start_end_date",
+ "end_start_date",
+ "end_end_date",
+ "status",
+ "source",
+ "published",
+ "tempentityclass_ptr",
+ "review",
+]
+
+
+class PersonWorkListFilter(FilterSet):
+ related_person = ModelMultipleChoiceFilter(
+ queryset=Person.objects.all(),
+ help_text="Wähle eine oder mehrere Personen",
+ label="Personen",
+ widget=autocomplete.Select2Multiple(
+ url=reverse_lazy(
+ "apis:apis_entities:generic_entities_autocomplete",
+ kwargs={"entity": "person"},
+ ),
+ attrs={"data-html": True},
+ ),
+ )
+ related_work = ModelMultipleChoiceFilter(
+ queryset=Work.objects.all(),
+ help_text="Wähle einen oder mehrere Werke",
+ label="Werke",
+ widget=autocomplete.Select2Multiple(
+ url=reverse_lazy(
+ "apis:apis_entities:generic_entities_autocomplete",
+ kwargs={"entity": "work"},
+ ),
+ attrs={"data-html": True},
+ ),
+ )
+ relation_type = ModelMultipleChoiceFilter(
+ queryset=PersonWorkRelation.objects.all().order_by("name"),
+ label="Art der Beziehung",
+ help_text="Mehrfachauswahl möglich",
+ )
+ start_date__year = RangeFilter(
+ label="Anfang (Jahr)",
+ )
+ end_date__year = RangeFilter(
+ label="Ende (Jahr)",
+ )
+
+ class Meta:
+ model = PersonWork
+ fields = [
+ "related_person",
+ "related_work",
+ "relation_type",
+ "start_date__year",
+ "end_date__year",
+ ]
+
+
+class PersonWorkFormHelper(FormHelper):
+ def __init__(self, *args, **kwargs):
+ super(PersonWorkFormHelper, self).__init__(*args, **kwargs)
+ self.helper = FormHelper()
+ self.form_class = "genericFilterForm"
+ self.form_method = "GET"
+ self.form_tag = False
+ self.layout = Layout(
+ "related_person",
+ "related_work",
+ "relation_type",
+ "start_date__year",
+ "end_date__year",
+ )
+
+
+class PersonWorkTable(tables.Table):
+ related_person = tables.TemplateColumn(
+ """{{ record.related_person }}""",
+ verbose_name="Person",
+ )
+ related_work = tables.TemplateColumn(
+ """{{ record.related_work }}""",
+ verbose_name="Werk",
+ )
+ relation_type = tables.TemplateColumn(
+ "{{ record.relation_type }}", verbose_name="Art der Beziehung"
+ )
+ start_date_written = tables.TemplateColumn(
+ "{% if record.start_date_written %} {{ record.start_date_written }} {% endif %}",
+ verbose_name="Start",
+ )
+ end_date_written = tables.TemplateColumn(
+ "{% if record.end_date_written %} {{ record.end_date_written }} {% endif %}",
+ verbose_name="End",
+ )
+
+ class Meta:
+ model = PersonWork
+ sequence = (
+ "id",
+ "related_person",
+ "relation_type",
+ "related_work",
+ "start_date_written",
+ )
+
+
+class PersonWorkListView(GenericListView):
+ model = PersonWork
+ filter_class = PersonWorkListFilter
+ formhelper_class = PersonWorkFormHelper
+ table_class = PersonWorkTable
+ init_columns = [
+ "start_date_written",
+ "end_date_written",
+ "related_person",
+ "relation_type",
+ "related_work",
+ ]
+ verbose_name = "Personen und Werke"
+ exclude_columns = excluded_cols
+ enable_merge = False
+ template_name = "apis_relations/list_view.html"
diff --git a/apis_core/apis_relations/urls.py b/apis_core/apis_relations/urls.py
index f8a1342..2a4ae99 100644
--- a/apis_core/apis_relations/urls.py
+++ b/apis_core/apis_relations/urls.py
@@ -1,16 +1,28 @@
from django.urls import path
from . import views
-from . import relation_views
+from . import person_place_relation_views
+from . import person_work_relation_views
+from . import person_person_relation_views
app_name = "apis_relations"
urlpatterns = [
path(
"person-place/",
- relation_views.PersonPlaceListView.as_view(),
+ person_place_relation_views.PersonPlaceListView.as_view(),
name="person_place",
),
+ path(
+ "person-work/",
+ person_work_relation_views.PersonWorkListView.as_view(),
+ name="person_work",
+ ),
+ path(
+ "person-person/",
+ person_person_relation_views.PersonPersonListView.as_view(),
+ name="person_person",
+ ),
path(
"delete//",
views.delete_relation_view,
diff --git a/templates/partials/navbar.html b/templates/partials/navbar.html
index f3f54ea..95eef23 100644
--- a/templates/partials/navbar.html
+++ b/templates/partials/navbar.html
@@ -83,6 +83,20 @@
+
+
+
+ Personen und Werke
+
+
+
+
+
+
+ Personen und Personen
+
+
+
{% if user.is_authenticated %}