from __future__ import absolute_import

from django.middleware.csrf import REASON_NO_REFERER

from sentry.web.frontend.base import BaseView


class CsrfFailureView(BaseView):
    auth_required = False
    sudo_required = False

    def handle(self, request, reason=""):
        context = {
            'no_referer': reason == REASON_NO_REFERER
        }

        return self.respond('sentry/403-csrf-failure.html', status=403)


view = CsrfFailureView.as_view()

from __future__ import absolute_import

from django.middleware.csrf import REASON_NO_REFERER
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import View
from django.utils.decorators import method_decorator

from sentry.web.helpers import render_to_response


class CsrfFailureView(View):
    @method_decorator(csrf_exempt)
    def dispatch(self, request, reason=""):
        context = {
            'no_referer': reason == REASON_NO_REFERER,
            'request': request,
        }

        return render_to_response('sentry/403-csrf-failure.html', context, request,
                                  status=403)


view = CsrfFailureView.as_view()

Kill possible recursion on csrf decorator
Kill possible recursion on csrf decorator

  from __future__ import absolute_import
  
  from django.middleware.csrf import REASON_NO_REFERER
+ from django.views.decorators.csrf import csrf_exempt
+ from django.views.generic import View
+ from django.utils.decorators import method_decorator
  
- from sentry.web.frontend.base import BaseView
+ from sentry.web.helpers import render_to_response
  
  
- class CsrfFailureView(BaseView):
+ class CsrfFailureView(View):
+     @method_decorator(csrf_exempt)
-     auth_required = False
-     sudo_required = False
- 
-     def handle(self, request, reason=""):
+     def dispatch(self, request, reason=""):
          context = {
-             'no_referer': reason == REASON_NO_REFERER
+             'no_referer': reason == REASON_NO_REFERER,
+             'request': request,
          }
  
-         return self.respond('sentry/403-csrf-failure.html', status=403)
+         return render_to_response('sentry/403-csrf-failure.html', context, request,
+                                   status=403)
  
  
  view = CsrfFailureView.as_view()
  
Kill possible recursion on csrf decorator
## Code Before:
from __future__ import absolute_import

from django.middleware.csrf import REASON_NO_REFERER

from sentry.web.frontend.base import BaseView


class CsrfFailureView(BaseView):
    auth_required = False
    sudo_required = False

    def handle(self, request, reason=""):
        context = {
            'no_referer': reason == REASON_NO_REFERER
        }

        return self.respond('sentry/403-csrf-failure.html', status=403)


view = CsrfFailureView.as_view()

## Instruction:
Kill possible recursion on csrf decorator
## Code After:
from __future__ import absolute_import

from django.middleware.csrf import REASON_NO_REFERER
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import View
from django.utils.decorators import method_decorator

from sentry.web.helpers import render_to_response


class CsrfFailureView(View):
    @method_decorator(csrf_exempt)
    def dispatch(self, request, reason=""):
        context = {
            'no_referer': reason == REASON_NO_REFERER,
            'request': request,
        }

        return render_to_response('sentry/403-csrf-failure.html', context, request,
                                  status=403)


view = CsrfFailureView.as_view()
