Commit 06778542 authored by okhin's avatar okhin 🚴

Moving the csrf exemption to the mixin. #195 /spend 20m

parent edae7d86
Pipeline #1071 failed with stage
in 9 minutes and 4 seconds
......@@ -5,8 +5,6 @@ import random
from django.db.models import Q, Count
from django.views import generic
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from representatives.models import Chamber, Representative
from representatives_positions.views import PositionFormMixin
......@@ -22,10 +20,6 @@ class HomeView(PositionFormMixin, RepresentativeViewMixin,
generic.TemplateView):
template_name = 'home.html'
@method_decorator(csrf_exempt)
def dispatch(self, *args, **kwargs):
return super(HomeView, self).dispatch(*args, **kwargs)
def get_context_data(self, **kwargs):
c = super(HomeView, self).get_context_data(**kwargs)
......
from django.views import generic
from django.views.decorators.csrf import csrf_exempt
from django.utils.decorators import method_decorator
from .forms import PositionForm
......@@ -15,6 +17,10 @@ class PositionFormMixin(generic.View):
position_form = None
position_created = False
@method_decorator(csrf_exempt)
def dispatch(self, *args, **kwargs):
return super(HomeView, self).dispatch(*args, **kwargs)
def post(self, request, *args, **kwargs):
if 'position-representatives' in request.POST:
self.position_form = PositionForm(request.POST, prefix='position')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment