Code Duplication    Length = 10-14 lines in 2 locations

wye/workshops/forms.py 2 locations

@@ 74-87 (lines=14) @@
71
class WorkshopEditForm(forms.ModelForm):
72
    requester = forms.CharField()
73
74
    def __init__(self, request, *args, **kwargs):
75
        super(WorkshopEditForm, self).__init__(*args, **kwargs)
76
        self.fields['expected_date'] = forms.DateField(
77
            widget=CalendarWidget,
78
            input_formats=settings.ALLOWED_DATE_FORMAT)
79
        self.fields['requester'].widget = forms.TextInput()
80
        self.fields['requester'].widget.attrs['readonly'] = True
81
        if RegionalLead.is_regional_lead(
82
                request.user, self.instance.location):
83
            self.fields['presenter'].queryset = User.objects.filter(
84
                profile__usertype__slug="tutor"
85
            )
86
        else:
87
            del self.fields['presenter']
88
89
    def clean_requester(self):
90
        return self.instance.requester
@@ 28-37 (lines=10) @@
25
26
class WorkshopForm(forms.ModelForm):
27
28
    def __init__(self, *args, **kwargs):
29
        user = kwargs.pop('user')
30
        super(WorkshopForm, self).__init__(*args, **kwargs)
31
        self.fields['expected_date'] = forms.DateField(
32
            widget=CalendarWidget,
33
            input_formats=settings.ALLOWED_DATE_FORMAT)
34
        self.fields['requester'].queryset = self.get_organisations(user)
35
        self.fields['location'].required = False
36
        self.fields['location'].widget = forms.HiddenInput()
37
        self.fields['workshop_section'].queryset = WorkshopSections.objects.filter(is_active=True)
38
39
    def clean_location(self):
40
        if "requester" not in self.cleaned_data: