mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Import Skill information from the API, also provide new Auth API to access this information
This commit is contained in:
@@ -2,3 +2,4 @@ from account import *
|
||||
from alliance import *
|
||||
from character import *
|
||||
from corporation import *
|
||||
from static import *
|
||||
|
||||
@@ -5,7 +5,7 @@ from celery.decorators import task
|
||||
|
||||
from eve_proxy.models import CachedDocument
|
||||
|
||||
from eve_api.models import EVEPlayerCorporation, EVEPlayerCharacter, EVEPlayerCharacterRole
|
||||
from eve_api.models import EVEPlayerCorporation, EVEPlayerCharacter, EVEPlayerCharacterRole, EVEPlayerCharacterSkill, EVESkill
|
||||
from eve_api.app_defines import *
|
||||
from eve_api.utils import basic_xml_parse, basic_xml_parse_doc
|
||||
|
||||
@@ -62,6 +62,17 @@ def import_eve_character(character_id, api_key=None, user_id=None, callback=None
|
||||
pchar.attrib_willpower = values['attributes']['willpower']
|
||||
pchar.attrib_memory = values['attributes']['memory']
|
||||
|
||||
|
||||
# Process the character's skills
|
||||
pchar.total_sp = 0
|
||||
for skill in values.get('skills', None):
|
||||
skillobj, created = EVESkill.objects.get_or_create(id=skill['typeID'])
|
||||
charskillobj, created = EVEPlayerCharacterSkill.objects.get_or_create(skill=skillobj, character=pchar)
|
||||
charskillobj.level = int(skill['level'])
|
||||
charskillobj.skillpoints = int(skill['skillpoints'])
|
||||
charskillobj.save()
|
||||
pchar.total_sp = pchar.total_sp + int(skill['skillpoints'])
|
||||
|
||||
# Process the character's roles
|
||||
pchar.director = False
|
||||
pchar.roles.clear()
|
||||
@@ -78,10 +89,6 @@ def import_eve_character(character_id, api_key=None, user_id=None, callback=None
|
||||
else:
|
||||
pchar.gender = API_GENDER_FEMALE
|
||||
|
||||
total = 0
|
||||
for skill in values['skills']:
|
||||
total = total + int(skill['skillpoints'])
|
||||
pchar.total_sp = total
|
||||
|
||||
pchar.api_last_updated = datetime.utcnow()
|
||||
pchar.save()
|
||||
|
||||
30
eve_api/tasks/static.py
Normal file
30
eve_api/tasks/static.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from celery.decorators import task
|
||||
from eve_proxy.models import CachedDocument
|
||||
from eve_api.utils import basic_xml_parse_doc
|
||||
from eve_api.models import EVESkill, EVESkillGroup
|
||||
|
||||
@task()
|
||||
def import_eve_skills():
|
||||
"""
|
||||
Imports the skill tree and groups
|
||||
"""
|
||||
|
||||
char_doc = CachedDocument.objects.api_query('/eve/SkillTree.xml.aspx')
|
||||
d = basic_xml_parse_doc(char_doc)['eveapi']
|
||||
if 'error' in d:
|
||||
return
|
||||
values = d['result']
|
||||
|
||||
for group in values['skillGroups']:
|
||||
gobj, created = EVESkillGroup.objects.get_or_create(id=group['groupID'])
|
||||
if created:
|
||||
gobj.name = group['groupName']
|
||||
gobj.save()
|
||||
|
||||
for skill in group['skills']:
|
||||
skillobj, created = EVESkill.objects.get_or_create(id=skill['typeID'])
|
||||
if created or not skillobj.name or not skillobj.group:
|
||||
skillobj.name = skill['typeName']
|
||||
skillobj.group = gobj
|
||||
skillobj.save()
|
||||
|
||||
Reference in New Issue
Block a user