ExercisesForm   A
last analyzed

Size/Duplication

Total Lines 21
Duplicated Lines 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 21
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __init__() 3 3 1

How to fix   Duplicated Code   

Duplicated Code

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
2
from dj_diabetes.models.sports import Exercises
3
4
from django import forms
5
6
7 View Code Duplication
class ExercisesForm(forms.ModelForm):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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