Skip to content

Commit

Permalink
Merge pull request #52 from arthur-schnitzler/113-fix-json+net-render…
Browse files Browse the repository at this point in the history
…er-for-same-same-relations

113 fix json+net renderer for same same relations
  • Loading branch information
csae8092 authored Jan 24, 2024
2 parents 7393153 + 4927b2d commit 8c76007
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 30 deletions.
4 changes: 2 additions & 2 deletions apis_core/api_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def render(self, data, media_type=None, renderer_context=None):
rel2 = re.match("^{}[a-z]*".format(r2), rel)
if rel2:
source = r
elif r.endswith("A"):
elif r.endswith("a"):
source = r
elif r.endswith("B"):
elif r.endswith("b"):
target = r
rel2 = re.match("^[a-z]*?{}$".format(r2), rel)
if rel2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h2>

<div class="row">
<div class="col-md-5">
<h3 class="text-center">
<h4 class="text-left">
<a href="{{ object.get_api_url }}">
<i class="bi bi-database" title="zur API-Ansicht der Entität"></i>
</a>
Expand Down Expand Up @@ -115,7 +115,7 @@ <h3 class="text-center">
{% if object.start_date or object.end_date %}
<tr>
<th>
Date
Datum
</th>
<td>
{% if object.start_date_written %}
Expand All @@ -130,7 +130,7 @@ <h3 class="text-center">
{% if object.lat %}
<tr>
<th>
Lat/Lng
Länge/Breite
</th>
<td>
{{ object.lat }} / {{ object.lng }}
Expand All @@ -142,8 +142,8 @@ <h3 class="text-center">
{% block info-metadata %}
<table class="table">
<tr>
<th>
Uri(s)
<th class="left-width">
URI
</th>
<td>
{% for x in object.uri_set.all %}
Expand All @@ -158,21 +158,20 @@ <h3 class="text-center">
{% if object.collection.all %}
<tr>
<th>
Collection(s)
Sammlungen
</th>
<td>
{% for x in object.collection.all %}
<li>
{{ x }}
</li>
{{ x }}<br />
{% endfor %}

</td>
</tr>
{% endif %}
{% if object.notes %}
<tr>
<th>
Notes
Anmerkungen
</th>
<td>
{{ object.notes }}
Expand All @@ -182,7 +181,7 @@ <h3 class="text-center">
{% if object.references %}
<tr>
<th>
References
Belege
</th>
<td>
{{ object.references }}
Expand All @@ -195,13 +194,13 @@ <h3 class="text-center">
{% endblock left-pane-additional %}
</div>
<div class="col-md-7">
<h3 class="text-center">Relations</h3>
<h3 class="text-center">Beziehungen</h3>
{% block relations %}
{% for obj in right_card %}
{% if obj.1.data|length > 0 %}
<h4 > {{ obj.0 }}</h4>

<div id="tab_{{ obj.2 }}" >
<div id="tab_{{ obj.2 }}" style="margin-bottom: 50px;">
{% render_table obj.1 %}
</div>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block info-table %}
<table class="table">
<tr>
<th>
<th class="left-width">
Name
</th>
<td>
Expand All @@ -13,7 +13,7 @@
{% if no_merge_labels %}
<tr>
<th>
Alternative Namen
anderer Name
</th>
<td>
{% for x in no_merge_labels %}
Expand Down Expand Up @@ -44,7 +44,7 @@
{% if object.start_date or object.end_date %}
<tr>
<th>
Lifespan
Lebensspanne
</th>
<td>
{% if object.start_date %}
Expand All @@ -59,7 +59,7 @@
{% if object.profession.all %}
<tr>
<th>
Professions
Berufe
</th>
<td>
{% for prof in object.profession.all %}
Expand Down
8 changes: 2 additions & 6 deletions apis_core/apis_entities/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,8 @@ def test_020_api_list_view(self):
r = client.get(value)
self.assertTrue(r.status_code, 200)
if key.startswith("relation"):
try:
r = client.get(f"{value}?format=json%2Bnet")
self.assertTrue(r.status_code, 200)
except Exception as e:
print(value, e)
continue
r = client.get(f"{value}?format=json%2Bnet")
self.assertTrue(r.status_code, 200)

def test_021_api_detail_view(self):
item = Person.objects.last()
Expand Down
8 changes: 4 additions & 4 deletions apis_core/entity_detail_generic.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h2>
<div class="col-md-4">
<div class="card">
<div class="card-header">
<h3>General Info</h3>
<h3>Allgemein</h3>
</div>
<div class="card-body">
{% block info-table %}
Expand All @@ -88,7 +88,7 @@ <h3>General Info</h3>
{% if object.start_date or object.end_date %}
<tr>
<th>
Date
Datum
</th>
<td>
{% if object.start_date %}
Expand Down Expand Up @@ -143,7 +143,7 @@ <h2>Texts</h2>
{% if object.text.all %}
<div class="card-body">
<legend>
Texts
Texte
</legend>
{% for x in object.text.all %}
<div class="card card-default">
Expand All @@ -160,7 +160,7 @@ <h4 class="card-title"> {{ x.kind }}</h4>
</div>
{% else %}
<div class="card-body">
<legend>No text provided for this {{entity}}</legend>
<legend>Kein Text verfügbar für {{entity}}</legend>
</div>
{% endif %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion set_env_variables.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export $(grep -v '^#' .secret | xargs)
export $(grep -v '^#' .env | xargs)
4 changes: 4 additions & 0 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,7 @@ main {
margin-right: .75rem;
margin-left: .75rem;
}

.left-width {
width: 100px;
}

0 comments on commit 8c76007

Please sign in to comment.