Code Duplication    Length = 21-21 lines in 2 locations

dj_diabetes/forms/meals.py 1 location

@@ 8-28 (lines=21) @@
5
from django import forms
6
7
8
class MealsForm(forms.ModelForm):
9
    """
10
        Meals Form
11
    """
12
    # get the list of pref to get the value in the dropdown
13
    breakfast_lunch_diner = forms.ChoiceField(widget=forms.Select(
14
        attrs={'class': 'form-control'}))
15
    food = forms.CharField(widget=forms.Textarea(
16
        {'class': 'form-control', 'rows': '3'}))
17
    date_meals = forms.DateField(widget=forms.TextInput(
18
        {'class': 'form-control'}))
19
    hour_meals = forms.TimeField(widget=forms.TextInput(
20
        {'class': 'form-control'}))
21
22
    class Meta:
23
        model = Meals
24
        fields = ['food', 'breakfast_lunch_diner', 'date_meals', 'hour_meals']
25
26
    def __init__(self, *args, **kwargs):
27
        super(MealsForm, self).__init__(*args, **kwargs)
28
        self.fields['breakfast_lunch_diner'].choices = pref_filter("meal")
29

dj_diabetes/forms/exercises.py 1 location

@@ 7-27 (lines=21) @@
4
from django import forms
5
6
7
class ExercisesForm(forms.ModelForm):
8
    """
9
        Exercises Form
10
    """
11
    comment = forms.CharField(widget=forms.Textarea(
12
        {'class': 'form-control', 'rows': '3'}))
13
    duration = forms.IntegerField(widget=forms.TextInput(
14
        {'class': 'form-control', 'type': 'number'}))
15
    date_exercises = forms.DateField(widget=forms.TextInput(
16
        attrs={'class': 'form-control'}))
17
    hour_exercises = forms.TimeField(widget=forms.TextInput(
18
        attrs={'class': 'form-control'}))
19
20
    class Meta:
21
        model = Exercises
22
        fields = ['sports', 'comment', 'duration',
23
                  'date_exercises', 'hour_exercises']
24
25
    def __init__(self, *args, **kwargs):
26
        super(ExercisesForm, self).__init__(*args, **kwargs)
27
        self.fields['sports'].widget.attrs['class'] = 'form-control'
28