Total Lines | 21 |
Duplicated Lines | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | # coding: utf-8 |
||
8 | View Code Duplication | 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 |