short-circuit middleware if migration loading url

* Had to monkey patch django middleware logic.
* Left checks to tell coders to use new middleware behavior in favor of
monkey patching.
This commit is contained in:
chris meyers
2018-03-02 11:04:18 -05:00
parent f907995374
commit 746a2c1eea
2 changed files with 37 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ from django.shortcuts import get_object_or_404, redirect
from django.apps import apps
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
from django.urls import resolve
from awx.main.models import ActivityStream
from awx.main.utils.named_url_graph import generate_graph, GraphNode
@@ -193,5 +194,6 @@ class MigrationRanCheckMiddleware(object):
def process_request(self, request):
executor = MigrationExecutor(connection)
plan = executor.migration_plan(executor.loader.graph.leaf_nodes())
if bool(plan) and 'migrations_notran' not in request.path:
if bool(plan) and \
getattr(resolve(request.path), 'url_name', '') != 'migrations_notran':
return redirect(reverse("ui:migrations_notran"))