From aea462b038d20a315072c324985004a1b6da84a1 Mon Sep 17 00:00:00 2001 From: lcduong Date: Tue, 3 Dec 2024 15:43:00 +0700 Subject: [PATCH] Update code --- server/venueless/api/views.py | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/server/venueless/api/views.py b/server/venueless/api/views.py index 04374b17..c7c020d6 100644 --- a/server/venueless/api/views.py +++ b/server/venueless/api/views.py @@ -150,6 +150,11 @@ def post(request, *args, **kwargs) -> JsonResponse: title = titles.get(locale) or titles.get("en") or title_default attendee_trait_grants = request.data.get("traits", {}).get("attendee", "") + trait_grants = { + "admin": ["admin"], + "attendee": [attendee_trait_grants] if attendee_trait_grants else ["attendee"], + "scheduleuser": ["schedule-update"], + } # if world already exists, update it, otherwise create a new world world_id = request.data.get("id") @@ -167,15 +172,7 @@ def post(request, *args, **kwargs) -> JsonResponse: world.domain = domain_path world.locale = request.data.get("locale") or "en" world.timezone = request.data.get("timezone") or "UTC" - world.trait_grants = { - "admin": ["admin"], - "attendee": ( - [attendee_trait_grants] - if attendee_trait_grants - else ["attendee"] - ), - "scheduleuser": ["schedule-update"], - } + world.trait_grants = trait_grants world.save() else: world = World.objects.create( @@ -185,15 +182,7 @@ def post(request, *args, **kwargs) -> JsonResponse: locale=request.data.get("locale") or "en", timezone=request.data.get("timezone") or "UTC", config=config, - trait_grants={ - "admin": ["admin"], - "attendee": ( - [attendee_trait_grants] - if attendee_trait_grants - else ["attendee"] - ), - "scheduleuser": ["schedule-update"], - }, + trait_grants=trait_grants, ) site_url = settings.SITE_URL