Exemplo n.º 1
0
def create_teachers(count):
    if Teacher.objects.all():
        print('Преподаватели уже добавлены')
        return
    with Faker.override_default_locale('ru_RU'):
        for i in range(count):
            factory = TeacherFactory
            factory.create()
    print('Преподаватели успешно добавлены')
Exemplo n.º 2
0
def create_students(count):
    if Student.objects.all():
        print('Студенты уже добавлены')
        return
    with Faker.override_default_locale('ru_RU'):
        for i in range(count):
            factory = StudentFactory
            factory.create()
    print('Студенты успешно добавлены')
Exemplo n.º 3
0
 def handle(self, *args, **options):
     if CourseGroup.objects.all():
         print('Курсы и группы уже добавлены')
         return
     all_teachers = Teacher.objects.all()
     all_students = Student.objects.all()
     if not (all_teachers and all_students):
         print('Сначала добавьте пользователей')
         return
     with Faker.override_default_locale('ru_RU'):
         course_factory = CourseFactory
         group_factory = CourseGroupFactory
         for c in range(15):
             course = add_course(course_factory, all_teachers)
             add_course_group(group_factory, course, all_students)
     print('Курсы и группы успешно добавлены')
Exemplo n.º 4
0
from sendengo.apps.shippers.models import Shipper, ShipperRequirement
from factory import DjangoModelFactory, Faker, post_generation, SubFactory
from sendengo.apps.catalog.tests.factories import CatalogRequirementFactory

Faker.override_default_locale('es_ES')


class ShipperFactory(DjangoModelFactory):

    company_name = Faker("company", locale='es_MX')
    address = Faker("address")
    phone = Faker("random_number")
    email = Faker("email")
    num_requirements = 0

    class Meta:
        model = Shipper


class ShipperRequirementFactory(DjangoModelFactory):

    shipper = SubFactory(ShipperFactory)

    requirement = SubFactory(CatalogRequirementFactory)

    # category is assigned automiticly <shipper.models.py save method>

    class Meta:
        model = ShipperRequirement