mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-15 07:20:17 +02:00
Handle new zKillboard API format
This commit is contained in:
parent
cca8b26375
commit
c63464c4c9
@ -6,7 +6,7 @@ import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SRPManager:
|
||||
class srpManager:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@ -26,11 +26,12 @@ class SRPManager:
|
||||
r = requests.get(url, headers=headers)
|
||||
result = r.json()[0]
|
||||
if result:
|
||||
ship_type = result['victim']['shipTypeID']
|
||||
logger.debug("Ship type for kill ID %s is determined to be %s" % (kill_id, ship_type))
|
||||
ship_type = result['victim']['ship_type_id']
|
||||
logger.debug("Ship type for kill ID %s is %s" % (kill_id, ship_type))
|
||||
ship_value = result['zkb']['totalValue']
|
||||
logger.debug("total loss value for kill id %s is %s" % (kill_id, ship_value))
|
||||
victim_name = result['victim']['characterName']
|
||||
return ship_type, ship_value, victim_name
|
||||
logger.debug("Total loss value for kill id %s is %s" % (kill_id, ship_value))
|
||||
victim_id = result['victim']['character_id']
|
||||
return ship_type, ship_value, victim_id
|
||||
else:
|
||||
raise ValueError("Invalid Kill ID")
|
||||
|
||||
|
@ -186,7 +186,7 @@ def srp_request_view(request, fleet_srp):
|
||||
|
||||
try:
|
||||
srp_kill_link = SRPManager.get_kill_id(srp_request.killboard_link)
|
||||
(ship_type_id, ship_value, victim_name) = SRPManager.get_kill_data(srp_kill_link)
|
||||
(ship_type_id, ship_value, victim_id) = SRPManager.get_kill_data(srp_kill_link)
|
||||
except ValueError:
|
||||
logger.debug("User %s Submitted Invalid Killmail Link %s or server could not be reached" % (
|
||||
request.user, srp_request.killboard_link))
|
||||
@ -196,7 +196,7 @@ def srp_request_view(request, fleet_srp):
|
||||
"Your SRP request Killmail link is invalid. Please make sure you are using zKillboard."))
|
||||
return redirect("srp:management")
|
||||
|
||||
if request.user.character_ownerships.filter(character__character_name=victim_name).exists():
|
||||
if request.user.character_ownerships.filter(character__character_id=str(victim_id)).exists():
|
||||
srp_request.srp_ship_name = provider.get_itemtype(ship_type_id).name
|
||||
srp_request.kb_total_loss = ship_value
|
||||
srp_request.post_time = post_time
|
||||
@ -209,8 +209,8 @@ def srp_request_view(request, fleet_srp):
|
||||
else:
|
||||
messages.error(request,
|
||||
_(
|
||||
"%(charname)s does not belong to your Auth account. Please add the API key for this character and try again")
|
||||
% {"charname": victim_name})
|
||||
"Character %(charid)s does not belong to your Auth account. Please add the API key for this character and try again")
|
||||
% {"charid": victim_id})
|
||||
return redirect("srp:management")
|
||||
else:
|
||||
logger.debug("Returning blank SrpFleetUserRequestForm")
|
||||
|
Loading…
x
Reference in New Issue
Block a user