+def method_decorator(function_decorator):
+ """Converts a function decorator to a method decorator.
+
+ It just makes it ignore first argument.
+ """
+ def decorator(method):
+ @wraps(method)
+ def wrapped_method(self, *args, **kwargs):
+ def function(*fargs, **fkwargs):
+ return method(self, *fargs, **fkwargs)
+ return function_decorator(function)(*args, **kwargs)
+ return wrapped_method
+ return decorator
+
+
+def require_login(request):
+ """Return 403 if request is AJAX. Redirect to login page if not."""
+ if request.is_ajax():
+ return HttpResponseForbidden('Not logged in')
+ else:
+ return HttpResponseRedirect('/uzytkownicy/zaloguj')# next?=request.build_full_path())
+