Redirect non-ajax forms to /

This commit is contained in:
Oliver Walters 2019-05-29 22:11:03 +10:00
parent 080f9da9c8
commit f4a052ee2b
2 changed files with 5 additions and 2 deletions

View File

@ -9,7 +9,7 @@ as JSON objects and passing them to modal forms (using jQuery / bootstrap).
from __future__ import unicode_literals from __future__ import unicode_literals
from django.template.loader import render_to_string 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 import View
from django.views.generic import UpdateView, CreateView from django.views.generic import UpdateView, CreateView
@ -132,6 +132,9 @@ class AjaxMixin(object):
JSON response object JSON response object
""" """
if not request.is_ajax():
return HttpResponseRedirect('/')
if context is None: if context is None:
try: try:
context = self.get_context_data() context = self.get_context_data()

View File

@ -36,7 +36,7 @@ stock_urls = [
url(r'^track/?', views.StockTrackingIndex.as_view(), name='stock-tracking-list'), 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 # Individual stock items
url(r'^item/(?P<pk>\d+)/', include(stock_item_detail_urls)), url(r'^item/(?P<pk>\d+)/', include(stock_item_detail_urls)),