mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-17 16:30:15 +02:00
Added the option to view shiptypes of killmails
This commit is contained in:
parent
a419145f7c
commit
376bf60421
@ -1,46 +1,56 @@
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
import json
|
||||
import urllib2
|
||||
import logging
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class srpManager():
|
||||
@staticmethod
|
||||
def get_kill_id (killboard_link):
|
||||
str = (killboard_link)
|
||||
set = '0123456789'
|
||||
kill_id = ''.join([c for c in str if c in set])
|
||||
|
||||
@staticmethod
|
||||
def get_kill_data (kill_id):
|
||||
url = ("https://www.zkillboard.com/api/killID/%s" % kill_id)
|
||||
request = urllib2.Request(url)
|
||||
request.add_header('User-Agent',"%s Alliance Auth" % settings.DOMAIN)
|
||||
request.add_header('Content-Type','application/json')
|
||||
response = urllib2.urlopen(request)
|
||||
result = json.load(response)[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_value = result['zkb']['totalValue']
|
||||
logger.debug("total loss value for kill id %s is %s" %(kill_id, ship_value))
|
||||
else:
|
||||
raise ValueError("Invalid Kill ID")
|
||||
|
||||
@staticmethod
|
||||
def get_ship_name (ship_type):
|
||||
url = ("https://jetbalsa.com/api/json.php/invTypes/%s" % ship_type)
|
||||
request = urllib2.Request(url)
|
||||
request.add_header('User-Agent',"%s Alliance Auth" % settings.DOMAIN)
|
||||
request.add_header('Content-Type','application/json')
|
||||
response = urllib2.urlopen(request)
|
||||
result = json.load(response)
|
||||
if result:
|
||||
ship_name = result['typeName']
|
||||
logger.debug("ship type %s determined to be %s" % (ship_type, ship_name))
|
||||
else:
|
||||
logger.info("ship type %s is invalid please try again" % ship_type)
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
import json
|
||||
import urllib2
|
||||
import logging
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class srpManager():
|
||||
@staticmethod
|
||||
def get_kill_id (killboard_link):
|
||||
str = (killboard_link)
|
||||
set = '0123456789'
|
||||
kill_id = ''.join([c for c in str if c in set])
|
||||
|
||||
@staticmethod
|
||||
def get_kill_data (kill_id):
|
||||
url = ("https://www.zkillboard.com/api/killID/%s" % kill_id)
|
||||
request = urllib2.Request(url)
|
||||
request.add_header('User-Agent',"%s Alliance Auth" % settings.DOMAIN)
|
||||
request.add_header('Content-Type','application/json')
|
||||
response = urllib2.urlopen(request)
|
||||
result = json.load(response)[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_value = result['zkb']['totalValue']
|
||||
logger.debug("total loss value for kill id %s is %s" %(kill_id, ship_value))
|
||||
else:
|
||||
raise ValueError("Invalid Kill ID")
|
||||
|
||||
@staticmethod
|
||||
def get_ship_name (ship_type):
|
||||
url = ("https://jetbalsa.com/api/json.php/invTypes/%s" % ship_type)
|
||||
request = urllib2.Request(url)
|
||||
request.add_header('User-Agent',"%s Alliance Auth" % settings.DOMAIN)
|
||||
request.add_header('Content-Type','application/json')
|
||||
response = urllib2.urlopen(request)
|
||||
result = json.load(response)
|
||||
if result:
|
||||
ship_name = result['typeName']
|
||||
logger.debug("ship type %s determined to be %s" % (ship_type, ship_name))
|
||||
else:
|
||||
logger.info("ship type %s is invalid please try again" % ship_type)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -24,7 +24,9 @@ class SrpUserRequest(models.Model):
|
||||
srp_total_amount = models.BigIntegerField(default=0)
|
||||
character = models.ForeignKey(EveCharacter)
|
||||
srp_fleet_main = models.ForeignKey(SrpFleetMain)
|
||||
srp_ship_name = models.CharField(max_length=254, default="")
|
||||
|
||||
srp_ship_name = models.CharField(max_length=254, default="")
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.character.character_name + " - SrpUserRequest"
|
||||
|
@ -186,6 +186,7 @@ def srp_request_view(request, fleet_srp):
|
||||
character = EveManager.get_character_by_id(authinfo.main_char_id)
|
||||
srp_fleet_main = SrpFleetMain.objects.get(fleet_srp_code=fleet_srp)
|
||||
|
||||
|
||||
srp_request = SrpUserRequest()
|
||||
srp_request.killboard_link = form.cleaned_data['killboard_link']
|
||||
srp_request.additional_info = form.cleaned_data['additional_info']
|
||||
@ -200,6 +201,8 @@ def srp_request_view(request, fleet_srp):
|
||||
completed = True
|
||||
logger.info("Created SRP Request on behalf of user %s for fleet name %s" % (request.user, srp_fleet_main.fleet_name))
|
||||
|
||||
|
||||
srp_request.append()
|
||||
else:
|
||||
logger.debug("Returning blank SrpFleetUserRequestForm")
|
||||
form = SrpFleetUserRequestForm()
|
||||
|
Loading…
x
Reference in New Issue
Block a user