diff --git a/servee/__init__.py b/servee/__init__.py index 19bb242..e7e4407 100644 --- a/servee/__init__.py +++ b/servee/__init__.py @@ -1,5 +1,5 @@ VERSION = (0, 6, 0, "a", 1) # following PEP 386 -DEV_N = "13" +DEV_N = "14" # cribbed from pinax diff --git a/servee/frontendadmin/options.py b/servee/frontendadmin/options.py index fc407e4..04d15e9 100644 --- a/servee/frontendadmin/options.py +++ b/servee/frontendadmin/options.py @@ -60,6 +60,28 @@ def __init__(self, *args, **kwargs): "admin/object_history.html", ] + + def response_add(self, request, obj): + """ + Act differently during frontendadmin(ajax) just reload the page. + """ + + # in these cases, the redirect is good + if list(set(request.POST.keys()) & set(["_addanother", "_continue"])): + return super(ServeeModelAdmin, self).response_change(request, obj) + + # we want to override the default save case in the frontend + ref = request.META.get("HTTP_REFERER") + if ref and (ref.find("/servee/") == -1): + if request.is_ajax(): + return HttpResponse("") + else: + return HttpResponseRedirect(ref) + + # fallback to normal functionality + return super(ServeeModelAdmin, self).response_add(request, obj) + + def response_change(self, request, obj): """ Act differently during frontendadmin(ajax) just reload the page.