Ejemplo n.º 1
0
def add(request):
    """
    Add a new nutrition plan and redirect to its page
    """

    plan = NutritionPlan()
    plan.user = request.user
    plan.language = load_language()
    plan.save()

    return HttpResponseRedirect(reverse("nutrition:plan:view", kwargs={"id": plan.id}))
Ejemplo n.º 2
0
Archivo: plan.py Proyecto: romansp/wger
def add(request):
    '''
    Add a new nutrition plan and redirect to its page
    '''

    plan = NutritionPlan()
    plan.user = request.user
    plan.language = load_language()
    plan.save()

    return HttpResponseRedirect(reverse('nutrition:plan:view', kwargs={'id': plan.id}))
Ejemplo n.º 3
0
    def export_pdf(self, fail=False):
        '''
        Helper function to test exporting a nutritional plan as a pdf
        '''

        # Get a plan
        response = self.client.get(reverse('nutrition:plan:export-pdf',
                                   kwargs={'id': 4}))

        if fail:
            self.assertIn(response.status_code, (404, 403))
        else:
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response['Content-Type'], 'application/pdf')
            self.assertEqual(response['Content-Disposition'],
                             'attachment; filename=nutritional-plan.pdf')

            # Approximate size
            self.assertGreater(int(response['Content-Length']), 29000)
            self.assertLess(int(response['Content-Length']), 34000)

        # Create an empty plan
        user = User.objects.get(pk=2)
        language = Language.objects.get(pk=1)
        plan = NutritionPlan()
        plan.user = user
        plan.language = language
        plan.save()
        response = self.client.get(reverse('nutrition:plan:export-pdf',
                                   kwargs={'id': plan.id}))

        if fail:
            self.assertIn(response.status_code, (404, 403))
        else:
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response['Content-Type'], 'application/pdf')
            self.assertEqual(response['Content-Disposition'],
                             'attachment; filename=nutritional-plan.pdf')

            # Approximate size
            self.assertGreater(int(response['Content-Length']), 29000)
            self.assertLess(int(response['Content-Length']), 33420)
Ejemplo n.º 4
0
Archivo: pdf.py Proyecto: seraphyn/wger
    def export_pdf(self, fail=False):
        '''
        Helper function to test exporting a nutritional plan as a pdf
        '''

        # Get a plan
        response = self.client.get(reverse('wger.nutrition.views.plan.export_pdf',
                                   kwargs={'id': 4}))

        if fail:
            self.assertIn(response.status_code, (404, 302))
        else:
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response['Content-Type'], 'application/pdf')
            self.assertEqual(response['Content-Disposition'],
                             'attachment; filename=nutritional-plan.pdf')

            # Approximate size, there's a timestamp in the document
            self.assertGreater(len(response.content), 2800)

        # Create an empty plan
        user = User.objects.get(pk=2)
        language = Language.objects.get(pk=1)
        plan = NutritionPlan()
        plan.user = user
        plan.language = language
        plan.save()
        response = self.client.get(reverse('wger.nutrition.views.plan.export_pdf',
                                   kwargs={'id': plan.id}))

        if fail:
            self.assertIn(response.status_code, (404, 302))
        else:
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response['Content-Type'], 'application/pdf')
            self.assertEqual(response['Content-Disposition'],
                             'attachment; filename=nutritional-plan.pdf')

            # Approximate size, there's a timestamp in the document
            self.assertGreater(len(response.content), 2800)
Ejemplo n.º 5
0
def add(request):
    '''
    Add a new nutrition plan and redirect to its page
    '''

    plan = NutritionPlan()
    plan.user = request.user
    plan.language = load_language()
    plan.save()

    return HttpResponseRedirect(reverse('nutrition:plan:view', kwargs={'id': plan.id}))
Ejemplo n.º 6
0
    def export_pdf(self, fail=False):
        '''
        Helper function to test exporting a nutritional plan as a pdf
        '''

        # Get a plan
        response = self.client.get(
            reverse('wger.nutrition.views.plan.export_pdf', kwargs={'id': 4}))

        if fail:
            self.assertIn(response.status_code, (404, 302))
        else:
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response['Content-Type'], 'application/pdf')
            self.assertEqual(response['Content-Disposition'],
                             'attachment; filename=nutritional-plan.pdf')

            # Approximate size
            self.assertGreater(int(response['Content-Length']), 31000)
            self.assertLess(int(response['Content-Length']), 34000)

        # Create an empty plan
        user = User.objects.get(pk=2)
        language = Language.objects.get(pk=1)
        plan = NutritionPlan()
        plan.user = user
        plan.language = language
        plan.save()
        response = self.client.get(
            reverse('wger.nutrition.views.plan.export_pdf',
                    kwargs={'id': plan.id}))

        if fail:
            self.assertIn(response.status_code, (404, 302))
        else:
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response['Content-Type'], 'application/pdf')
            self.assertEqual(response['Content-Disposition'],
                             'attachment; filename=nutritional-plan.pdf')

            # Approximate size
            self.assertGreater(int(response['Content-Length']), 31000)
            self.assertLess(int(response['Content-Length']), 33420)
Ejemplo n.º 7
0
 def create_nutrition_plan(self):
     """
     Create a nutrition plan and set dummy attributes that are required
     Create meal and set dummy attributes that are required
     Create meal item and set dummy attributes that are required
     """
     nutrition_plan = NutritionPlan()
     nutrition_plan.user = User.objects.create_user(username='******')
     nutrition_plan.language = Language.objects.get(short_name="en")
     nutrition_plan.save()
     meal = Meal()
     meal.plan = nutrition_plan
     meal.order = 1
     meal.save()
     meal_item = MealItem()
     meal_item.id = 1
     meal_item.meal = meal
     meal_item.amount = 1
     meal_item.ingredient_id = 1
     meal_item.order = 1
     test_objects = [nutrition_plan, meal, meal_item]
     return test_objects
Ejemplo n.º 8
0
    # Load all ingredients to a list
    ingredientList = [i for i in Ingredient.objects.order_by('?').all()[:100]]

    # Total meals per plan
    total_meals = 4

    for user in userlist:
        print('   - generating for {0}'.format(user.username))

        # Add nutrition plan
        for i in range(0, args.number_nutrition_plans):
            uid = str(uuid.uuid4()).split('-')
            start_date = datetime.date.today() - datetime.timedelta(
                days=random.randint(0, 100))
            nutrition_plan = NutritionPlan(
                language=Language.objects.all()[1],
                description='Dummy nutrition plan - {0}'.format(uid[1]),
                creation_date=start_date)
            nutrition_plan.user = user

            nutrition_plan.save()

            # Add meals to plan
            order = 1
            for j in range(0, total_meals):
                meal = Meal(plan=nutrition_plan, order=order)
                meal.save()
                for k in range(0, random.randint(1, 5)):
                    ingredient = random.choice(ingredientList)
                    meal_item = MealItem(meal=meal,
                                         ingredient=ingredient,
                                         weight_unit=None,
Ejemplo n.º 9
0
def create_demo_entries(user):
    """
    Creates some demo data for temporary users
    """

    # (this is a bit ugly and long...)
    language = load_language()

    #
    # Workout and exercises
    #
    setting_list = []
    weight_log = []
    workout = Workout(user=user, name=_('Sample workout'))
    workout.save()
    monday = DaysOfWeek.objects.get(pk=1)
    wednesday = DaysOfWeek.objects.get(pk=3)
    day = Day(training=workout, description=_('Sample day'))
    day.save()
    day.day.add(monday)

    day2 = Day(training=workout, description=_('Another sample day'))
    day2.save()
    day2.day.add(wednesday)

    # Biceps curls with dumbbell
    if language.short_name == 'de':
        exercise = Exercise.objects.get(pk=26)
    else:
        exercise = Exercise.objects.get(pk=81)
    day_set = Set(exerciseday=day, sets=4, order=2)
    day_set.save()

    setting = Setting(set=day_set, exercise=exercise, reps=8, order=1)
    setting.save()

    # Weight log entries
    for reps in (8, 10, 12):
        for i in range(1, 8):
            log = WorkoutLog(user=user,
                             exercise=exercise,
                             workout=workout,
                             reps=reps,
                             weight=18 - reps + random.randint(1, 4),
                             date=datetime.date.today() -
                             datetime.timedelta(weeks=i))
            weight_log.append(log)

    # French press
    if language.short_name == 'de':
        exercise = Exercise.objects.get(pk=25)
    else:
        exercise = Exercise.objects.get(pk=84)
    day_set = Set(exerciseday=day, sets=4, order=2)
    day_set.save()

    setting_list.append(
        Setting(set=day_set, exercise=exercise, reps=8, order=1))

    # Weight log entries
    for reps in (7, 10):
        for i in range(1, 8):
            log = WorkoutLog(user=user,
                             exercise=exercise,
                             workout=workout,
                             reps=reps,
                             weight=30 - reps + random.randint(1, 4),
                             date=datetime.date.today() -
                             datetime.timedelta(weeks=i))
            weight_log.append(log)

    # Squats
    if language.short_name == 'de':
        exercise = Exercise.objects.get(pk=6)
    else:
        exercise = Exercise.objects.get(pk=111)
    day_set = Set(exerciseday=day, sets=4, order=3)
    day_set.save()

    setting_list.append(
        Setting(set=day_set, exercise=exercise, reps=10, order=1))

    # Weight log entries
    for reps in (5, 10, 12):
        for i in range(1, 8):
            log = WorkoutLog(user=user,
                             exercise=exercise,
                             workout=workout,
                             reps=reps,
                             weight=110 - reps + random.randint(1, 10),
                             date=datetime.date.today() -
                             datetime.timedelta(weeks=i))
            weight_log.append(log)

    # Crunches
    if language.short_name == 'de':
        exercise = Exercise.objects.get(pk=4)
    else:
        exercise = Exercise.objects.get(pk=91)
    day_set = Set(exerciseday=day, sets=4, order=4)
    day_set.save()

    setting_list.append(
        Setting(set=day_set, exercise=exercise, reps=30, order=1))
    setting_list.append(
        Setting(set=day_set, exercise=exercise, reps=99, order=2))
    setting_list.append(
        Setting(set=day_set, exercise=exercise, reps=35, order=3))

    # Leg raises, supersets with crunches
    if language.short_name == 'de':
        exercise = Exercise.objects.get(pk=35)
    else:
        exercise = Exercise.objects.get(pk=126)

    setting_list.append(
        Setting(set=day_set, exercise=exercise, reps=30, order=1))
    setting_list.append(
        Setting(set=day_set, exercise=exercise, reps=40, order=2))
    setting_list.append(
        Setting(set=day_set, exercise=exercise, reps=99, order=3))

    Setting.objects.bulk_create(setting_list)

    # Save all the log entries
    WorkoutLog.objects.bulk_create(weight_log)

    #
    # (Body) weight entries
    #
    temp = []
    existing_entries = [i.date for i in WeightEntry.objects.filter(user=user)]
    for i in range(1, 20):
        creation_date = datetime.date.today() - datetime.timedelta(days=i)
        if creation_date not in existing_entries:
            entry = WeightEntry(user=user,
                                weight=80 + 0.5 * i + random.randint(1, 3),
                                date=creation_date)
            temp.append(entry)
    WeightEntry.objects.bulk_create(temp)

    #
    # Nutritional plan
    #
    plan = NutritionPlan()
    plan.user = user
    plan.language = language
    plan.description = _('Sample nutrional plan')
    plan.save()

    # Breakfast
    meal = Meal()
    meal.plan = plan
    meal.order = 1
    meal.time = datetime.time(7, 30)
    meal.save()

    # Oatmeal
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8197)
    else:
        ingredient = Ingredient.objects.get(pk=2126)

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.ingredient = ingredient
    mealitem.order = 1
    mealitem.amount = 100
    mealitem.save()

    # Milk
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8198)
    else:
        ingredient = Ingredient.objects.get(pk=154)

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.ingredient = ingredient
    mealitem.order = 2
    mealitem.amount = 100
    mealitem.save()

    # Protein powder
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8244)
    else:
        ingredient = Ingredient.objects.get(pk=196)

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.ingredient = ingredient
    mealitem.order = 3
    mealitem.amount = 30
    mealitem.save()

    #
    # 11 o'clock meal
    meal = Meal()
    meal.plan = plan
    meal.order = 2
    meal.time = datetime.time(11, 0)
    meal.save()

    # Bread, in slices
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8225)
        unit = None
        amount = 80
    else:
        ingredient = Ingredient.objects.get(pk=5370)
        unit = IngredientWeightUnit.objects.get(pk=9874)
        amount = 2

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.ingredient = ingredient
    mealitem.weight_unit = unit
    mealitem.order = 1
    mealitem.amount = amount
    mealitem.save()

    # Turkey
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8201)
    else:
        ingredient = Ingredient.objects.get(pk=1643)

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.order = 2
    mealitem.ingredient = ingredient
    mealitem.amount = 100
    mealitem.save()

    # Cottage cheese
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8222)  # TODO: check this!
    else:
        ingredient = Ingredient.objects.get(pk=17)

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.ingredient = ingredient
    mealitem.order = 3
    mealitem.amount = 50
    mealitem.save()

    # Tomato, one
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8217)
        unit = None
        amount = 120
    else:
        ingredient = Ingredient.objects.get(pk=3208)
        unit = IngredientWeightUnit.objects.get(pk=5950)
        amount = 1

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.weight_unit = unit
    mealitem.ingredient = ingredient
    mealitem.order = 4
    mealitem.amount = amount
    mealitem.save()

    #
    # Lunch (leave empty so users can add their own ingredients)
    meal = Meal()
    meal.plan = plan
    meal.order = 3
    meal.time = datetime.time(13, 0)
    meal.save()

    #
    # Workout schedules
    #

    # create some empty workouts to fill the list
    workout2 = Workout(
        user=user, name=_('Placeholder workout nr {0} for schedule').format(1))
    workout2.save()
    workout3 = Workout(
        user=user, name=_('Placeholder workout nr {0} for schedule').format(2))
    workout3.save()
    workout4 = Workout(
        user=user, name=_('Placeholder workout nr {0} for schedule').format(3))
    workout4.save()

    schedule = Schedule()
    schedule.user = user
    schedule.name = _('My cool workout schedule')
    schedule.start_date = datetime.date.today() - datetime.timedelta(weeks=4)
    schedule.is_active = True
    schedule.is_loop = True
    schedule.save()

    # Add the workouts
    step = ScheduleStep()
    step.schedule = schedule
    step.workout = workout2
    step.duration = 2
    step.order = 1
    step.save()

    step = ScheduleStep()
    step.schedule = schedule
    step.workout = workout
    step.duration = 4
    step.order = 2
    step.save()

    step = ScheduleStep()
    step.schedule = schedule
    step.workout = workout3
    step.duration = 1
    step.order = 3
    step.save()

    step = ScheduleStep()
    step.schedule = schedule
    step.workout = workout4
    step.duration = 6
    step.order = 4
    step.save()

    #
    # Add two more schedules, to make the overview more interesting
    schedule = Schedule()
    schedule.user = user
    schedule.name = _('Empty placeholder schedule')
    schedule.start_date = datetime.date.today() - datetime.timedelta(weeks=15)
    schedule.is_active = False
    schedule.is_loop = False
    schedule.save()

    step = ScheduleStep()
    step.schedule = schedule
    step.workout = workout2
    step.duration = 2
    step.order = 1
    step.save()

    schedule = Schedule()
    schedule.user = user
    schedule.name = _('Empty placeholder schedule')
    schedule.start_date = datetime.date.today() - datetime.timedelta(weeks=30)
    schedule.is_active = False
    schedule.is_loop = False
    schedule.save()

    step = ScheduleStep()
    step.schedule = schedule
    step.workout = workout4
    step.duration = 2
    step.order = 1
    step.save()
Ejemplo n.º 10
0
        userlist = [i for i in User.objects.all()]

    # Load all ingredients to a list
    ingredientList = [i for i in Ingredient.objects.order_by('?').all()[:100]]

    # Total meals per plan
    total_meals = 4
    
    for user in userlist:
        print('   - generating for {0}'.format(user.username))

        # Add nutrition plan
        for i in range(0, args.number_nutrition_plans):
            uid = str(uuid.uuid4()).split('-')
            start_date = datetime.date.today() - datetime.timedelta(days=random.randint(0, 100))
            nutrition_plan = NutritionPlan(language=Language.objects.all()[1], description='Dummy nutrition plan - {0}'.format(uid[1]),
                              creation_date=start_date)
            nutrition_plan.user = user

            nutrition_plan.save()

            # Add meals to plan
            order = 1
            for j in range(0, total_meals):
                meal = Meal(plan=nutrition_plan, order=order)
                meal.save()
                for k in range(0, random.randint(1,5)):
                    ingredient = random.choice(ingredientList)
                    meal_item = MealItem(meal=meal, ingredient=ingredient, weight_unit=None, order=order, amount=random.randint(10, 250))
                    meal_item.save()
                order = order + 1
Ejemplo n.º 11
0
def create_demo_entries(user):
    '''
    Creates some demo data for temporary users
    '''

    # (this is a bit ugly and long...)
    language = load_language()

    #
    # Workout and exercises
    #
    setting_list = []
    weight_log = []
    workout = Workout(user=user, comment=_('Sample workout'))
    workout.save()
    monday = DaysOfWeek.objects.get(pk=1)
    wednesday = DaysOfWeek.objects.get(pk=3)
    day = Day(training=workout, description=_('Sample day'))
    day.save()
    day.day.add(monday)

    day2 = Day(training=workout, description=_('Another sample day'))
    day2.save()
    day2.day.add(wednesday)

    # Biceps curls with dumbbell
    if language.short_name == 'de':
        exercise = Exercise.objects.get(pk=26)
    else:
        exercise = Exercise.objects.get(pk=81)
    day_set = Set(exerciseday=day, sets=4, order=2)
    day_set.save()
    day_set.exercises.add(exercise)

    setting = Setting(set=day_set, exercise=exercise, reps=8, order=1)
    setting.save()

    # Weight log entries
    for reps in (8, 10, 12):
        for i in range(1, 8):
            log = WorkoutLog(user=user,
                             exercise=exercise,
                             workout=workout,
                             reps=reps,
                             weight=18 - reps + random.randint(1, 4),
                             date=datetime.date.today() - datetime.timedelta(weeks=i))
            weight_log.append(log)

    # French press
    if language.short_name == 'de':
        exercise = Exercise.objects.get(pk=25)
    else:
        exercise = Exercise.objects.get(pk=84)
    day_set = Set(exerciseday=day, sets=4, order=2)
    day_set.save()
    day_set.exercises.add(exercise)

    setting_list.append(Setting(set=day_set, exercise=exercise, reps=8, order=1))

    # Weight log entries
    for reps in (7, 10):
        for i in range(1, 8):
            log = WorkoutLog(user=user,
                             exercise=exercise,
                             workout=workout,
                             reps=reps,
                             weight=30 - reps + random.randint(1, 4),
                             date=datetime.date.today() - datetime.timedelta(weeks=i))
            weight_log.append(log)

    # Squats
    if language.short_name == 'de':
        exercise = Exercise.objects.get(pk=6)
    else:
        exercise = Exercise.objects.get(pk=111)
    day_set = Set(exerciseday=day, sets=4, order=3)
    day_set.save()
    day_set.exercises.add(exercise)

    setting_list.append(Setting(set=day_set, exercise=exercise, reps=10, order=1))

    # Weight log entries
    for reps in (5, 10, 12):
        for i in range(1, 8):
            log = WorkoutLog(user=user,
                             exercise=exercise,
                             workout=workout,
                             reps=reps,
                             weight=110 - reps + random.randint(1, 10),
                             date=datetime.date.today() - datetime.timedelta(weeks=i))
            weight_log.append(log)

    # Crunches
    if language.short_name == 'de':
        exercise = Exercise.objects.get(pk=4)
    else:
        exercise = Exercise.objects.get(pk=91)
    day_set = Set(exerciseday=day, sets=4, order=4)
    day_set.save()
    day_set.exercises.add(exercise)

    setting_list.append(Setting(set=day_set, exercise=exercise, reps=30, order=1))
    setting_list.append(Setting(set=day_set, exercise=exercise, reps=99, order=2))
    setting_list.append(Setting(set=day_set, exercise=exercise, reps=35, order=3))

    # Leg raises, supersets with crunches
    if language.short_name == 'de':
        exercise = Exercise.objects.get(pk=35)
    else:
        exercise = Exercise.objects.get(pk=126)
    day_set.exercises.add(exercise)

    setting_list.append(Setting(set=day_set, exercise=exercise, reps=30, order=1))
    setting_list.append(Setting(set=day_set, exercise=exercise, reps=40, order=2))
    setting_list.append(Setting(set=day_set, exercise=exercise, reps=99, order=3))

    Setting.objects.bulk_create(setting_list)

    # Save all the log entries
    WorkoutLog.objects.bulk_create(weight_log)

    #
    # (Body) weight entries
    #
    temp = []
    existing_entries = [i.date for i in WeightEntry.objects.filter(user=user)]
    for i in range(1, 20):
        creation_date = datetime.date.today() - datetime.timedelta(days=i)
        if creation_date not in existing_entries:
            entry = WeightEntry(user=user,
                                weight=80 + 0.5 * i + random.randint(1, 3),
                                date=creation_date)
            temp.append(entry)
    WeightEntry.objects.bulk_create(temp)

    #
    # Nutritional plan
    #
    plan = NutritionPlan()
    plan.user = user
    plan.language = language
    plan.description = _('Sample nutrional plan')
    plan.save()

    # Breakfast
    meal = Meal()
    meal.plan = plan
    meal.order = 1
    meal.time = datetime.time(7, 30)
    meal.save()

    # Oatmeal
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8197)
    else:
        ingredient = Ingredient.objects.get(pk=2126)

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.ingredient = ingredient
    mealitem.order = 1
    mealitem.amount = 100
    mealitem.save()

    # Milk
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8198)
    else:
        ingredient = Ingredient.objects.get(pk=154)

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.ingredient = ingredient
    mealitem.order = 2
    mealitem.amount = 100
    mealitem.save()

    # Protein powder
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8244)
    else:
        ingredient = Ingredient.objects.get(pk=196)

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.ingredient = ingredient
    mealitem.order = 3
    mealitem.amount = 30
    mealitem.save()

    #
    # 11 o'clock meal
    meal = Meal()
    meal.plan = plan
    meal.order = 2
    meal.time = datetime.time(11, 0)
    meal.save()

    # Bread, in slices
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8225)
        unit = None
        amount = 80
    else:
        ingredient = Ingredient.objects.get(pk=5370)
        unit = IngredientWeightUnit.objects.get(pk=9874)
        amount = 2

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.ingredient = ingredient
    mealitem.weight_unit = unit
    mealitem.order = 1
    mealitem.amount = amount
    mealitem.save()

    # Turkey
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8201)
    else:
        ingredient = Ingredient.objects.get(pk=1643)

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.order = 2
    mealitem.ingredient = ingredient
    mealitem.amount = 100
    mealitem.save()

    # Cottage cheese
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8222)  # TODO: check this!
    else:
        ingredient = Ingredient.objects.get(pk=17)

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.ingredient = ingredient
    mealitem.order = 3
    mealitem.amount = 50
    mealitem.save()

    # Tomato, one
    if language.short_name == 'de':
        ingredient = Ingredient.objects.get(pk=8217)
        unit = None
        amount = 120
    else:
        ingredient = Ingredient.objects.get(pk=3208)
        unit = IngredientWeightUnit.objects.get(pk=5950)
        amount = 1

    mealitem = MealItem()
    mealitem.meal = meal
    mealitem.weight_unit = unit
    mealitem.ingredient = ingredient
    mealitem.order = 4
    mealitem.amount = amount
    mealitem.save()

    #
    # Lunch (leave empty so users can add their own ingredients)
    meal = Meal()
    meal.plan = plan
    meal.order = 3
    meal.time = datetime.time(13, 0)
    meal.save()

    #
    # Workout schedules
    #

    # create some empty workouts to fill the list
    workout2 = Workout(user=user, comment=_('Placeholder workout nr {0} for schedule').format(1))
    workout2.save()
    workout3 = Workout(user=user, comment=_('Placeholder workout nr {0} for schedule').format(2))
    workout3.save()
    workout4 = Workout(user=user, comment=_('Placeholder workout nr {0} for schedule').format(3))
    workout4.save()

    schedule = Schedule()
    schedule.user = user
    schedule.name = _('My cool workout schedule')
    schedule.start_date = datetime.date.today() - datetime.timedelta(weeks=4)
    schedule.is_active = True
    schedule.is_loop = True
    schedule.save()

    # Add the workouts
    step = ScheduleStep()
    step.schedule = schedule
    step.workout = workout2
    step.duration = 2
    step.order = 1
    step.save()

    step = ScheduleStep()
    step.schedule = schedule
    step.workout = workout
    step.duration = 4
    step.order = 2
    step.save()

    step = ScheduleStep()
    step.schedule = schedule
    step.workout = workout3
    step.duration = 1
    step.order = 3
    step.save()

    step = ScheduleStep()
    step.schedule = schedule
    step.workout = workout4
    step.duration = 6
    step.order = 4
    step.save()

    #
    # Add two more schedules, to make the overview more interesting
    schedule = Schedule()
    schedule.user = user
    schedule.name = _('Empty placeholder schedule')
    schedule.start_date = datetime.date.today() - datetime.timedelta(weeks=15)
    schedule.is_active = False
    schedule.is_loop = False
    schedule.save()

    step = ScheduleStep()
    step.schedule = schedule
    step.workout = workout2
    step.duration = 2
    step.order = 1
    step.save()

    schedule = Schedule()
    schedule.user = user
    schedule.name = _('Empty placeholder schedule')
    schedule.start_date = datetime.date.today() - datetime.timedelta(weeks=30)
    schedule.is_active = False
    schedule.is_loop = False
    schedule.save()

    step = ScheduleStep()
    step.schedule = schedule
    step.workout = workout4
    step.duration = 2
    step.order = 1
    step.save()