Skip to content

Commit

Permalink
Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
lcduong committed Dec 3, 2024
1 parent 8972af1 commit aea462b
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions server/venueless/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit aea462b

Please sign in to comment.