Skip to content

Commit

Permalink
Fix add user to group
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Bharadwaj committed Jan 20, 2023
1 parent 654b001 commit 95d46a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions journalism_workflow/load_sample_data.py
Expand Up @@ -20,8 +20,10 @@ def load(workflow_version):
user.set_password(password)
user.save()
worker, _ = Worker.objects.update_or_create(user=user)
project_admins = Group.objects.get_or_create(name='project_admins')
project_admins.user_set.add(user)
project_admins, created = Group.objects.get_or_create(
name='project_admins')
if created:
user.groups.add(project_admins)

# Grant the worker the desired certifications.
for certification_slug, certification_role in certifications:
Expand Down
6 changes: 4 additions & 2 deletions simple_workflow/load_sample_data.py
Expand Up @@ -21,5 +21,7 @@ def load(workflow_version):
user.save()
if created:
Worker.objects.create(user=user)
project_admins = Group.objects.get_or_create(name='project_admins')
project_admins.user_set.add(user)
project_admins, created = Group.objects.get_or_create(
name='project_admins')
if created:
user.groups.add(project_admins)

0 comments on commit 95d46a5

Please sign in to comment.