diff --git a/apps/templates/_header_bar.html b/apps/templates/_header_bar.html
index 66699be53..71bd0e95e 100644
--- a/apps/templates/_header_bar.html
+++ b/apps/templates/_header_bar.html
@@ -19,9 +19,15 @@
+ {% if user.is_authenticated %}
- Log out
+ {% trans 'Log out' %}
+ {% else %}
+
+ {% trans 'Log in' %}
+
+ {% endif %}
diff --git a/apps/templates/_user_profile.html b/apps/templates/_user_profile.html
index 13d272d90..d47ba6537 100644
--- a/apps/templates/_user_profile.html
+++ b/apps/templates/_user_profile.html
@@ -8,10 +8,10 @@
- {{ request.user.name }}
+ {{ user.name }}
- {{ request.user.get_role_display | default:"{% trans 'User' %}" }}
+ {{ user.get_role_display | default:_('User') }}
diff --git a/apps/users/forms.py b/apps/users/forms.py
index 88b6ccd93..3f2dcfa98 100644
--- a/apps/users/forms.py
+++ b/apps/users/forms.py
@@ -1,20 +1,24 @@
# ~*~ coding: utf-8 ~*~
-from django.forms import ModelForm
from django import forms
-from captcha.fields import CaptchaField
+from django.contrib.auth.forms import AuthenticationForm
from django.utils.translation import gettext_lazy as _
+from captcha.fields import CaptchaField
+
from .models import User, UserGroup
-class UserLoginForm(forms.Form):
+class UserLoginForm(AuthenticationForm):
username = forms.CharField(label=_('Username'), max_length=100)
- password = forms.CharField(label=_('Password'), widget=forms.PasswordInput, max_length=100)
+ password = forms.CharField(
+ label=_('Password'), widget=forms.PasswordInput, max_length=100,
+ strip=False)
captcha = CaptchaField()
-class UserAddForm(ModelForm):
+class UserAddForm(forms.ModelForm):
+
class Meta:
model = User
fields = [
@@ -32,7 +36,8 @@ class UserAddForm(ModelForm):
}
-class UserUpdateForm(ModelForm):
+class UserUpdateForm(forms.ModelForm):
+
class Meta:
model = User
fields = [
@@ -51,7 +56,8 @@ class UserUpdateForm(ModelForm):
}
-class UserGroupForm(ModelForm):
+class UserGroupForm(forms.ModelForm):
+
class Meta:
model = UserGroup
diff --git a/apps/users/templates/users/login.html b/apps/users/templates/users/login.html
index b2cc09668..81fd5252e 100644
--- a/apps/users/templates/users/login.html
+++ b/apps/users/templates/users/login.html
@@ -40,11 +40,10 @@
{% if form.errors %}
{% if 'captcha' in form.errors %}
{% trans 'Captcha invalid' %}
+ {% else %}
+ {{ form.non_field_errors.as_text }}
{% endif %}
{% endif %}
- {% if errors %}
- {{ errors }}
- {% endif %}
@@ -57,7 +56,7 @@
- Forgot password?
+ {% trans 'Forgot password' %}?
@@ -79,7 +78,4 @@