Пример #1
0
def _populate_database():
    get_user_model().objects.create_user(username='******', password='******')
    get_user_model().objects.create_superuser(username='******', password='******')

    for farmer_name in ('Philippe', 'Pierre', 'Agnès'):
        email = farmer_name + "@farmer.com"
        get_user_model().objects.create_user(farmer_name, email=email, password="******")

        farmer = Farmer(
            name=farmer_name,
            lat=45.1808,
            lon=1.893,
            email=email,
            approved=True,
        )
        farmer.save()

    for experiment_name in ('Faux semis', 'Allongement', 'Lâchés de trichos'):
        experiment = Experiment(
            name=experiment_name,
            farmer=Farmer.objects.filter(name='Pierre').first(),
            state='Validé',
        )
        experiment.save()

    Experiment(
        name="Association de cultures",
        farmer=Farmer.objects.filter(name='Agnès').first(),
        state="Brouillon"
    ).save()
Пример #2
0
def _populate_database():
    get_user_model().objects.create_superuser(username='******', password='******')

    # Approved farmers
    for farmer_name in ('Philippe', 'Pierre', 'Agnès'):
        email = farmer_name + "@farmer.com"
        get_user_model().objects.create_user(farmer_name, email=email, password="******")
        farmer = Farmer(
            name=farmer_name,
            lat=45.1808,
            lon=1.893,
            email=email,
            approved=True,
        )
        farmer.save()

    # Unapproved farmers
    get_user_model().objects.create_user("Edouard", email="*****@*****.**", password="******")
    Farmer(
        name="Edouard",
        email="*****@*****.**",
        lat=0.0,
        lon=0.0,
        approved=False,
        phone_number='012345678'
    ).save()

    # Approved experiments
    for experiment_name in ('Faux semis', 'Allongement', 'Lâchés de trichos'):
        experiment = Experiment(
            name=experiment_name,
            farmer=Farmer.objects.filter(name='Pierre').first(),
            state='Validé',
        )
        experiment.save()

    Experiment(
        name="Culture de millet",
        farmer=Farmer.objects.filter(name='Edouard').first(),
        state='Validé',
    ).save()

    # Unapproved experiments
    Experiment(
        name="Vente directe",
        farmer=Farmer.objects.filter(name='Pierre').first(),
        state='Brouillon',
    ).save()

    Experiment(
        name="Couvert de sarrasin",
        farmer=Farmer.objects.filter(name='Edouard').first(),
        state='Brouillon',
    ).save()
Пример #3
0
def _populate_database():
    User.objects.create_user(username='******', password='******')
    User.objects.create_superuser(username='******', password='******')

    for farmer_name in ('Philippe', 'Pierre', 'Agnès'):
        email = farmer_name + "@farmer.com"
        User.objects.create_user(farmer_name, email=email, password="******")

        farmer = Farmer(
            name=farmer_name,
            lat=45.1808,
            lon=1.893,
            email=email,
            approved=True,
        )
        farmer.save()

    for experiment_name in ('Faux semis', 'Allongement', 'Lâchés de trichos'):
        experiment = Experiment(
            name=experiment_name,
            farmer=Farmer.objects.filter(name='Pierre').first(),
            approved=True,
        )
        experiment.save()
Пример #4
0
def _populate_database():
    get_user_model().objects.create_superuser(username='******', password='******')

    # Approved farmers
    for farmer_name in ('Philippe', 'Pierre', 'Agnès'):
        email = farmer_name + "@farmer.com"
        get_user_model().objects.create_user(farmer_name, email=email, password="******")
        farmer = Farmer(
            name=farmer_name,
            lat=45.1808,
            lon=1.893,
            email=email,
            approved=True,
        )
        farmer.save()

    # Unapproved farmers
    get_user_model().objects.create_user("Edouard", email="*****@*****.**", password="******")
    Farmer(
        name="Edouard",
        email="*****@*****.**",
        lat=0.0,
        lon=0.0,
        approved=False,
        phone_number='012345678'
    ).save()

    philippe = Farmer.objects.get(name="Philippe")
    pierre = Farmer.objects.get(name="Pierre")
    agnes = Farmer.objects.get(name="Agnès")
    edouard = Farmer.objects.get(name="Edouard")

    # Approved experiments
    for experiment_name in ('Faux semis', 'Allongement', 'Lâchés de tricos'):
        experiment = Experiment(
            name=experiment_name,
            farmer=Farmer.objects.filter(name='Pierre').first(),
            state='Validé',
        )
        experiment.save()

    Experiment(
        name="Culture de millet",
        farmer=Farmer.objects.filter(name='Edouard').first(),
        state='Validé',
    ).save()

    # Unapproved experiments
    Experiment(
        name="Vente directe",
        farmer=Farmer.objects.filter(name='Pierre').first(),
        state='Brouillon',
    ).save()

    Experiment(
        name="Couvert de sarrasin",
        farmer=Farmer.objects.filter(name='Edouard').first(),
        state='Brouillon',
    ).save()

    # Active themes
    desherbage_theme = Theme(
        name="Désherbage",
        active=True,
        description="Description désherbage",
    )
    desherbage_theme.save()
    desherbage_theme.experiments.set([
        Experiment.objects.get(name="Faux semis"),
        Experiment.objects.get(name="Allongement"),
    ])
    

    tricos_theme = Theme(
        name="Les tricos",
        active=True,
        description="Description tricos",
    )
    tricos_theme.save()
    tricos_theme.experiments.set([
        Experiment.objects.get(name="Vente directe"), # not approved yet
        Experiment.objects.get(name="Lâchés de tricos"),
    ])
    

    autres_theme = Theme(
        name="Autres",
        active=False,
        description="Description autres",
    )
    autres_theme.save()
    autres_theme.experiments.set([
        Experiment.objects.get(name="Vente directe"), # not approved yet
        Experiment.objects.get(name="Culture de millet"),
    ])
Пример #5
0
def _populate_database():
    User.objects.create_superuser(username='******', password='******')

    # Approved farmers
    for farmer_name in ('Philippe', 'Pierre', 'Agnès'):
        email = farmer_name + "@farmer.com"
        User.objects.create_user(farmer_name, email=email, password="******")
        farmer = Farmer(
            name=farmer_name,
            lat=45.1808,
            lon=1.893,
            email=email,
            approved=True,
        )
        farmer.save()

    # Unapproved farmers
    User.objects.create_user("Edouard",
                             email="*****@*****.**",
                             password="******")
    Farmer(name="Edouard",
           email="*****@*****.**",
           lat=0.0,
           lon=0.0,
           approved=False,
           phone_number='012345678').save()

    philippe = Farmer.objects.get(name="Philippe")
    pierre = Farmer.objects.get(name="Pierre")
    agnes = Farmer.objects.get(name="Agnès")
    edouard = Farmer.objects.get(name="Edouard")

    # Approved experiments
    for experiment_name in ('Faux semis', 'Allongement', 'Lâchés de trichos'):
        experiment = Experiment(
            name=experiment_name,
            farmer=Farmer.objects.filter(name='Pierre').first(),
            approved=True,
        )
        experiment.save()

    Experiment(
        name="Culture de millet",
        farmer=Farmer.objects.filter(name='Edouard').first(),
        approved=True,
    ).save()

    # Unapproved experiments
    Experiment(
        name="Vente directe",
        farmer=Farmer.objects.filter(name='Pierre').first(),
        approved=False,
    ).save()

    Experiment(
        name="Couvert de sarrasin",
        farmer=Farmer.objects.filter(name='Edouard').first(),
        approved=False,
    ).save()

    # Message exchange between Philippe and Pierre
    Message(
        sender=philippe,
        recipient=pierre,
    ).save()
    Message(
        sender=pierre,
        recipient=philippe,
    ).save()
    Message(
        sender=philippe,
        recipient=pierre,
    ).save()

    # Message exchange between Agnès and Edouard
    Message(
        sender=edouard,
        recipient=agnes,
    ).save()
    Message(
        sender=agnes,
        recipient=edouard,
    ).save()

    # Single message from Agnès Pierre
    Message(
        sender=agnes,
        recipient=pierre,
    ).save()