mirror of
https://github.com/nikdoof/test-auth.git
synced 2026-01-29 23:48:16 +00:00
Fixed assign group tool to be more useful, refreshes user's access after adding the group.
This commit is contained in:
@@ -4,8 +4,9 @@ import unicodedata
|
|||||||
import re
|
import re
|
||||||
from optparse import make_option
|
from optparse import make_option
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
from eve_api.models import EVEPlayerCharacter
|
from django.contrib.auth.models import User, Group
|
||||||
from eve_api.app_defines import API_STATUS_OK
|
from eve_api.app_defines import API_STATUS_OK
|
||||||
|
from sso.tasks import update_user_access
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = ("Assigns a group to corporation or alliance.")
|
help = ("Assigns a group to corporation or alliance.")
|
||||||
@@ -40,10 +41,12 @@ class Command(BaseCommand):
|
|||||||
elif corporation:
|
elif corporation:
|
||||||
args['eveaccount__characters__corporation__id'] = corporation
|
args['eveaccount__characters__corporation__id'] = corporation
|
||||||
|
|
||||||
users = User.objects.filter(**args).distinct()
|
users = User.objects.select_related('groups').filter(**args).exclude(groups__id=group.id).distinct()
|
||||||
print "%s user(s) to update." % users.count()
|
print "%s user(s) to update." % users.count()
|
||||||
for user in users:
|
for user in users:
|
||||||
|
if not group in user.groups.all():
|
||||||
user.groups.add(group)
|
user.groups.add(group)
|
||||||
|
update_user_access.delay(user.id)
|
||||||
print "Done."
|
print "Done."
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user