# Path: api/tests/factories.py
# class ProjectFactory(AbstractLocationFactory):
#     name = factory.Sequence(lambda n: 'Smogly Project %04d' % n)
#     website = factory.Sequence(lambda n: 'http://%04d.smogly.org' % n)
#     description = factory.Faker('paragraph', nb_sentences=3, variable_nb_sentences=True)
#     owner = factory.SubFactory(UserFactory)
# 
#     @factory.post_generation
#     def create_logo(self, create, extracted, **kwargs):
#         if extracted in [None, True]:
#             if create:
#                 # add random image from factories assets
#                 source_file_name = 'logo{}.jpg'.format(random.randint(1, 4))
#                 source_path = os.path.join(
#                     os.path.dirname(__file__),
#                     'assets',
#                     'project',
#                     source_file_name
#                 )
#                 # save using ImageField
#                 destination_file_name = '%s.jpg' % Faker().uuid4()
#                 self.logo.save(
#                     destination_file_name,
#                     File(
#                         open(
#                             source_path,
#                             # for python 3.x, we need binary mode
#                             # https://github.com/python-pillow/Pillow/issues/1605#issuecomment-167402651
#                             'rb'
#                         )
#                     )
#                 )
#                 self.save(update_fields=['logo'])
# 
#     class Meta:
#         model = Project
# 
# class StationFactory(AbstractLocationFactory):
#     name = factory.Sequence(lambda n: 'Smogly Station %04d' % n)
#     type = factory.fuzzy.FuzzyChoice([type_choice[0] for type_choice in Station.TYPE_CHOICES])
#     notes = factory.Faker('sentences', nb=3)
#     altitude = FuzzyFloatRound(0.0, 300.0, ndigits=2)
#     project = factory.SubFactory(ProjectFactory, **{
#         'country': factory.SelfAttribute('..country'),
#         'state': factory.SelfAttribute('..state'),
#         'county': factory.SelfAttribute('..county'),
#         'community': factory.SelfAttribute('..community'),
#         'district': factory.SelfAttribute('..district')
#     })
#     owner = factory.SubFactory(UserFactory)
# 
#     class Meta:
#         model = Station
# 
# class MeteringFactory(AbstractMeteringFactory):
#     class Meta:
#         model = Metering


from django.core.management.base import BaseCommand
from django.db import transaction
from django.utils import timezone
from tqdm import tqdm
from api.tests.factories import ProjectFactory, StationFactory, MeteringFactory

    help = 'Populate models with some data, see arguments for possible details.'

    def add_arguments(self, parser):
        parser.add_argument(
            '-p',
            '--projects',
            action='store',
            default=self.__class__.DEFAULT_PROJECTS,
            help='How many Project to create? default={}.'.format(
                self.__class__.DEFAULT_PROJECTS
            ),
            type=int
        )
        parser.add_argument(
            '-s',
            '--stations',
            action='store',
            default=self.__class__.DEFAULT_STATIONS,
            help='How many Station for each Project to create? default={}.'.format(
                self.__class__.DEFAULT_STATIONS
            ),
            type=int
        )
        parser.add_argument(
            '-m',
            '--meterings',
            action='store',
            default=self.__class__.DEFAULT_METERINGS,
            help='How many Metering for each Station to create? default={}.'.format(

# Path: api/tests/factories.py
# class ProjectFactory(AbstractLocationFactory):
#     name = factory.Sequence(lambda n: 'Smogly Project %04d' % n)
#     website = factory.Sequence(lambda n: 'http://%04d.smogly.org' % n)
#     description = factory.Faker('paragraph', nb_sentences=3, variable_nb_sentences=True)
#     owner = factory.SubFactory(UserFactory)
# 
#     @factory.post_generation
#     def create_logo(self, create, extracted, **kwargs):
#         if extracted in [None, True]:
#             if create:
#                 # add random image from factories assets
#                 source_file_name = 'logo{}.jpg'.format(random.randint(1, 4))
#                 source_path = os.path.join(
#                     os.path.dirname(__file__),
#                     'assets',
#                     'project',
#                     source_file_name
#                 )
#                 # save using ImageField
#                 destination_file_name = '%s.jpg' % Faker().uuid4()
#                 self.logo.save(
#                     destination_file_name,
#                     File(
#                         open(
#                             source_path,
#                             # for python 3.x, we need binary mode
#                             # https://github.com/python-pillow/Pillow/issues/1605#issuecomment-167402651
#                             'rb'
#                         )
#                     )
#                 )
#                 self.save(update_fields=['logo'])
# 
#     class Meta:
#         model = Project
# 
# class StationFactory(AbstractLocationFactory):
#     name = factory.Sequence(lambda n: 'Smogly Station %04d' % n)
#     type = factory.fuzzy.FuzzyChoice([type_choice[0] for type_choice in Station.TYPE_CHOICES])
#     notes = factory.Faker('sentences', nb=3)
#     altitude = FuzzyFloatRound(0.0, 300.0, ndigits=2)
#     project = factory.SubFactory(ProjectFactory, **{
#         'country': factory.SelfAttribute('..country'),
#         'state': factory.SelfAttribute('..state'),
#         'county': factory.SelfAttribute('..county'),
#         'community': factory.SelfAttribute('..community'),
#         'district': factory.SelfAttribute('..district')
#     })
#     owner = factory.SubFactory(UserFactory)
# 
#     class Meta:
#         model = Station
# 
# class MeteringFactory(AbstractMeteringFactory):
#     class Meta:
#         model = Metering


# Path: api/management/commands/api_generate_data.py
from django.core.management.base import BaseCommand
from django.db import transaction
from django.utils import timezone
from tqdm import tqdm
from api.tests.factories import ProjectFactory, StationFactory, MeteringFactory


    help = 'Populate models with some data, see arguments for possible details.'

    def add_arguments(self, parser):
        parser.add_argument(
            '-p',
            '--projects',
            action='store',
            default=self.__class__.DEFAULT_PROJECTS,
            help='How many Project to create? default={}.'.format(
                self.__class__.DEFAULT_PROJECTS
            ),
            type=int
        )
        parser.add_argument(
            '-s',
            '--stations',
            action='store',
            default=self.__class__.DEFAULT_STATIONS,
            help='How many Station for each Project to create? default={}.'.format(
                self.__class__.DEFAULT_STATIONS
            ),
            type=int
        )
        parser.add_argument(
            '-m',
            '--meterings',
            action='store',
            default=self.__class__.DEFAULT_METERINGS,
            help='How many Metering for each Station to create? default={}.'.format(

                self.__class__.DEFAULT_METERINGS