mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-11 04:19:25 +00:00
Graph de famille en frontend (#820)
* Remove graphviz and use cytoscape.js instead * Frontend generated graphs * Make installation easier and faster * Better user experience * Family api and improved interface * Fix url history when using 0, improve button selection and reset reverse with reset button * Use klay layout * Add js translations and apply review comments
This commit is contained in:
committed by
GitHub
parent
bf96d8a10c
commit
f624b7c66d
@ -1,3 +1,4 @@
|
||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||
from ninja import ModelSchema, Schema
|
||||
|
||||
from core.models import User
|
||||
@ -13,3 +14,41 @@ class SimpleUserSchema(ModelSchema):
|
||||
|
||||
class MarkdownSchema(Schema):
|
||||
text: str
|
||||
|
||||
|
||||
class UserProfileSchema(ModelSchema):
|
||||
"""The necessary information to show a user profile"""
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ["id", "nick_name", "first_name", "last_name"]
|
||||
|
||||
display_name: str
|
||||
profile_url: str
|
||||
profile_pict: str
|
||||
|
||||
@staticmethod
|
||||
def resolve_display_name(obj: User) -> str:
|
||||
return obj.get_display_name()
|
||||
|
||||
@staticmethod
|
||||
def resolve_profile_url(obj: User) -> str:
|
||||
return obj.get_absolute_url()
|
||||
|
||||
@staticmethod
|
||||
def resolve_profile_pict(obj: User) -> str:
|
||||
if obj.profile_pict_id is None:
|
||||
return staticfiles_storage.url("core/img/unknown.jpg")
|
||||
return obj.profile_pict.get_download_url()
|
||||
|
||||
|
||||
class FamilyGodfatherSchema(Schema):
|
||||
godfather: int
|
||||
godchild: int
|
||||
|
||||
|
||||
class UserFamilySchema(Schema):
|
||||
"""Represent a graph of a user's family"""
|
||||
|
||||
users: list[UserProfileSchema]
|
||||
relationships: list[FamilyGodfatherSchema]
|
||||
|
Reference in New Issue
Block a user