Skip to content

Commit

Permalink
Merge pull request #112 from arthur-schnitzler/main
Browse files Browse the repository at this point in the history
code updates
  • Loading branch information
csae8092 authored Nov 26, 2024
2 parents da7ec6d + c5a3d78 commit 3e70c05
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ <h2>
</div>
<div class="col-md-1"></div>
<div class="col-md-7">
<h3 class="text-center mt-5">Beziehungen</h3>
<h3 class="text-center mt-5">
Beziehungen
<a href="{% url 'network:edges_browse' %}?node_id={{ object.id }}" title="Alle Relationen von {{ object }}"><i class="ps-2 bi bi-box-arrow-up-right" aria-hidden="true"><span class="visually-hidden">Alle Relationen von {{ object }}</span></i></a>
<a href="{% url 'network:network' %}?node_id={{ object.id }}&format=cosmograph" title="Alle Relationen von {{ object }} als Netzwerk"><i class="ps-2 bi bi-share" aria-hidden="true"><span class="visually-hidden">Alle Relationen von {{ object }} als Netzwerk</span></i></a>
</h3>
{% block relations %}
{% for obj in right_card %}
{% if obj.1.data|length > 0 %}
Expand Down
5 changes: 0 additions & 5 deletions dumper/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,3 @@ def test_09_imprint(self):
url = reverse("dumper:export")
response = client.get(url)
self.assertEqual(response.status_code, 200)

def test_10_network(self):
url = reverse("dumper:network")
response = client.get(url)
self.assertEqual(response.status_code, 200)
1 change: 0 additions & 1 deletion dumper/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
urlpatterns = [
path("", views.HomePageView.as_view(), name="home"),
path("about/", views.AboutView.as_view(), name="about"),
path("network/", views.NetworkView.as_view(), name="network"),
path("export/", views.ExportView.as_view(), name="export"),
path("imprint/", views.ImprintView.as_view(), name="imprint"),
path("login/", views.user_login, name="user_login"),
Expand Down
24 changes: 0 additions & 24 deletions dumper/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import requests
from typing import Any


from django.apps import apps
from django.conf import settings
from django.contrib.auth import authenticate, login, logout
from django.http import HttpResponse, HttpResponseRedirect
Expand Down Expand Up @@ -32,27 +29,6 @@ class ExportView(TemplateView):
template_name = "dumper/export.html"


class NetworkView(TemplateView):
template_name = "dumper/network.html"

def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
MODELS = list(apps.all_models["apis_entities"].values())
model_list = []
for x in MODELS:
try:
item = {
"color": x.get_color(),
"icon": x.get_icon(),
"name": x._meta.verbose_name,
}
except AttributeError:
continue
model_list.append(item)
context["model_list"] = model_list
return context


class ImprintView(TemplateView):
template_name = "dumper/imprint.html"

Expand Down
1 change: 1 addition & 0 deletions fixtures/network.json

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions network/templates/network/list_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,12 @@ <h1 class="display-1 text-center">
<i class="bi bi-share"> Beziehungen</i>
</h1>
<div class="row">
<div class="col-md-6 text-center">
<h2>Download</h2>
<div class="btn-group" role="group" class="text-end">
<a type="button" class="btn btn-outline-primary" href="{% url 'network:data' %}{% querystring %}&format=csv">CSV</a>
<a type="button" class="btn btn-outline-primary" href="{% url 'network:data' %}{% querystring %}&format=cosmograph">JSON</a>
<a type="button" class="btn btn-outline-primary" href="{% url 'network:network' %}{% querystring %}&format=cosmograph">Als Netzwerk</a>
</div>
</div>
<div class="col-md-6 text-center">
<h2>Visualize</h2>
<div class="btn-group" role="group" class="text-end">
<a type="button" class="btn btn-outline-primary" href="{% url 'dumper:network' %}{% querystring %}&format=cosmograph">Als Nezwerk</a>
</div>
</div>
</div>

<div class="row pt-4">
<div class="col-md-4" id="searchpane">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
{% load static %}
{% load django_vite %}

{% block title %}Vite{% endblock %}
{% block scripts %}
{% vite_hmr_client %}
{% vite_asset 'js/main.js' %}
{% endblock scripts %}
{% block title %}Netzwerk{% endblock %}


{% block content %}
<div class="container-fluid p3-4">
Expand All @@ -31,4 +28,11 @@ <h1 class="display-3 text-center">Netzwerk aller Verbindungen</h1>
</div>
<div id="app" class="pt-2 pe-2 ps-2 pb-2" style="height: 750px;"></div>
</div>
{% endblock %}

{% endblock %}

{% block scripts2 %}
{% vite_hmr_client %}
{% vite_asset 'js/main.js' %}
{% endblock scripts2 %}

31 changes: 29 additions & 2 deletions network/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# from django.test import TestCase
from django.apps import apps
from django.conf import settings
from django.test import Client, TestCase
from django.urls import reverse

# Create your tests here.

client = Client()
USER = {"username": "testuser", "password": "password", "is_active": True}
BAHR = {"name": "Schnitzler", "first_name": "Hermann", "start_date_written": "1900"}

ENTITY_TYPES = ["person", "place", "event", "work", "institution"]

MODELS = list(apps.all_models["apis_entities"].values())
MEDIA_ROOT = settings.MEDIA_ROOT


class DumperTestCase(TestCase):
fixtures = [
"network.json",
]

def test_01_network(self):
url = reverse("network:network")
response = client.get(url)
self.assertEqual(response.status_code, 200)

def test_02_edge_list_view(self):
url = reverse("network:edges_browse")
response = client.get(url)
self.assertEqual(response.status_code, 200)
3 changes: 2 additions & 1 deletion network/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from django.urls import path
from network.views import EdgeListViews, network_data
from network.views import EdgeListViews, network_data, NetworkView


app_name = "network"
urlpatterns = [
path("edges/", EdgeListViews.as_view(), name="edges_browse"),
path("csv/", network_data, name="data"),
path("network/", NetworkView.as_view(), name="network"),
]
25 changes: 24 additions & 1 deletion network/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pandas as pd
import json
import pandas as pd
from django.apps import apps
from django.http import HttpResponse, JsonResponse
from django.views.generic import TemplateView


from browsing.browsing_utils import (
Expand All @@ -13,6 +15,27 @@
from network.tables import EdgeTable


class NetworkView(TemplateView):
template_name = "network/network.html"

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
MODELS = list(apps.all_models["apis_entities"].values())
model_list = []
for x in MODELS:
try:
item = {
"color": x.get_color(),
"icon": x.get_icon(),
"name": x._meta.verbose_name,
}
except AttributeError:
continue
model_list.append(item)
context["model_list"] = model_list
return context


class EdgeListViews(GenericListView):
model = Edge
filter_class = EdgeListFilter
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"vite": "^5.1.4"
},
"dependencies": {
"@cosmograph/cosmos": "^1.6.1",
"d3": "^7.9.0"
"@cosmograph/cosmos": "^1.6.1"
}
}

0 comments on commit 3e70c05

Please sign in to comment.