mirror of
https://github.com/nikdoof/django-evesde.git
synced 2025-12-20 13:19:23 +00:00
25 lines
769 B
Python
25 lines
769 B
Python
from django.db import transaction
|
|
|
|
from evesde.models.locations import Station
|
|
from evesde.eveapi import get_api_connection
|
|
|
|
|
|
def import_conquerable_stations():
|
|
"""Import all conquerable stations and outposts from the EVE API"""
|
|
api = get_api_connection()
|
|
stations = Station.objects.all()
|
|
|
|
objs = []
|
|
for station in api.eve.ConquerableStationList().outposts:
|
|
print "Importing %s" % station.stationName
|
|
try:
|
|
obj = stations.get(pk=station.stationID)
|
|
except Station.DoesNotExist:
|
|
obj = Station(pk=station.stationID)
|
|
obj.name = station.stationName
|
|
obj.system_id = station.solarSystemID
|
|
objs.append(obj)
|
|
|
|
with transaction.atomic():
|
|
for obj in objs:
|
|
obj.save() |