Add multiple network maps, graph UX improvements, and full backup import.
Support per-map contact membership with scoped graph views, relation editing on edges, layout caching, and automatic detection of full JSON backups so contacts and relations import together. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from rest_framework import serializers
|
||||
from .models import Contact, Relation
|
||||
from .models import Contact, Relation, NetworkMap, NetworkMapMembership
|
||||
|
||||
|
||||
class ContactSerializer(serializers.ModelSerializer):
|
||||
@@ -10,9 +10,6 @@ class ContactSerializer(serializers.ModelSerializer):
|
||||
fields = [
|
||||
'id', 'name', 'email', 'phone',
|
||||
'organization', 'position', 'notes',
|
||||
'life_sphere', 'network_circle', 'importance',
|
||||
'include_on_network_map',
|
||||
'map_angle', 'map_radius_ratio',
|
||||
'created_at', 'updated_at', 'relations_count',
|
||||
]
|
||||
read_only_fields = ['id', 'created_at', 'updated_at', 'relations_count']
|
||||
@@ -46,6 +43,36 @@ class RelationSerializer(serializers.ModelSerializer):
|
||||
return data
|
||||
|
||||
|
||||
class NetworkMapSerializer(serializers.ModelSerializer):
|
||||
memberships_count = serializers.SerializerMethodField()
|
||||
|
||||
class Meta:
|
||||
model = NetworkMap
|
||||
fields = [
|
||||
'id', 'name', 'description',
|
||||
'created_at', 'updated_at', 'memberships_count',
|
||||
]
|
||||
read_only_fields = ['id', 'created_at', 'updated_at', 'memberships_count']
|
||||
|
||||
def get_memberships_count(self, obj):
|
||||
return obj.memberships.count()
|
||||
|
||||
|
||||
class NetworkMapMembershipSerializer(serializers.ModelSerializer):
|
||||
contact_name = serializers.CharField(source='contact.name', read_only=True)
|
||||
map_name = serializers.CharField(source='map.name', read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = NetworkMapMembership
|
||||
fields = [
|
||||
'id', 'map', 'map_name', 'contact', 'contact_name',
|
||||
'life_sphere', 'network_circle', 'importance',
|
||||
'map_angle', 'map_radius_ratio',
|
||||
'created_at', 'updated_at',
|
||||
]
|
||||
read_only_fields = ['id', 'created_at', 'updated_at', 'contact_name', 'map_name']
|
||||
|
||||
|
||||
class GraphSerializer(serializers.Serializer):
|
||||
"""Граф для vis.js: nodes + edges."""
|
||||
|
||||
@@ -60,9 +87,6 @@ class GraphSerializer(serializers.Serializer):
|
||||
'label': c.name,
|
||||
'title': f'{c.organization}\n{c.position}'.strip() or c.name,
|
||||
'group': c.organization or 'default',
|
||||
'life_sphere': c.life_sphere,
|
||||
'network_circle': c.network_circle,
|
||||
'importance': c.importance,
|
||||
}
|
||||
for c in contacts
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user