-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update set_default_handles script to set handle on team workspaces
- Loading branch information
Showing
1 changed file
with
9 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" | ||
) |