Exemple #1
0
    def handle(self, *args, **options):

        country = Country.objects.all()[0]
        modification = Modification.objects.all()[0]

        for index in range(1, 150):

            # создать два аэропорта
            p1 = Port.objects.create(
                name=get_random_string(10),
                country=country,
                latitude=random.randint(-10000000, 10000000),
                longitude=random.randint(-10000000, 10000000),
                altitude=random.randint(10, 2000),
            )
            p2 = Port.objects.create(
                name=get_random_string(10),
                country=country,
                latitude=random.randint(-10000000, 10000000),
                longitude=random.randint(-10000000, 10000000),
                altitude=random.randint(10, 2000),
            )

            # создать расписание
            s = Schedule.objects.create()
            SchedulePort.objects.create(port=p1, schedule=s)
            SchedulePort.objects.create(port=p2, schedule=s)

            # создать самолет
            Plane.objects.create(**{
                'name': get_random_string(10),
                'modification': modification,
                'schedule': s,
            })
Exemple #2
0
def create_port():
    """
    create airport
    :return:Port instance
    """
    return Port.objects.create(
        **dict(name=get_random_string(length=10), country=create_country(), latitude=100, longitude=100, altitude=12)
    )
Exemple #3
0
def create_country():
    """
    create Country
    :return: Country instance
    """
    return Country.objects.create(name=get_random_string(length=10))