Skip to content

Commit

Permalink
Merge pull request #123 from arthur-schnitzler/main
Browse files Browse the repository at this point in the history
fix for tei-relation; and test
  • Loading branch information
csae8092 authored Jan 13, 2025
2 parents d5d1ce6 + 1faa7e2 commit 7253138
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions network/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ def test_05_calendar_data(self):
url = reverse("network:calender_data")
response = client.get(url)
self.assertEqual(response.status_code, 200)

def test_06_tei_relation(self):
url = reverse("network:tei")
response = client.get(url)
self.assertEqual(response.status_code, 200)
4 changes: 2 additions & 2 deletions network/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
edges_as_geojson,
edges_as_calender,
MapView,
get_person_person_tei,
get_realtions_as_tei,
)


Expand All @@ -20,5 +20,5 @@
path("calender-data/", edges_as_calender, name="calender_data"),
path("calender/", CalenderView.as_view(), name="calender"),
path("map/", MapView.as_view(), name="map"),
path("tei/", get_person_person_tei, name="tei"),
path("tei/", get_realtions_as_tei, name="tei"),
]
8 changes: 4 additions & 4 deletions network/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@
"""


def get_person_person_tei(request):
def get_realtions_as_tei(request):
doc = TeiReader(tei_template)
root = doc.any_xpath(".//tei:listRelation")[0]
query_params = request.GET
qs = EdgeListFilter(query_params, queryset=Edge.objects.all()).qs
for x in qs:
relation = ET.SubElement(root, "{http://www.tei-c.org/ns/1.0}relation")
print(x.edge_label)
relation.attrib["name"] = slugify(x.edge_label)
relation.attrib["active"] = f"#pmb{x.source_id}"
relation.attrib["passive"] = f"#pmb{x.target_id}"
relation.attrib["active"] = f"#{x.source_id}"
relation.attrib["passive"] = f"#{x.target_id}"
if x.start_date:
relation.attrib["from-iso"] = f"{x.start_date}"
if x.end_date:
relation.attrib["to-iso"] = f"{x.end_date}"
relation.attrib["n"] = f"{x.target_label}{x.edge_label}{x.source_label}"
relation.attrib["type"] = x.edge_kind
xml_str = doc.return_string()
return HttpResponse(xml_str, content_type="application/xml")

Expand Down

0 comments on commit 7253138

Please sign in to comment.