mirror of
https://github.com/Findus23/RPGnotes.git
synced 2024-09-19 15:43:45 +02:00
also show loot in graph
This commit is contained in:
parent
f472f70b88
commit
3eeaf581f9
3 changed files with 23 additions and 3 deletions
|
@ -7,6 +7,7 @@ from django.views.generic import TemplateView
|
|||
from characters.models import Character
|
||||
from factions.models import Faction
|
||||
from locations.models import Location
|
||||
from loot.models import Loot, LootType
|
||||
from notes.models import Note
|
||||
from users.models import TenantUser
|
||||
|
||||
|
@ -72,7 +73,6 @@ def get_graph(request: HttpRequest) -> HttpResponse:
|
|||
.filter(tenants=connection.get_tenant()) \
|
||||
.exclude(pk__in=[1, 2]):
|
||||
g.add_node(user, user.name)
|
||||
|
||||
for char in Character.objects.all():
|
||||
g.add_node(char)
|
||||
if char.location:
|
||||
|
@ -81,6 +81,18 @@ def get_graph(request: HttpRequest) -> HttpResponse:
|
|||
g.add_edge(char, char.faction)
|
||||
if char.player:
|
||||
g.add_edge(char, char.player)
|
||||
|
||||
for loottype in LootType.objects.all():
|
||||
g.add_node(loottype)
|
||||
|
||||
for loot in Loot.objects.all():
|
||||
g.add_node(loot)
|
||||
if loot.location:
|
||||
g.add_edge(loot, loot.location)
|
||||
if loot.owner:
|
||||
g.add_edge(loot, loot.owner)
|
||||
if loot.type:
|
||||
g.add_edge(loot, loot.type)
|
||||
g.prune()
|
||||
|
||||
return JsonResponse(g.export())
|
||||
|
|
|
@ -15,6 +15,10 @@ class LootType(NameSlugModel, models.Model):
|
|||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
@property
|
||||
def graphkey(self):
|
||||
return f"lty{self.pk}"
|
||||
|
||||
|
||||
class Loot(DescriptionModel, AliasModel, HistoryModel):
|
||||
name = models.CharField(_("Name"), max_length=1000)
|
||||
|
@ -59,3 +63,7 @@ class Loot(DescriptionModel, AliasModel, HistoryModel):
|
|||
|
||||
def get_absolute_url(self):
|
||||
return reverse('lootedit', args=[self.id])
|
||||
|
||||
@property
|
||||
def graphkey(self):
|
||||
return f"loo{self.pk}"
|
||||
|
|
|
@ -38,8 +38,8 @@ if (container) {
|
|||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const renderer = new Sigma(graph, container, {
|
||||
labelSize:20,
|
||||
edgeLabelSize:200
|
||||
labelSize: 20,
|
||||
edgeLabelSize: 200,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue