Self hosted FLOSS fitness/workout, nutrition and weight tracker
Read out where the user came from so we can redirect him after logging in
Roland Geiderc2f2ac793f0c
diff --git a/manager/templates/login.html b/manager/templates/login.htmlindex f8022023e..dfd5b907d 100644--- a/manager/templates/login.html+++ b/manager/templates/login.html@@ -11,6 +11,7 @@class="ym-form">{% csrf_token %}{{ form.non_field_errors }}+ <input type="hidden" name="redirect_target" value="{{redirect_target}}"><table>{% include "form_snippet.html" with field=form.username %}{% include "form_snippet.html" with field=form.password %}diff --git a/manager/views.py b/manager/views.pyindex 86e5cbaeb..f800e3ebc 100644--- a/manager/views.py+++ b/manager/views.py@@ -73,7 +73,12 @@ def login(request):template_data['form'] = AuthenticationForm()+ # Read out where the user came from so we can redirect him after logging in+ redirect_target = request.GET.get('next')+ template_data['redirect_target'] = redirect_target+if request.method == 'POST':+ redirect_target = request.POST.get('redirect_target', '/')authentication_form = AuthenticationForm(data=request.POST)# If the data is valid, log in and redirect@@ -86,8 +91,11 @@ def login(request):if user.is_active:django_login(request, user)- # Redirect to the start page.- return HttpResponseRedirect('/')+ # Redirect to where the user came from++ logger.debug("target: %s" % redirect_target)++ return HttpResponseRedirect(redirect_target)else:# Return a disabled account error messagepass@@ -208,7 +216,7 @@ def pdf_workout(request, id):table_style.append(('SPAN', (0, marker), (-1, marker)))- table_style.append+ #table_style.appendt = Table(data, style = table_style)# Manually set the width of thecolumns