-
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.
- Loading branch information
1 parent
c8c986b
commit 3c442c2
Showing
1 changed file
with
26 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django.db import migrations | ||
from users.saml import saml_user_group | ||
|
||
def add_saml_users_to_group(apps, schema_editor): | ||
CustomUser = apps.get_model('users', 'CustomUser') | ||
|
||
saml_users = CustomUser.objects.filter(saml = True) | ||
saml_group = saml_user_group() | ||
|
||
if saml_group: | ||
for user in saml_users: | ||
user.groups.add(saml_group) | ||
user.save() | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('users', '0003_sitedomain'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
add_saml_users_to_group, | ||
reverse_code=migrations.RunPython.noop | ||
) | ||
] |