# Path: telostats/stations/models.py
# class Station(models.Model):
#     id = models.IntegerField(unique=True, primary_key=True)
#     name = models.CharField(u'name', max_length=100)
#     address = models.CharField(u'address', max_length=100, null=True, blank=True)
#     longitude = models.FloatField(u'longitude')
#     latitude = models.FloatField(u'latitude')
#     polygon = JSONField(u'polygon')
#     poles = models.IntegerField(u'poles')
#     available = models.IntegerField(u'available')
#     visible = models.BooleanField(u'visible', default=False)
# 
#     objects = models.Manager()
#     visible_objects = VisibleStationManager()
# 
#     def __unicode__(self):
#         return u'({}) {}'.format(self.id, self.name)
# 
#     def available_poles(self):
#         return self.available
# 
#     def available_bikes(self):
#         return self.poles - self.available


import json
import logging
from django.core.management.base import NoArgsCommand
from telostats.stations.models import Station
from unipath import FSPath as Path



logging.basicConfig(level=logging.DEBUG)

class Command(NoArgsCommand):
    help = 'Import station polygon JSON data'

    def handle_noargs(self, **options):
        project_dir = Path(__file__).absolute().ancestor(4)
        data_file = project_dir.child('static', 'js', 'station_polys.json')
        with open(data_file, 'r') as f:

# Path: telostats/stations/models.py
# class Station(models.Model):
#     id = models.IntegerField(unique=True, primary_key=True)
#     name = models.CharField(u'name', max_length=100)
#     address = models.CharField(u'address', max_length=100, null=True, blank=True)
#     longitude = models.FloatField(u'longitude')
#     latitude = models.FloatField(u'latitude')
#     polygon = JSONField(u'polygon')
#     poles = models.IntegerField(u'poles')
#     available = models.IntegerField(u'available')
#     visible = models.BooleanField(u'visible', default=False)
# 
#     objects = models.Manager()
#     visible_objects = VisibleStationManager()
# 
#     def __unicode__(self):
#         return u'({}) {}'.format(self.id, self.name)
# 
#     def available_poles(self):
#         return self.available
# 
#     def available_bikes(self):
#         return self.poles - self.available


# Path: telostats/stations/management/commands/import_station_json.py
import json
import logging
from django.core.management.base import NoArgsCommand
from telostats.stations.models import Station
from unipath import FSPath as Path




logging.basicConfig(level=logging.DEBUG)

class Command(NoArgsCommand):
    help = 'Import station polygon JSON data'

    def handle_noargs(self, **options):
        project_dir = Path(__file__).absolute().ancestor(4)
        data_file = project_dir.child('static', 'js', 'station_polys.json')
        with open(data_file, 'r') as f:

            data = json.loads(f.read())