fix clone with nodata

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt 2024-01-11 15:25:15 +01:00
parent 6945dafe0b
commit 1cff8902dd
No known key found for this signature in database
GPG Key ID: 9C3FA22FABF1AA8D
1 changed files with 5 additions and 2 deletions

View File

@ -72,10 +72,13 @@ def model_to_dict(model: Model) -> dict[str, Any]:
}
def get_user(user: User, original_user: Optional[User] = None) -> dict[str, Any]:
def get_user(user: User | AnonymousUser, original_user: Optional[User] = None) -> dict[str, Any]:
"""Convert user object to dictionary, optionally including the original user"""
if isinstance(user, AnonymousUser):
try:
user = get_anonymous_user()
except User.DoesNotExist:
return {}
user_data = {
"username": user.username,
"pk": user.pk,