From f4a052ee2b83ebb5d121d33f230574f6e9da24ba Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 29 May 2019 22:11:03 +1000 Subject: [PATCH] Redirect non-ajax forms to / --- InvenTree/InvenTree/views.py | 5 ++++- InvenTree/stock/urls.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index f6fdbc4d46..338e664252 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -9,7 +9,7 @@ as JSON objects and passing them to modal forms (using jQuery / bootstrap). from __future__ import unicode_literals from django.template.loader import render_to_string -from django.http import JsonResponse +from django.http import JsonResponse, HttpResponseRedirect from django.views import View from django.views.generic import UpdateView, CreateView @@ -132,6 +132,9 @@ class AjaxMixin(object): JSON response object """ + if not request.is_ajax(): + return HttpResponseRedirect('/') + if context is None: try: context = self.get_context_data() diff --git a/InvenTree/stock/urls.py b/InvenTree/stock/urls.py index 513fff6cb0..237e2281f0 100644 --- a/InvenTree/stock/urls.py +++ b/InvenTree/stock/urls.py @@ -36,7 +36,7 @@ stock_urls = [ url(r'^track/?', views.StockTrackingIndex.as_view(), name='stock-tracking-list'), - url(r'^move/', views.StockItemMoveMultiple.as_view(), name='stock-item-move-multiple'), + url(r'^move/?', views.StockItemMoveMultiple.as_view(), name='stock-item-move-multiple'), # Individual stock items url(r'^item/(?P\d+)/', include(stock_item_detail_urls)),