Skip to content

Commit

Permalink
Update login form with inactive user
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Kanashiro <kanashiro.duarte@gmail.com>
Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
  • Loading branch information
macartur committed May 18, 2016
1 parent 5c8d8ef commit 9e5653c
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 27 deletions.
13 changes: 12 additions & 1 deletion colab/accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.forms import (ReadOnlyPasswordHashField,
SetPasswordForm, PasswordChangeForm)
SetPasswordForm, PasswordChangeForm,
AuthenticationForm)
from django.core.urlresolvers import reverse
from django.utils.functional import lazy
from django.utils.translation import ugettext_lazy as _
Expand Down Expand Up @@ -106,6 +107,16 @@ def clean_github(self):
return github


class LoginAuthenticationForm(AuthenticationForm):

error_messages = {
'invalid_login': _("Please enter a correct %(username)s and password. "
"Note that both fields may be case-sensitive."),
'inactive': _("This user is inactive. Try to resend your email "
"verification and activate your account."),
}


class UserUpdateForm(UserForm):

bio = forms.CharField(
Expand Down
37 changes: 36 additions & 1 deletion colab/accounts/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from colab.accounts.forms import (ColabPasswordChangeForm,
ColabSetPasswordForm, ColabSetUsernameForm,
UserChangeForm, UserCreationForm, UserForm,
UserUpdateForm, get_lists_choices)
UserUpdateForm, get_lists_choices,
LoginAuthenticationForm)
from colab.accounts.models import User
from colab.accounts.utils import mailman
from django.core.urlresolvers import reverse
Expand Down Expand Up @@ -370,3 +371,37 @@ def test_clean_password(self):
data=self.get_form_data('teste12345@example.com',
username='user12345'))
self.assertTrue(creation_form.is_valid())


class LoginFormTest(TestCase):

@classmethod
def setUpClass(cls):
cls.user = User.objects.create_user(username='user1234',
email='teste1234@example.com',
first_name='test_first_name',
last_name='test_last_name')

cls.user.set_password("12345")
cls.user.is_active = False
cls.user.save()

@classmethod
def tearDownClass(cls):
User.objects.all().delete()

def get_form_data(self, username='user1234', password='12345'):
return {
'username': username,
'password': password,
}

def test_inactive_login_message(self):
login_form = LoginAuthenticationForm(
data=self.get_form_data(username='user1234', password="12345"))

message = ("This user is inactive. Try to resend your email "
"verification and activate your account.")
result = login_form.errors['__all__'][0]

self.assertIn(message, result)
6 changes: 4 additions & 2 deletions colab/accounts/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

from .views import (UserProfileDetailView, UserProfileUpdateView,
ManageUserSubscriptionsView)
from .forms import ColabPasswordChangeForm, ColabSetPasswordForm
from .forms import (ColabPasswordChangeForm, ColabSetPasswordForm,
LoginAuthenticationForm)


urlpatterns = patterns('',
url(r'^login/?$', 'django.contrib.auth.views.login',
{'redirect_field_name': 'previous_path'}, name='login'),
{'redirect_field_name': 'previous_path',
'authentication_form': LoginAuthenticationForm}, name='login'),

url(r'^logout/?$', 'django.contrib.auth.views.logout',
{'next_page':'home'}, name='logout'),
Expand Down
Binary file modified colab/locale/pt_BR/LC_MESSAGES/django.mo
Binary file not shown.
59 changes: 38 additions & 21 deletions colab/locale/pt_BR/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Project-Id-Version: colab\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-05-13 13:35+0000\n"
"POT-Creation-Date: 2016-05-18 20:03+0000\n"
"PO-Revision-Date: 2015-09-07 19:13+0000\n"
"Last-Translator: Lucas Kanashiro Duarte <kanashiro.duarte@gmail.com>\n"
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/colab/colab/"
Expand Down Expand Up @@ -38,8 +38,8 @@ msgstr "Datas importantes"
msgid "User"
msgstr "Usuário"

#: colab/accounts/filters.py:12 colab/accounts/forms.py:228
#: colab/accounts/forms.py:306
#: colab/accounts/filters.py:12 colab/accounts/forms.py:239
#: colab/accounts/forms.py:317
msgid "Username"
msgstr "Nome de Usuário"

Expand All @@ -55,60 +55,77 @@ msgstr "Instituição"
msgid "Role"
msgstr "Papel"

#: colab/accounts/forms.py:33
#: colab/accounts/forms.py:34
msgid "Social account does not exist"
msgstr "Conta social não existe"

#: colab/accounts/forms.py:61 colab/accounts/forms.py:67
#: colab/accounts/forms.py:73
#: colab/accounts/forms.py:62 colab/accounts/forms.py:68
#: colab/accounts/forms.py:74
msgid "This field cannot be blank."
msgstr "Este campo não pode ficar em branco."

#: colab/accounts/forms.py:114
#: colab/accounts/forms.py:113
#, python-format
msgid ""
"Please enter a correct %(username)s and password. Note that both fields may "
"be case-sensitive."
msgstr ""
"Por favor entre com %(username)s and senha corretamente. Lembre-se que ambos "
"fazem diferença de maiúscula e minúsculas"

#: colab/accounts/forms.py:115
msgid ""
"This user is inactive. Try to resend your email verification and activate "
"your account."
msgstr ""
"Este usuário está inativo. Tente reenviar seu email de verificação e ative "
"sua conta."

#: colab/accounts/forms.py:125
#: colab/accounts/templates/accounts/user_detail.html:45
msgid "Bio"
msgstr "Bio"

#: colab/accounts/forms.py:115
#: colab/accounts/forms.py:126
msgid "Write something about you in 200 characters or less."
msgstr "Escreva algo sobre você em 200 caracteres ou menos."

#: colab/accounts/forms.py:160
#: colab/accounts/forms.py:171
msgid "Mailing lists"
msgstr "Listas de e-mail"

#: colab/accounts/forms.py:223
#: colab/accounts/forms.py:234
#, python-format
msgid "Email already used. Is it you? Please <a href='%(url)s'>login</a>"
msgstr ""
"Este email ja está sendo utilizado.Caso seja o seu efetue o <a "
"href='%(url)s'>login</a>"

#: colab/accounts/forms.py:225
#: colab/accounts/forms.py:236
msgid "A user with that username already exists."
msgstr "Já existe um usuário com este nome."

#: colab/accounts/forms.py:226
#: colab/accounts/forms.py:237
msgid "The two password fields didn't match."
msgstr "Os dois campos de senha não conferem."

#: colab/accounts/forms.py:236 colab/accounts/forms.py:311
#: colab/accounts/forms.py:247 colab/accounts/forms.py:322
msgid "Password"
msgstr "Senha"

#: colab/accounts/forms.py:238
#: colab/accounts/forms.py:249
msgid "Password confirmation"
msgstr "Confirmação de senha"

#: colab/accounts/forms.py:307 colab/accounts/models.py:111
#: colab/accounts/forms.py:318 colab/accounts/models.py:116
msgid "Required. 30 characters or fewer. Letters and digits."
msgstr "Obrigatório. 30 caracteres ou menos. Letras ou digitos."

#: colab/accounts/forms.py:309
#: colab/accounts/forms.py:320
msgid "This value may contain only letters and numbers."
msgstr "Este campo pode conter apenas letras e números."

#: colab/accounts/forms.py:312
#: colab/accounts/forms.py:323
msgid ""
"Raw passwords are not stored, so there is no way to see this user's "
"password, but you can change the password using <a href=\"password/\">this "
Expand Down Expand Up @@ -287,7 +304,6 @@ msgid "Forgot Password?"
msgstr "Esqueci minha Senha?"

#: colab/accounts/templates/registration/login.html:57
#| msgid "Sending verification..."
msgid "Resend Email Verification?"
msgstr "Reenviar Email de Verificação?"

Expand Down Expand Up @@ -319,8 +335,7 @@ msgstr "Redefinir senha"

#: colab/accounts/templates/registration/resend_email_verification.html:22
msgid "Enter your email address below, and we'll resend an email verification."
msgstr ""
"Informe seu email abaixo e reenviaremos um email de verificação."
msgstr "Informe seu email abaixo e reenviaremos um email de verificação."

#: colab/accounts/templates/registration/resend_email_verification.html:36
msgid "Resend Email"
Expand Down Expand Up @@ -481,7 +496,9 @@ msgstr "Este email não está registrado ainda."

#: colab/accounts/views.py:225
msgid "An email was sent to you. Verify your inbox or spam."
msgstr "Um email foi enviado para você. Verifique sua caixa de email ou possivelmente sua caixa de spam."
msgstr ""
"Um email foi enviado para você. Verifique sua caixa de email ou "
"possivelmente sua caixa de spam."

#: colab/accounts/views.py:228
msgid "An error occurred while sending mail."
Expand Down
Binary file modified colab/super_archives/locale/pt_BR/LC_MESSAGES/django.mo
Binary file not shown.
46 changes: 44 additions & 2 deletions colab/super_archives/locale/pt_BR/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: colab\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-01-15 19:18+0000\n"
"POT-Creation-Date: 2016-05-18 20:03+0000\n"
"PO-Revision-Date: 2014-11-21 17:38+0000\n"
"Last-Translator: Sergio Oliveira <seocam@seocam.com>\n"
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/projects/p/"
Expand All @@ -20,6 +20,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#: colab/super_archives/filters.py:8
#: colab/super_archives/templates/search/thread_search_preview.html:11
msgid "Discussion"
msgstr "Discussão"

Expand Down Expand Up @@ -263,10 +264,51 @@ msgstr "mais..."
msgid "most relevant"
msgstr "Mais relevante"

#: colab/super_archives/templates/widgets/dashboard_collaboration_graph.html:3
msgid "Contributions"
msgstr ""

#: colab/super_archives/templates/widgets/dashboard_collaboration_graph.html:7
msgid "Collaboration Graph"
msgstr ""

#: colab/super_archives/templates/widgets/dashboard_latest_collaborations.html:8
msgid "Latest Collaborations"
msgstr ""

#: colab/super_archives/templates/widgets/dashboard_latest_collaborations.html:12
msgid "RSS - Latest collaborations"
msgstr ""

#: colab/super_archives/templates/widgets/dashboard_latest_collaborations.html:21
msgid "View more collaborations..."
msgstr ""

#: colab/super_archives/templates/widgets/dashboard_latest_threads.html:8
#, fuzzy
#| msgid "Threads"
msgid "Latest Threads"
msgstr "Discussões"

#: colab/super_archives/templates/widgets/dashboard_latest_threads.html:12
msgid "RSS - Latest Threads"
msgstr ""

#: colab/super_archives/templates/widgets/dashboard_latest_threads.html:20
#: colab/super_archives/templates/widgets/dashboard_most_relevant_threads.html:20
msgid "View more discussions..."
msgstr ""

#: colab/super_archives/templates/widgets/dashboard_most_relevant_threads.html:8
msgid "Most Relevant Threads"
msgstr "Mais relevante"

#: colab/super_archives/templates/widgets/dashboard_most_relevant_threads.html:12
#, fuzzy
#| msgid "Most Relevant Threads"
msgid "RSS - Most Relevant Threads"
msgstr "Mais relevante"

#: colab/super_archives/utils/email.py:14
msgid "Please verify your email "
msgstr "Por favor verifique seu email"
Expand Down Expand Up @@ -331,6 +373,6 @@ msgstr "Avaliação"
msgid "You are not logged in"
msgstr "Você não esta logado"

#: colab/super_archives/views.py:399
#: colab/super_archives/views.py:396
msgid "You don't have permission to access this list"
msgstr "Você não tem permissão para acessar esta lista"

0 comments on commit 9e5653c

Please sign in to comment.