mirror of
https://github.com/nikdoof/limetime.git
synced 2025-12-20 22:19:26 +00:00
Initial import of codebase
This commit is contained in:
24
app/timer/management/commands/import_stations.py
Normal file
24
app/timer/management/commands/import_stations.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import transaction
|
||||
from timer.models import Station, System
|
||||
from eveapi import EVEAPIConnection
|
||||
|
||||
class Command(BaseCommand):
|
||||
args = ''
|
||||
help = 'Updates conquerable stations from the EVE API'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
api = EVEAPIConnection()
|
||||
|
||||
station_list = api.eve.ConquerableStationList().outposts
|
||||
print 'Updating %d stations... ' % len(station_list)
|
||||
with transaction.commit_on_success():
|
||||
for station in station_list:
|
||||
try:
|
||||
obj = Station.objects.get(pk=station.stationID)
|
||||
except Station.DoesNotExist:
|
||||
obj = Station(pk=station.stationID)
|
||||
obj.system, created = System.objects.get_or_create(pk=station.solarSystemID)
|
||||
obj.name = station.stationName
|
||||
obj.save()
|
||||
print 'Done'
|
||||
Reference in New Issue
Block a user