Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Change label on username field used for login

Roland Geider39ff0a462767
diff --git a/wger/core/forms.py b/wger/core/forms.py
index 45d430711..00a62a689 100644
--- a/wger/core/forms.py
+++ b/wger/core/forms.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU Affero General Public License
from captcha.fields import ReCaptchaField
-from django.contrib.auth.forms import UserCreationForm
+from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django import forms
@@ -30,6 +30,15 @@ from django.utils.translation import ugettext as _
from wger.core.models import UserProfile
+class UserLoginForm(AuthenticationForm):
+ '''
+ Form for logins
+
+ Overwritten here just to change the label on the 'username' field
+ '''
+ username = forms.CharField(label=_("Username or email"), max_length=254)
+
+
class UserPreferencesForm(forms.ModelForm):
class Meta:
model = UserProfile
diff --git a/wger/core/views/user.py b/wger/core/views/user.py
index d4df4faac..b18b1cdd7 100644
--- a/wger/core/views/user.py
+++ b/wger/core/views/user.py
@@ -45,8 +45,8 @@ from wger.core.forms import (
UserPersonalInformationForm,
PasswordConfirmationForm,
RegistrationForm,
- RegistrationFormNoCaptcha
-)
+ RegistrationFormNoCaptcha,
+ UserLoginForm)
from wger.core.models import Language
from wger.manager.models import (
WorkoutLog,
@@ -73,6 +73,7 @@ def login(request):
return django_loginview(request,
template_name='user/login.html',
+ authentication_form=UserLoginForm,
extra_context=context)
diff --git a/wger/software/templates/changelog.html b/wger/software/templates/changelog.html
index 9008040ff..6e9dd773f 100644
--- a/wger/software/templates/changelog.html
+++ b/wger/software/templates/changelog.html
@@ -11,6 +11,10 @@
<h4>2015-XX-XX</h4>
<ul>
+ <li>
+ Allow login with username or email
+ <a href="https://github.com/rolandgeider/wger/issues/164">#164</a>
+ </li>
<li>
Fix problem with datepicker
<a href="https://github.com/rolandgeider/wger/issues/192">#192</a>