backoffice: add links to carddef in graph (#58368)
gitea-wip/wcs/pipeline/head Build started... Details

This commit is contained in:
Lauréline Guérin 2021-11-05 16:33:16 +01:00
parent ffa52fcdd3
commit ce6aee3fb7
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 16 additions and 3 deletions

View File

@ -743,6 +743,11 @@ def test_cards_svg(pub):
resp = app.get('/backoffice/cards/svg')
# cards
assert '<title>card_card_1_1</title' in resp
assert (
'xlink:href="http://example.net/backoffice/cards/%s/" xlink:title="&lt;card&gt;card 1&#45;1"'
% carddef11.id
in resp
)
assert '<title>card_card_1_2</title' in resp
assert '<title>card_card_1_3</title' not in resp
assert '<title>card_card_2_1</title' in resp
@ -761,6 +766,11 @@ def test_cards_svg(pub):
resp = app.get('/backoffice/cards/categories/%s/svg' % cat1.id)
# cards
assert '<title>card_card_1_1</title' in resp
assert (
'xlink:href="http://example.net/backoffice/cards/%s/" xlink:title="&lt;card&gt;card 1&#45;1"'
% carddef11.id
in resp
)
assert '<title>card_card_1_2</title' in resp
assert '<title>card_card_1_3</title' not in resp
assert '<title>card_card_2_1</title' not in resp

View File

@ -331,10 +331,13 @@ def get_cards_graph(category=None, show_orphans=False):
for carddef in carddefs:
carddef_ref = 'card_%s' % carddef.url_name.replace('-', '_')
record = '%s [shape=record,label="<card>%s' % (carddef_ref, carddef.name)
relations += list(check_relations(carddef_ref, carddef.get_all_fields()))
record += '"];'
record = '%s [shape=record,label="<card>%s",URL="%s"];' % (
carddef_ref,
carddef.name,
carddef.get_admin_url(),
)
records.append(record)
relations += list(check_relations(carddef_ref, carddef.get_all_fields()))
if not show_orphans:
for record in records[:]:
if not [x for x in relations if record.split()[0] in x.split()]: