mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
@@ -16,6 +16,15 @@ class PersonSerializer(serializers.ModelSerializer):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class OrganisationSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = models.Organisation
|
||||||
|
fields = [
|
||||||
|
'pk',
|
||||||
|
'name',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class RelationshipSerializer(serializers.ModelSerializer):
|
class RelationshipSerializer(serializers.ModelSerializer):
|
||||||
source = PersonSerializer()
|
source = PersonSerializer()
|
||||||
target = PersonSerializer()
|
target = PersonSerializer()
|
||||||
|
|||||||
@@ -53,6 +53,8 @@
|
|||||||
-->
|
-->
|
||||||
{{ person_set|json_script:'person-set-data' }}
|
{{ person_set|json_script:'person-set-data' }}
|
||||||
|
|
||||||
|
{{ organisation_set|json_script:'organisation-set-data' }}
|
||||||
|
|
||||||
{{ relationship_set|json_script:'relationship-set-data' }}
|
{{ relationship_set|json_script:'relationship-set-data' }}
|
||||||
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.14.0/cytoscape.min.js"
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.14.0/cytoscape.min.js"
|
||||||
@@ -102,6 +104,22 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load organisations and add to graph
|
||||||
|
var organisation_set = JSON.parse(document.getElementById('organisation-set-data').textContent);
|
||||||
|
|
||||||
|
for (var item of organisation_set) {
|
||||||
|
cy.add({
|
||||||
|
group: 'nodes',
|
||||||
|
data: {
|
||||||
|
id: 'organisation-' + item.pk.toString(),
|
||||||
|
name: item.name
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
shape: 'rectangle'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Load relationships and add to graph
|
// Load relationships and add to graph
|
||||||
var relationship_set = JSON.parse(document.getElementById('relationship-set-data').textContent);
|
var relationship_set = JSON.parse(document.getElementById('relationship-set-data').textContent);
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ class NetworkView(LoginRequiredMixin, FormView):
|
|||||||
context['person_set'] = serializers.PersonSerializer(
|
context['person_set'] = serializers.PersonSerializer(
|
||||||
models.Person.objects.all(), many=True).data
|
models.Person.objects.all(), many=True).data
|
||||||
|
|
||||||
|
context['organisation_set'] = serializers.OrganisationSerializer(
|
||||||
|
models.Organisation.objects.all(), many=True).data
|
||||||
|
|
||||||
context['relationship_set'] = serializers.RelationshipSerializer(
|
context['relationship_set'] = serializers.RelationshipSerializer(
|
||||||
models.Relationship.objects.filter(
|
models.Relationship.objects.filter(
|
||||||
pk__in=relationship_answerset_set.values_list('relationship',
|
pk__in=relationship_answerset_set.values_list('relationship',
|
||||||
|
|||||||
Reference in New Issue
Block a user