@@ -0,0 +1,1689 @@
+# -*- coding: utf-8 -*-%0A%0A# This file is part of Workout Manager.%0A#%0A# Workout Manager is free software: you can redistribute it and/or modify%0A# it under the terms of the GNU Affero General Public License as published by%0A# the Free Software Foundation, either version 3 of the License, or%0A# (at your option) any later version.%0A#%0A# Workout Manager is distributed in the hope that it will be useful,%0A# but WITHOUT ANY WARRANTY; without even the implied warranty of%0A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A# GNU General Public License for more details.%0A#%0A# You should have received a copy of the GNU Affero General Public License%0A%0Aimport logging%0A%0Afrom django import forms%0A%0Afrom wger.nutrition.models import IngredientWeightUnit%0A%0Alogger = logging.getLogger('workout_manager.custom')%0A%0Aclass UnitChooserForm(forms.Form):%0A    '''%0A    A small form to select an amount and a unit for an ingredient%0A    '''%0A    amount = forms.DecimalField(decimal_places=2,%0A                                max_digits=5,%0A                                localize=True)%0A    unit = forms.ModelChoiceField(queryset=IngredientWeightUnit.objects.none(),%0A                                  empty_label=%22g%22,%0A                                  required=False)%0A%0A    def __init__(self, *args, **kwargs):%0A        super(UnitChooserForm, self).__init__(*args, **kwargs)%0A%0A        if len(args) and args%5B0%5D%5B'ingredient'%5D:%0A            ingredient_id = args%5B0%5D%5B'ingredient'%5D%0A%0A        elif kwargs.get('data'):%0A            ingredient_id = kwargs%5B'data'%5D%5B'ingredient_id'%5D%0A%0A        else:%0A            ingredient_id = -1%0A%0A        self.fields%5B'unit'%5D.queryset=IngredientWeightUnit.objects.filter(ingredient_id=ingredient_id)

Add missing forms field