diff --git a/users/templates/users/profile.html b/users/templates/users/profile.html index 9391952..8800812 100644 --- a/users/templates/users/profile.html +++ b/users/templates/users/profile.html @@ -13,7 +13,7 @@ {% else %} -

Not logged in

+

Niet ingelogd

{% endif %} {% endblock %} diff --git a/users/views.py b/users/views.py index 6dd36c1..83472c1 100644 --- a/users/views.py +++ b/users/views.py @@ -10,26 +10,20 @@ from users.models import CustomUser def profile(request): - if not request.user.is_authenticated: - return HttpResponseRedirect(reverse("events:index")) + if request.method == "POST": + if not request.user.is_authenticated: + return HttpResponseRedirect(reverse("users:profile")) - # if this is a POST request we need to process the form data - if request.method == 'POST': - # create a form instance and populate it with data from the request: form = UserMetaForm(request.POST, instance=request.user) - # check whether it's valid: if form.is_valid(): - # process the data in form.cleaned_data as required form.save() - # redirect to a new URL: return HttpResponseRedirect(reverse("users:profile")) - # if a GET (or any other method) we'll create a blank form else: - form = UserMetaForm(instance=request.user) + form = UserMetaForm(instance=request.user) if request.user.is_authenticated else None - return render(request, 'users/profile.html', {'form': form}) + return render(request, "users/profile.html", {"form": form}) def logout_view(request): logout(request)