示例#1
0
class DailyCaloriesForm(forms.ModelForm):
    """
    Form for the total daily calories needed
    """

    base_calories = forms.IntegerField(label=_('Basic caloric intake'),
                                       help_text=_('Your basic caloric intake as calculated for '
                                                   'your data'),
                                       required=False,
                                       widget=Html5NumberInput())
    additional_calories = forms.IntegerField(label=_('Additional calories'),
                                             help_text=_('Additional calories to add to the base '
                                                         'rate (to substract, enter a negative '
                                                         'number)'),
                                             initial=0,
                                             required=False,
                                             widget=Html5NumberInput())

    class Meta:
        model = UserProfile
        fields = ('calories',)

    def __init__(self, *args, **kwargs):
        super(DailyCaloriesForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.form_tag = False
示例#2
0
class BmiForm(forms.ModelForm):
    height = forms.DecimalField(widget=Html5NumberInput(),
                                max_value=999,
                                label=_('Height (cm)'))
    weight = forms.DecimalField(widget=Html5NumberInput(),
                                max_value=999)

    class Meta:
        model = UserProfile
        fields = ('height', )

    def __init__(self, *args, **kwargs):
        super(BmiForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.form_action = reverse('nutrition:bmi:calculate')
        self.helper.form_class = 'wger-form'
        self.helper.form_id = 'bmi-form'
        self.helper.layout = Layout(
            Row(
                Column('height', css_class='form-group col-6 mb-0'),
                Column('weight', css_class='form-group col-6 mb-0'),
                css_class='form-row'
            ),
            ButtonHolder(Submit('submit', _("Calculate"), css_class='btn-success'))
        )
示例#3
0
class BmiForm(forms.ModelForm):
    height = forms.DecimalField(
        widget=Html5NumberInput(), max_value=999, label=_('Height (cm)'))
    weight = forms.DecimalField(widget=Html5NumberInput(), max_value=999)

    class Meta:
        model = UserProfile
        fields = ('height', )
示例#4
0
文件: forms.py 项目: qbig/wger
class BmrForm(forms.ModelForm):
    '''
    Form for the basal metabolic rate
    '''
    weight = forms.DecimalField(widget=Html5NumberInput())

    class Meta:
        model = UserProfile
        fields = ('age', 'height', 'gender')
示例#5
0
class MealCreateForm(forms.Form):
    ingredient = forms.CharField()
    time = forms.TimeField(widget=Html5TimeInput(), label=' Time ')
    weight_unit = ChoiceFieldCustom(
        choices=IngredientWeightUnit.objects.none(),
        required=False)
    amount = forms.DecimalField(decimal_places=2,
                                max_digits=6, label='Amount',
                                widget=Html5NumberInput())
示例#6
0
文件: forms.py 项目: helenst/wger
class DailyCaloriesForm(forms.ModelForm):
    '''
    Form for the total daily calories needed
    '''

    base_calories = forms.IntegerField(label=_('Basic caloric intake'),
                                       help_text=_('Your basic caloric intake as calculated for '
                                                   'your data'),
                                       required=False,
                                       widget=Html5NumberInput())
    additional_calories = forms.IntegerField(label=_('Additional calories'),
                                             help_text=_('Additional calories to add to the base '
                                                         'rate (to substract, enter a negative '
                                                         'number)'),
                                             initial=0,
                                             required=False,
                                             widget=Html5NumberInput())

    class Meta:
        model = UserProfile
        fields = ('calories',)
示例#7
0
class WorkoutLogForm(ModelForm):
    '''
    Helper form for a WorkoutLog.

    The field for the weight is overwritten here, activating localization (so a
    German user can  use ',' as the separator)
    '''
    weight = DecimalField(decimal_places=2,
                          max_digits=5,
                          localize=True,
                          widget=Html5NumberInput())

    class Meta:
        model = WorkoutLog
        exclude = ('exercise', )
示例#8
0
class BmrForm(forms.ModelForm):
    """
    Form for the basal metabolic rate
    """
    weight = forms.DecimalField(widget=Html5NumberInput())

    class Meta:
        model = UserProfile
        fields = ('age', 'height', 'gender')

    def __init__(self, *args, **kwargs):
        super(BmrForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout("age", "height", "gender", "weight")
        self.helper.form_tag = False
示例#9
0
文件: forms.py 项目: qbig/wger
class BmiForm(forms.ModelForm):
    weight = forms.DecimalField(widget=Html5NumberInput())

    class Meta:
        model = UserProfile
        fields = ('height', )