diff --git a/akvo/rsr/views/account.py b/akvo/rsr/views/account.py index 2e67e2ff9b..79508eb44d 100644 --- a/akvo/rsr/views/account.py +++ b/akvo/rsr/views/account.py @@ -439,8 +439,8 @@ def get_context_data(self, form, **kwargs): def get_success_url(self): next_url = self.get_redirect_url() - success_url = reverse(self.success_url) - return f"{success_url}?next={next_url}" if next_url else success_url + success_url = f"{reverse(self.success_url)}?setup=1" + return f"{success_url}&next={next_url}" if next_url else success_url def done(self, form_list, **kwargs): response = super().done(form_list, **kwargs) @@ -469,7 +469,11 @@ def form_valid(self, form): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) next_url = self.get_redirect_url() - context.update({"next_url": next_url}) + is_setup = self.request.GET.get("setup", "") + context.update({ + "next_url": next_url, + "show_generate_button": False if is_setup else True, + }) return context # Copied from django.contrib.auth.views.LoginView (Branch: stable/1.11.x) diff --git a/akvo/templates/two_factor/core/backup_tokens.html b/akvo/templates/two_factor/core/backup_tokens.html index fb1cefab52..671a97ff88 100644 --- a/akvo/templates/two_factor/core/backup_tokens.html +++ b/akvo/templates/two_factor/core/backup_tokens.html @@ -30,7 +30,9 @@

{% block title %}{% trans "Backup Tokens" %}{% endblock %}

{% else %} {% trans "Back to Account Security" %} {% endif %} + {% if show_generate_button %} + {% endif %}