Skip to content

Commit

Permalink
Merge pull request #96 from arthur-schnitzler/210-the-return-of-the-r…
Browse files Browse the repository at this point in the history
…elations

210 the return of the relations
  • Loading branch information
csae8092 authored Oct 13, 2024
2 parents 6dcf4f1 + c7cd7f1 commit 3511bf7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
9 changes: 9 additions & 0 deletions apis_core/apis_entities/detail_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ def get(self, request, *args, **kwargs):
table = get_generic_relations_table(
relation_class=rel, entity_instance=instance, detail=True
)
print(match, entity)
if match[0] == entity:
link_to_relations = f"{rel.get_listview_url()}?source={pk}"
rel_type = match[1]
else:
link_to_relations = f"{rel.get_listview_url()}?target={pk}"
rel_type = match[0]
if match[0] == match[1]:
title_card = entity.title()
dict_1 = {"related_" + entity.lower() + "a": instance}
Expand Down Expand Up @@ -69,6 +76,8 @@ def get(self, request, *args, **kwargs):
tb_object,
"".join([x.title() for x in match]),
tb_object_open,
link_to_relations,
rel_type
)
)
object_lod = Uri.objects.filter(entity=instance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ <h3 class="text-center mt-5">Beziehungen</h3>
{% block relations %}
{% for obj in right_card %}
{% if obj.1.data|length > 0 %}
<h4 > {{ obj.0 }}</h4>
<h4>{{ obj.0 }} <a class="apis-{{ obj.5 }}" title="Gehe zu {{ object }}–{{ obj.0 }} Relationen" href="{{ obj.4 }}"><i class="bi bi-box-arrow-up-right" aria-hidden="true"><span class="visually-hidden">Gehe zu {{ object }} - {{ obj.5 }} Relationen</span></i></a></h4>

<div id="tab_{{ obj.2 }}" class="mb-5">
{% render_table obj.1 %}
</div>
Expand Down
10 changes: 2 additions & 8 deletions apis_core/apis_relations/forms2.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,11 @@ def get_html_table(self, entity_type, request, site_instance, form_match):
if form_match.group(1) == form_match.group(2):
dic_a = {"related_" + entity_type.lower() + "a": site_instance}
dic_b = {"related_" + entity_type.lower() + "b": site_instance}
if "apis_highlighter" in settings.INSTALLED_APPS:
objects = self.relation_form.objects.filter_ann_proj(
request=request
).filter(Q(**dic_a) | Q(**dic_b))
else:
objects = self.relation_form.objects.filter(Q(**dic_a) | Q(**dic_b))

objects = self.relation_form.objects.filter(Q(**dic_a) | Q(**dic_b)).order_by("-updated")[:10]
table_html = table(data=objects, prefix=prefix)
else:
tab_query = {"related_" + entity_type.lower(): site_instance}
ttab = self.relation_form.objects.filter(**tab_query)
ttab = self.relation_form.objects.filter(**tab_query).order_by("-updated")[:10]
table_html = table(data=ttab, prefix=prefix)
return table_html

Expand Down

0 comments on commit 3511bf7

Please sign in to comment.