Fixed bug in first time setup wizard at login/user creation step. If an admin user already exists, the login page didn't work properly.

This commit is contained in:
2019-01-02 23:11:39 +02:00
parent c7f740a4d1
commit 43583e0fca
4 changed files with 39 additions and 27 deletions

View File

@ -6,7 +6,7 @@ from django import forms
from django.contrib.auth.models import User
from django.urls import reverse_lazy
from YtManagerApp.views.forms.auth import ExtendedUserCreationForm
from YtManagerApp.views.forms.auth import ExtendedUserCreationForm, ExtendedAuthenticationForm
logger = logging.getLogger("FirstTimeWizard")
@ -30,7 +30,7 @@ class ApiKeyForm(forms.Form):
'api_key',
Column(
Submit('submit', value='Continue'),
HTML('<a href="{% url \'first_time_2\' %}" class="btn">Skip</a>')
HTML('<a href="{% url \'first_time_2\' %}" class="btn btn-secondary">Skip</a>')
)
)
@ -39,6 +39,22 @@ class UserCreationForm(ExtendedUserCreationForm):
form_action = reverse_lazy('first_time_2')
class LoginForm(ExtendedAuthenticationForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
'username',
'password',
'remember_me',
Column(
Submit('submit', value='Continue'),
HTML('<a href="{% url \'first_time_2\' %}?register=1" class="btn">Register new admin account</a>')
)
)
class PickAdminUserForm(forms.Form):
admin_user = forms.ModelChoiceField(
User.objects.order_by('username'),