mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Removed EDK API extract, added Assign Groups command
This commit is contained in:
49
app/tools/management/commands/assigngroup.py
Normal file
49
app/tools/management/commands/assigngroup.py
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import unicodedata
|
||||
import re
|
||||
from optparse import make_option
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from eve_api.models import EVEPlayerCharacter
|
||||
from eve_api.app_defines import API_STATUS_OK
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = ("Assigns a group to corporation or alliance.")
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('-a', '--alli', action='store', dest='alliance', help='Alliance ID'),
|
||||
make_option('-c', '--corp', action='store', dest='corporation', help='Corp ID'),
|
||||
make_option('-g', '--group', action='store', dest='group', help='Group ID to assign to the corp/alliance')
|
||||
)
|
||||
|
||||
requires_model_validation = False
|
||||
|
||||
def handle(self, **options):
|
||||
|
||||
if not options.get('alliance', None) and not options.get('corporation', None):
|
||||
raise CommandError("Please provide either a corporation or alliance")
|
||||
|
||||
if options.get('alliance', None) and options.get('corporation', None):
|
||||
raise CommandError("Use either alliance or corporation, not both")
|
||||
|
||||
if not options.get('group', None):
|
||||
raise CommandError("You need to specify a domain")
|
||||
|
||||
alliance = options.get('alliance', None)
|
||||
corporation = options.get('corporation', None)
|
||||
group = Group.objects.get(id=options.get('group'))
|
||||
|
||||
args = {'eveaccount__api_status': API_STATUS_OK}
|
||||
|
||||
if alliance:
|
||||
args['eveaccount__characters__corporation__alliance__id'] = alliance
|
||||
elif corporation:
|
||||
args['eveaccount__characters__corporation__id'] = corporation
|
||||
|
||||
users = User.objects.filter(**args).distinct()
|
||||
print "%s user(s) to update." % users.count()
|
||||
for user in users:
|
||||
user.groups.add(group)
|
||||
print "Done."
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#!/usr/bin/env python2.5
|
||||
|
||||
from django.core.management.base import NoArgsCommand
|
||||
from eve_api.models import EVEPlayerCharacter
|
||||
from eve_api.app_defines import *
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
help = "Extracts a list of director's full API keys in CSV format for uploading to EDK"
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
chars = EVEPlayerCharacter.objects.filter(roles__name='roleDirector', eveaccount__api_keytype=API_KEYTYPE_FULL, eveaccount__api_status=API_STATUS_OK, corporation__alliance__ticker="TEST")
|
||||
donekeys = []
|
||||
|
||||
i = 0
|
||||
for c in chars:
|
||||
i = i + 1
|
||||
print "\"TEST\",\"API_CharID_%s\",\"%s\"" % (i, c.id)
|
||||
print "\"TEST\",\"API_UserID_%s\",\"%s\"" % (i, c.eveaccount_set.all()[0].pk)
|
||||
print "\"TEST\",\"API_Key_%s\",\"%s\"" % (i, c.eveaccount_set.all()[0].api_key)
|
||||
print "\"TEST\",\"API_Name_%s\",\"%s - %s\"" % (i, c.corporation.name, c.name)
|
||||
print "\"TEST\",\"API_Type_%s\",\"corp\"" % (i)
|
||||
print "\"TEST\",\"API_Key_count\",\"%s\"" % i
|
||||
Reference in New Issue
Block a user