mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Update-directors now works better causing less unneeded task triggering
This commit is contained in:
21
update-directors.py
Executable file → Normal file
21
update-directors.py
Executable file → Normal file
@@ -11,23 +11,24 @@ path = os.path.dirname(os.path.realpath( __file__ ))
|
|||||||
activate_this = os.path.join(path, 'env/bin/activate_this.py')
|
activate_this = os.path.join(path, 'env/bin/activate_this.py')
|
||||||
execfile(activate_this, dict(__file__=activate_this))
|
execfile(activate_this, dict(__file__=activate_this))
|
||||||
|
|
||||||
import sys
|
|
||||||
import logging
|
|
||||||
from django.core.management import setup_environ
|
from django.core.management import setup_environ
|
||||||
import settings
|
import settings
|
||||||
|
|
||||||
setup_environ(settings)
|
setup_environ(settings)
|
||||||
|
|
||||||
from eve_api.models import EVEPlayerCharacter
|
from eve_api.models import EVEPlayerCharacter
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group, User
|
||||||
import unicodedata
|
|
||||||
import re
|
|
||||||
|
|
||||||
g = Group.objects.get(name="Alliance Directors")
|
g = Group.objects.get(name="Alliance Directors")
|
||||||
c = EVEPlayerCharacter.objects.filter(corporation__alliance__name="Test Alliance Please Ignore",director=True)
|
|
||||||
|
|
||||||
for m in g.user_set.all():
|
users = []
|
||||||
|
for char in EVEPlayerCharacter.objects.filter(corporation__alliance__name="Test Alliance Please Ignore",director=True):
|
||||||
|
users.append(char.eveaccount_set.all()[0].user)
|
||||||
|
|
||||||
|
add = set(users) - set(g.user_set.all())
|
||||||
|
rem = set(g.user_set.all()) - set(users)
|
||||||
|
|
||||||
|
for m in rem:
|
||||||
m.groups.remove(g)
|
m.groups.remove(g)
|
||||||
|
|
||||||
for char in c:
|
for m in add:
|
||||||
char.eveaccount_set.all()[0].user.groups.add(g)
|
m.groups.add(g)
|
||||||
|
|||||||
Reference in New Issue
Block a user