Added Total SP field calculated during API runs

This commit is contained in:
2010-04-20 14:04:54 +01:00
parent e2dce0aed4
commit 98e10b1952
6 changed files with 31 additions and 8 deletions

View File

@@ -110,13 +110,21 @@ def import_eve_character(api_key, user_id, character_id):
if len(node.childNodes) == 1:
values[node.tagName] = node.childNodes[0].nodeValue
else:
if node.tagName == "rowset":
continue
nv = {}
for nd in node.childNodes:
if nd.nodeType == 1:
nv[nd.tagName] = nd.childNodes[0].nodeValue
values[node.tagName] = nv
if node.tagName == "rowset":
rset = []
for nd in node.childNodes:
if nd.nodeType == 1:
d = {}
for e in nd.attributes.keys():
d[e] = nd.attributes[e].value
rset.append(d)
values[node.attributes['name'].value] = rset
else:
for nd in node.childNodes:
if nd.nodeType == 1:
nv[nd.tagName] = nd.childNodes[0].nodeValue
values[node.tagName] = nv
# Get this first, as it's safe.
corporation_id = values['corporationID']
@@ -146,6 +154,11 @@ def import_eve_character(api_key, user_id, character_id):
pchar.race = API_RACES[values['race']]
total = 0
for skill in values['skills']:
total = total + int(skill['skillpoints'])
pchar.total_sp = total
pchar.api_last_updated = datetime.utcnow()
pchar.save()

View File

@@ -1 +1 @@
SEQUENCE = ['applications-field']
SEQUENCE = ['applications-field', 'total-sp']

View File

@@ -0,0 +1,7 @@
from django_evolution.mutations import *
from django.db import models
MUTATIONS = [
AddField('EVEPlayerCharacter', 'total_sp', models.IntegerField, initial=0)
]

View File

@@ -73,6 +73,8 @@ class EVEPlayerCharacter(EVEAPIModel):
attrib_charisma = models.IntegerField("Charisma", blank=True, null=True)
attrib_perception = models.IntegerField("Perception", blank=True, null=True)
attrib_willpower = models.IntegerField("Willpower", blank=True, null=True)
total_sp = models.IntegerField("Total SP", blank=True, null=True)
objects = EVEPlayerCharacterManager()

View File

@@ -34,7 +34,7 @@
<ul>
{% for acc in eveacc %}
{% for char in acc.characters.all %}
<li><a href="/profile/characters/{{ char.id }}/">{{ char.name }}</a> - {{ char.corporation }} / {{ char.corporation.alliance }} - {{ char.balance }} ISK <button type="button" onclick="CCPEVE.showInfo('1377//{{ char.id }}')">Show In Eve</button></li>
<li><a href="/profile/characters/{{ char.id }}/">{{ char.name }}</a> - {{ char.corporation }} / {{ char.corporation.alliance }} - {{ char.balance }} ISK, {{ char.total_sp }} SP <button type="button" onclick="CCPEVE.showInfo('1377//{{ char.id }}')">Show In Eve</button></li>
{% endfor %}
{% endfor %}
</ul>

View File

@@ -10,6 +10,7 @@
<li>Race: {{ character.race_description }}</li>
<li>Gender: {{ character.gender_description }}</li>
<li>Corporation: {{ character.corporation.name }}</li>
<li>Total SP: {{ character.total_sp }}</li>
</ul>
<table>