from django.contrib.auth import get_user_model
from django.utils.text import slugify
from faker import Faker

from import DemoHistoricalDataBuilder
from betterself import celery_app
from betterself.users.models import DemoUserLog

User = get_user_model()

def create_demo_fixtures():
    fake = Faker()
    name =

    # have username be demo-username, so demos-users are easy to tell
    username = 'demo-{name}'.format(name=name)
    username = slugify(username)

    # since these are demo accounts, just set the username/pass the same
    # so this is a really weird bug since you'd wonder why this would be a get_or_create
    # but faker doesn't always generate fake names in celery instances ...
    user, _ = User.objects.get_or_create(username=username)

    # create a log of this person as a demo user, otherwise we would never be able to tell if someone is a demo or not!
    _, created = DemoUserLog.objects.get_or_create(user=user)
    if not created:

    fixtures_builder = DemoHistoricalDataBuilder(user, periods_back=180)