Code Duplication    Length = 15-15 lines in 2 locations

wye/regions/views.py 2 locations

@@ 50-64 (lines=15) @@
47
    template_name = 'regions/state/edit.html'
48
49
50
class LocationCreateView(views.StaffuserRequiredMixin, generic.CreateView):
51
    model = models.Location
52
    form_class = forms.LocationForm
53
    success_url = '/region/'
54
    template_name = 'regions/location/create.html'
55
56
    def post(self, request, *args, **kwargs):
57
        form = forms.LocationForm(data=request.POST)
58
        if form.is_valid():
59
            form.modified_by = request.user
60
            form.created_by = request.user
61
            form.instance.save()
62
            return HttpResponseRedirect(self.success_url)
63
        else:
64
            return render(request, self.template_name, {'form': form})
65
66
67
class LocationUpdateView(views.StaffuserRequiredMixin, generic.UpdateView):
@@ 26-40 (lines=15) @@
23
        return context
24
25
26
class StateCreateView(views.StaffuserRequiredMixin, generic.CreateView):
27
    model = models.State
28
    form_class = forms.StateForm
29
    success_url = '/region/'
30
    template_name = 'regions/state/create.html'
31
32
    def post(self, request, *args, **kwargs):
33
        form = forms.StateForm(data=request.POST)
34
        if form.is_valid():
35
            form.modified_by = request.user
36
            form.created_by = request.user
37
            form.instance.save()
38
            return HttpResponseRedirect(self.success_url)
39
        else:
40
            return render(request, self.template_name, {'form': form})
41
42
43
class StateEditView(views.StaffuserRequiredMixin, generic.UpdateView):