mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-13 22:32:15 +00:00
Convert update-directors into a full command
This commit is contained in:
@@ -160,11 +160,14 @@ FULL_API_CHARACTER_ID = 246102445
|
|||||||
|
|
||||||
BANNED_EMAIL_DOMAINS = ['att.net']
|
BANNED_EMAIL_DOMAINS = ['att.net']
|
||||||
|
|
||||||
|
|
||||||
## Eve Proxy settings
|
## Eve Proxy settings
|
||||||
|
|
||||||
EVE_PROXY_KEEP_LOGS = 30
|
EVE_PROXY_KEEP_LOGS = 30
|
||||||
|
|
||||||
|
## Director management settings
|
||||||
|
|
||||||
|
IGNORE_CORP_GROUPS = [29]
|
||||||
|
|
||||||
# try and import local settings
|
# try and import local settings
|
||||||
try:
|
try:
|
||||||
from conf.settingslocal import *
|
from conf.settingslocal import *
|
||||||
|
|||||||
@@ -1,50 +1,29 @@
|
|||||||
#!/usr/bin/env python
|
from django.conf import settings
|
||||||
"""Executes a Django cronjob"""
|
from django.core.management.base import NoArgsCommand
|
||||||
|
|
||||||
PACS = 29
|
|
||||||
|
|
||||||
import os, sys
|
|
||||||
|
|
||||||
# Set niceness
|
|
||||||
os.nice(20)
|
|
||||||
|
|
||||||
# Activate the virtualenv
|
|
||||||
path = os.path.dirname(os.path.realpath( __file__ ))
|
|
||||||
os.chdir(path)
|
|
||||||
activate_this = os.path.join(path, 'env/bin/activate_this.py')
|
|
||||||
execfile(activate_this, dict(__file__=activate_this))
|
|
||||||
|
|
||||||
from django.core.management import setup_environ
|
|
||||||
import settings
|
|
||||||
setup_environ(settings)
|
|
||||||
|
|
||||||
from eve_api.models import EVEPlayerCharacter
|
|
||||||
from django.contrib.auth.models import Group, User
|
from django.contrib.auth.models import Group, User
|
||||||
|
from eve_api.models import EVEPlayerCharacter
|
||||||
from sso.tasks import update_user_access
|
from sso.tasks import update_user_access
|
||||||
|
|
||||||
g = Group.objects.get(name="Alliance Directors")
|
class Command(NoArgsCommand):
|
||||||
|
help = "Updates the members of the alliance director group"
|
||||||
|
|
||||||
users = []
|
def handle_noargs(self, **options):
|
||||||
for char in EVEPlayerCharacter.objects.filter(corporation__alliance__name="Test Alliance Please Ignore",director=True):
|
g = Group.objects.get(name="Alliance Directors")
|
||||||
if char.eveaccount_set.count() and char.eveaccount_set.all()[0].user and not (char.corporation.group and char.corporation.group.id == PACS):
|
|
||||||
users.append(char.eveaccount_set.all()[0].user)
|
|
||||||
|
|
||||||
add = set(users) - set(g.user_set.all())
|
users = []
|
||||||
rem = set(g.user_set.all()) - set(users)
|
for char in EVEPlayerCharacter.objects.filter(corporation__alliance__name="Test Alliance Please Ignore",roles__name="roleDirector"):
|
||||||
|
if char.eveaccount_set.count() and char.eveaccount_set.all()[0].user and not (char.corporation.group and char.corporation.group.id in settings.IGNORE_CORP_GROUPS):
|
||||||
|
users.append(char.eveaccount_set.all()[0].user)
|
||||||
|
|
||||||
print "Add:", add
|
add = set(users) - set(g.user_set.all())
|
||||||
print "Rem:", rem
|
rem = set(g.user_set.all()) - set(users)
|
||||||
|
|
||||||
|
print g.user_set.all()
|
||||||
|
|
||||||
for m in rem:
|
for m in rem:
|
||||||
m.groups.remove(g)
|
m.groups.remove(g)
|
||||||
update_user_access.delay(m.id)
|
update_user_access.delay(m.id)
|
||||||
|
|
||||||
for m in add:
|
for m in add:
|
||||||
m.groups.add(g)
|
m.groups.add(g)
|
||||||
update_user_access.delay(m.id)
|
update_user_access.delay(m.id)
|
||||||
|
|
||||||
#for u in set(users):
|
|
||||||
# print "Updating %s" % u
|
|
||||||
# update_user_access.delay(u.id)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user