mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-11 01:26:22 +01:00
Character stuff
This commit is contained in:
0
evespecific/__init__.py
Normal file
0
evespecific/__init__.py
Normal file
3
evespecific/admin.py
Normal file
3
evespecific/admin.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
60
evespecific/managers.py
Normal file
60
evespecific/managers.py
Normal file
@@ -0,0 +1,60 @@
|
||||
import evelink.api # Raw API access
|
||||
import evelink.char # Wrapped API access for the /char/ API path
|
||||
import evelink.eve # Wrapped API access for the /eve/ API path
|
||||
|
||||
from models import EveCharacter
|
||||
|
||||
class EveCharacterManager():
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def create_character(self,character_id, character_name,corporation_id,
|
||||
corporation_name, alliance_id,
|
||||
alliance_name, allianceuser_owner):
|
||||
|
||||
eve_char = EveCharacter();
|
||||
eve_char.character_id = character_id
|
||||
eve_char.character_name = character_name
|
||||
eve_char.corporation_id = corporation_id
|
||||
eve_char.corporation_name = corporation_name
|
||||
eve_char.alliance_id = alliance_id
|
||||
eve_char.alliance_name = alliance_name
|
||||
eve_char.allianceuser_owner = allianceuser_owner
|
||||
|
||||
eve_char.save()
|
||||
|
||||
def get_characters_by_owner_id(self, owner_id):
|
||||
return EveCharacter.objects.all().filter(allianceuser_owner=owner_id)
|
||||
|
||||
class EveApiManager():
|
||||
|
||||
characterManager = EveCharacterManager()
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def CreateCharactersFromID(self,api_id, api_key, user):
|
||||
# Create user
|
||||
api = evelink.api.API(api_key=(api_id, api_key))
|
||||
# Should get characters
|
||||
account = evelink.account.Account(api=api)
|
||||
chars = account.characters()
|
||||
|
||||
# Have our characters now lets populate database
|
||||
for char in chars.result:
|
||||
self.characterManager.create_character( chars.result[char]['id'], chars.result[char]['name'],
|
||||
chars.result[char]['corp']['id'], chars.result[char]['corp']['name'],
|
||||
chars.result[char]['alliance']['id'],chars.result[char]['alliance']['name'],
|
||||
user)
|
||||
#Done
|
||||
|
||||
def GetCorpNameByKey(self, api_id, api_key):
|
||||
pass
|
||||
|
||||
def GetAllianceNameByKey(self, api_id, api_key):
|
||||
pass
|
||||
|
||||
def GetCharactersByKey(self, api_id, api_key):
|
||||
pass
|
||||
|
||||
13
evespecific/models.py
Normal file
13
evespecific/models.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from django.db import models
|
||||
|
||||
from authentication.models import AllianceUser
|
||||
|
||||
# Create your models here.
|
||||
class EveCharacter(models.Model):
|
||||
character_id = models.CharField(max_length=254)
|
||||
character_name = models.CharField(max_length=254)
|
||||
corporation_id = models.CharField(max_length=254)
|
||||
corporation_name = models.CharField(max_length=254)
|
||||
alliance_id = models.CharField(max_length=254)
|
||||
alliance_name = models.CharField(max_length=254)
|
||||
allianceuser_owner = models.ForeignKey(AllianceUser)
|
||||
3
evespecific/tests.py
Normal file
3
evespecific/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
3
evespecific/views.py
Normal file
3
evespecific/views.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Reference in New Issue
Block a user