Skip to content

Commit

Permalink
update set_default_handles script to set handle on team workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko committed Jan 14, 2025
1 parent 3a6ee90 commit 5e72597
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions scripts/set_default_handles.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
from loguru import logger

from app_users.models import AppUser
from workspaces.models import Workspace
from handles.models import Handle


def run():
# TODO:update to set handle on workspace
team_workspaces = Workspace.objects.filter(is_personal=False, handle__isnull=True)

registered_users = AppUser.objects.filter(
handle__isnull=True,
is_anonymous=False,
)

for user in registered_users:
if handle := Handle.create_default_for_user(user):
user.handle = handle
user.save()
for workspace in team_workspaces:
if handle := Handle.create_default_for_workspace(workspace):
workspace.handle = handle
workspace.save()
else:
logger.warning(f"unable to find acceptable handle for user: {user}")
logger.warning(
f"unable to find acceptable handle for workspace: {workspace}"
)

0 comments on commit 5e72597

Please sign in to comment.