diff --git a/src/accounts/forms.py b/src/accounts/forms.py index f55d13ab..d8ecdf10 100644 --- a/src/accounts/forms.py +++ b/src/accounts/forms.py @@ -44,9 +44,57 @@ def __init__(self, *args, **kwargs): class UserCreationForm(UserForm): + password = forms.CharField( + max_length=128, + widget=forms.PasswordInput()) + + confirm_password = forms.CharField( + max_length=128, + widget=forms.PasswordInput()) class Meta: model = User - fields = ('first_name', 'last_name', 'email', 'username') + fields = ('first_name', + 'last_name', + 'email', + 'username', + 'password', + 'confirm_password') + + def clean(self): + super(UserCreationForm, self).clean() + data = self.cleaned_data + + username = data.get('username') + + if User.objects.filter(username=username).exists(): + raise forms.ValidationError( + 'Esse nome de usuário já existe.') + + if not 'password' in data or not 'confirm_password' in data: + raise forms.ValidationError( + 'Preencha os campos de senha') + + senha = self.cleaned_data['password'] + confirma_senha = self.cleaned_data['confirm_password'] + + if senha != confirma_senha: + raise forms.ValidationError('As senhas não conferem.') + + + return self.cleaned_data + + def save(self, commit=False): + user = User.objects.create( + first_name=self.cleaned_data['first_name'], + last_name=self.cleaned_data['last_name'], + email=self.cleaned_data['email'], + username=self.cleaned_data['username']) + + user.set_password(self.cleaned_data['password']) + + user.save() + + return user class UserUpdateForm(UserForm): diff --git a/src/accounts/templates/accounts/user_update_form.html b/src/accounts/templates/accounts/user_update_form.html index cffbf12a..4d09152e 100644 --- a/src/accounts/templates/accounts/user_update_form.html +++ b/src/accounts/templates/accounts/user_update_form.html @@ -192,7 +192,7 @@

{% trans "This feature is available only for those who need to change the password for some reason as having an old user with the same username, forgot your password to commit, usage of other XMPP Client for connection. Usually, you won't need to change this password. Only change it if you are sure about what you are doing." %}
- {% trans "Change Password" %} + {% trans "Change Password" %} diff --git a/src/accounts/templates/novo_login.html b/src/accounts/templates/novo_login.html new file mode 100644 index 00000000..574288b1 --- /dev/null +++ b/src/accounts/templates/novo_login.html @@ -0,0 +1,50 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block title %}Login{% endblock %} + +{% block main-content %} +
+
+
+ +
+
+
+ + +{% endblock %} diff --git a/src/accounts/templates/registration/password_change_form_custom.html b/src/accounts/templates/registration/password_change_form_custom.html new file mode 100644 index 00000000..7c09c0d4 --- /dev/null +++ b/src/accounts/templates/registration/password_change_form_custom.html @@ -0,0 +1,60 @@ +{% extends "base.html" %} +{% load i18n %} +{% block main-content %} + +
+ {% if form.errors %} +
+ + {% if form.errors.items|length == 1 %} + {% trans "Please correct the error below and try again." %} + {% else %} + {% trans "Please correct the errors below and try again." %} + {% endif %} + +
+ {% endif %} +
+ +
+
+ {% csrf_token %} + +
+
+
+

{% trans 'Change Password' %}

+ +
+
+ Nova senha + + {{ form.old_password.errors }} +
+ +
+ {{ form.new_password1.label_tag }} + + {{ form.new_password1.errors }} +
+ +
+ {{ form.new_password2.label_tag }} + + {{ form.new_password2.errors }} +
+ +
+
+
+
+ +
+
+ +
+ +
+
+ +{% endblock %} diff --git a/src/accounts/templates/registration/password_reset_complete_custom.html b/src/accounts/templates/registration/password_reset_complete_custom.html new file mode 100644 index 00000000..5c2ea207 --- /dev/null +++ b/src/accounts/templates/registration/password_reset_complete_custom.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block pagetitle %}Recuperação de senha concluída{% endblock %} + +{% block main-content %} +

Sua senha foi modificada com sucesso. Clique aqui para fazer o login.

+ +{% endblock %} diff --git a/src/accounts/templates/registration/password_reset_confirm_custom.html b/src/accounts/templates/registration/password_reset_confirm_custom.html new file mode 100644 index 00000000..10e40f28 --- /dev/null +++ b/src/accounts/templates/registration/password_reset_confirm_custom.html @@ -0,0 +1,63 @@ +{% extends "base.html" %} +{% load i18n %} +{% block pagetitle %}{% trans "Criar nova senha" %}{% endblock %} +{% block main-content %} + {% if validlink %} + +
+ {% if form.errors %} +
+ + {% if form.errors.items|length == 1 %} + {% trans "Por favor, corrija o erro e tente novamente." %} + {% else %} + {% trans "Por favor, corrija os erros e tente novamente." %} + {% endif %} + +
+ {% endif %} +
+ +
+
+ {% csrf_token %} + +
+
+
+

{% trans 'Modificar Senha' %}

+ +
+ +
+ Senha + + {{ form.new_password1.errors }} +
+ +
+ Confirmar Senha + + {{ form.new_password2.errors }} +
+ +
+
+
+
+ +
+
+ +
+ +
+
+ {% else %} +

A troca de senha não obteve sucesso.

+

O link é inválido, + provavelmente ele já foi utilizado.
+ Por favor, solicite uma nova recuperação de senha.

+ {% endif %} + +{% endblock %} diff --git a/src/accounts/templates/registration/password_reset_done_custom.html b/src/accounts/templates/registration/password_reset_done_custom.html new file mode 100644 index 00000000..c12f557d --- /dev/null +++ b/src/accounts/templates/registration/password_reset_done_custom.html @@ -0,0 +1,8 @@ +{% extends "base.html" %} + +{% block pagetitle %}Recuperação de senha enviada com sucesso{% endblock %} + +{% block main-content %} +

Nós enviamos as instruções de recuperação de senha para o e-mail informado.

+

Você deve recebê-lo em breve. Caso não receba, verifique sua caixa de spam.

+{% endblock %} diff --git a/src/accounts/templates/registration/password_reset_email_custom.html b/src/accounts/templates/registration/password_reset_email_custom.html new file mode 100644 index 00000000..eb7f87ec --- /dev/null +++ b/src/accounts/templates/registration/password_reset_email_custom.html @@ -0,0 +1,15 @@ +{% autoescape off %} +Você está recebendo este e-mail porque requisitou uma troca de senha no site {{ site_name }}. + +Por favor, clique no link abaixo e preencha o formulário: +{% block reset_link %} +{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} +{% endblock %} + +Seu nome de usuário, caso tenha esquecido: {{ user.username }} + +Obrigado por usar nosso sistema! + +Equipe Colab. + +{% endautoescape %} diff --git a/src/accounts/templates/registration/password_reset_form_custom.html b/src/accounts/templates/registration/password_reset_form_custom.html new file mode 100644 index 00000000..d721db60 --- /dev/null +++ b/src/accounts/templates/registration/password_reset_form_custom.html @@ -0,0 +1,52 @@ +{% extends "base.html" %} +{% load i18n %} +{% block main-content %} + + +
+ {% if form.errors %} +
+ {% trans "Por favor, corrija os campos destacados e tente novamente." %} +
+ {% endif %} +
+ +
+
+ {% csrf_token %} + +
+
+
+

{{ title }}

+
+
{% trans "Esqueceu sua senha? Insira seu endereço de e-mail abaixo, e nós iremos enviar uma mensagem com as instruções para gerar uma nova." %}
+
+
+ + + {{ form.email.errors }} +
+
+
+
+
+ +
+
+

+
+
+ +
+ +{% endblock %} + + + + + + + + + diff --git a/src/accounts/templates/registration/resend_email_verification.html b/src/accounts/templates/registration/resend_email_verification.html new file mode 100644 index 00000000..cd5ef24f --- /dev/null +++ b/src/accounts/templates/registration/resend_email_verification.html @@ -0,0 +1,51 @@ +{% extends "base.html" %} +{% load i18n %} +{% block main-content %} + +
+ {% if form.errors %} +
+ {% trans "Please correct the errors below and try again." %} +
+ {% endif %} +
+ +
+
+ {% csrf_token %} + +
+
+
+

{{ title }}

+
+
{% trans "Enter your email address below, and we'll resend an email verification." %}
+
+
+ + + {{ form.email.errors }} +
+
+
+
+
+ +
+
+

+
+
+ +
+ +{% endblock %} + + + + + + + + + diff --git a/src/accounts/urls.py b/src/accounts/urls.py index b7788d54..205c2e10 100644 --- a/src/accounts/urls.py +++ b/src/accounts/urls.py @@ -1,17 +1,47 @@ from django.conf.urls import patterns, include, url +from django.contrib.auth import views as auth_views +from django.contrib.auth.views import login from .views import (UserProfileDetailView, UserProfileUpdateView, - ManageUserSubscriptionsView, ChangeXMPPPasswordView) + ManageUserSubscriptionsView, ChangeXMPPPasswordView, + password_reset_done_custom, password_reset_complete_custom) urlpatterns = patterns('', url(r'^register/$', 'accounts.views.signup', name='signup'), - url(r'^change-password/$', - ChangeXMPPPasswordView.as_view(), name='change_password'), + url(r'^change-password-xmpp/$', + ChangeXMPPPasswordView.as_view(), + name='change_password_xmpp'), - url(r'^logout/?$', 'django.contrib.auth.views.logout'), + url(r'^novo-login/$', + login, + {'template_name': 'novo_login.html', + 'redirect_field_name': 'previous_path'}, + name='novo_login'), + + url(r'^password-reset/$', auth_views.password_reset, + {'template_name': 'registration/password_reset_form_custom.html', + 'email_template_name':'registration/password_reset_email_custom.html'}, + name="password_reset"), + + url(r'^password-reset-done/?$', password_reset_done_custom, + name="password_reset_done"), + + url(r'^password-reset-confirm/(?P[0-9A-Za-z]+)-(?P.+)/$', + auth_views.password_reset_confirm, + {'template_name': 'registration/password_reset_confirm_custom.html'}, + name="password_reset_confirm"), + + url(r'^password-reset-complete/$', 'accounts.views.password_reset_complete_custom', + name="password_reset_complete"), + + url(r'^change-password/?$', auth_views.password_change, + {'template_name': 'registration/password_change_form_custom.html'}, + name='change_password'), + + url(r'^logout/?$', 'django.contrib.auth.views.logout', {'next_page': '/'}, name='novo_logout'), url(r'^(?P[\w@+.-]+)/?$', UserProfileDetailView.as_view(), name='user_profile'), diff --git a/src/accounts/views.py b/src/accounts/views.py index 29c4fa94..a4745788 100644 --- a/src/accounts/views.py +++ b/src/accounts/views.py @@ -134,16 +134,18 @@ def signup(request): # Check if the user's email have been used previously # in the mainling lists to link the user to old messages + email_addr, created = EmailAddress.objects.get_or_create(address=user.email) + if created: email_addr.real_name = user.get_full_name() email_addr.user = user email_addr.save() - messages.success(request, _('Your profile has been created!')) - messages.warning(request, _('You must login to validated your profile. ' - 'Profiles not validated are deleted in 24h.')) + messages.success(request, _('Seu perfil foi criado com sucesso!')) + # messages.warning(request, _('You must login to validated your profile. ' + # 'Profiles not validated are deleted in 24h.')) return redirect('user_profile', username=user.username) @@ -238,3 +240,20 @@ def form_valid(self, form): _("You've changed your password successfully!") ) return response + + +def password_reset_done_custom(request): + msg = _(("Nós enviamos um email com as intrução para a " + "troca de senha. Você deve recebê-lo em breve. " + "Caso não receba, verifique sua caxa de spam. ")) + messages.success(request, msg) + + return redirect('home') + + +def password_reset_complete_custom(request): + msg = _('Sua senha foi modificada com sucesso. ' + 'Faça o login.') + messages.success(request, msg) + + return redirect('home') diff --git a/src/colab/custom_settings.py b/src/colab/custom_settings.py index 141f59ce..68b5ca4c 100644 --- a/src/colab/custom_settings.py +++ b/src/colab/custom_settings.py @@ -132,7 +132,8 @@ 'disable_existing_loggers': False, 'root': { 'level': 'WARNING', - 'handlers': ['sentry', 'console'], + #'handlers': ['sentry', 'console'], + 'handlers': ['console'], }, 'formatters': { 'verbose': { @@ -151,10 +152,10 @@ 'include_html': True, 'filters': ['require_debug_false'], }, - 'sentry': { - 'level': 'ERROR', - 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', - }, + # 'sentry': { + # 'level': 'ERROR', + # 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', + #}, 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', @@ -163,30 +164,31 @@ }, 'loggers': { 'django.request': { - 'handlers': ['mail_admins', 'sentry'], + #'handlers': ['mail_admins', 'sentry'], + 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True, }, - 'django.db.backends': { - 'level': 'ERROR', - 'handlers': ['sentry'], - 'propagate': False, - }, + #'django.db.backends': { + #'level': 'ERROR', + # 'handlers': ['sentry'], + # 'propagate': False, + # }, 'raven': { 'level': 'DEBUG', 'handlers': ['console'], 'propagate': False, }, - 'sentry.errors': { - 'level': 'DEBUG', - 'handlers': ['console'], - 'propagate': False, - }, - 'django_browserid': { - 'handlers': ['sentry'], - 'level': 'WARNING', - 'propagate': False, - }, + #'sentry.errors': { + # 'level': 'DEBUG', + # 'handlers': ['console'], + # 'propagate': False, + #}, + #'django_browserid': { + # 'handlers': ['sentry'], + # 'level': 'WARNING', + # 'propagate': False, + #}, 'conversejs': { 'handlers': ['console'], 'level': 'DEBUG', @@ -195,10 +197,10 @@ } } -COLAB_FROM_ADDRESS = '"Colab Interlegis" ' -SERVER_EMAIL = COLAB_FROM_ADDRESS -EMAIL_HOST = 'smtp.interlegis.leg.br' -EMAIL_PORT = 25 +# COLAB_FROM_ADDRESS = '"Colab Interlegis" ' +# SERVER_EMAIL = COLAB_FROM_ADDRESS +# EMAIL_HOST = 'smtp.interlegis.leg.br' +# EMAIL_PORT = 25 TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.auth.context_processors.auth', diff --git a/src/colab/local_settings-dev.py b/src/colab/local_settings-dev.py index 0f8d667c..20106e71 100644 --- a/src/colab/local_settings-dev.py +++ b/src/colab/local_settings-dev.py @@ -1,7 +1,7 @@ from custom_settings import * -DEBUG = True +DEBUG = False TEMPLATE_DEBUG = DEBUG ADMINS = ( @@ -35,6 +35,15 @@ COLAB_TRAC_URL = 'http://localhost:5000/' COLAB_CI_URL = 'http://localhost:8080/ci/' +MIDDLEWARE_CLASSES = ( + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +) + CONVERSEJS_ENABLED = False DIAZO_THEME = SITE_URL diff --git a/src/colab/settings.py b/src/colab/settings.py index 56e24e8e..10ff214f 100644 --- a/src/colab/settings.py +++ b/src/colab/settings.py @@ -20,9 +20,9 @@ SECRET_KEY = 'd%gy$gfn4z2=z414qvqouyd2h6_i8nr_m4zmlxqklu15u!8&^@' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False -TEMPLATE_DEBUG = True +TEMPLATE_DEBUG = False ALLOWED_HOSTS = [] @@ -82,4 +82,14 @@ STATIC_URL = '/static/' MEDIA_URL = '/media/' + +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +EMAIL_HOST = 'smtp.interlegis.leg.br' +EMAIL_PORT = 25 +EMAIL_SEND_USER = '"Colab Interlegis"' +EMAIL_HOST_USER = '' +EMAIL_HOST_PASSWORD = '' +DEFAULT_FROM_EMAIL = '"Colab Interlegis"' + + from custom_settings import * diff --git a/src/locale/pt_BR/LC_MESSAGES/django.mo b/src/locale/pt_BR/LC_MESSAGES/django.mo index 7e27c3e7..2612cbd6 100644 Binary files a/src/locale/pt_BR/LC_MESSAGES/django.mo and b/src/locale/pt_BR/LC_MESSAGES/django.mo differ diff --git a/src/locale/pt_BR/LC_MESSAGES/django.po b/src/locale/pt_BR/LC_MESSAGES/django.po index f50197a1..8b888d43 100644 --- a/src/locale/pt_BR/LC_MESSAGES/django.po +++ b/src/locale/pt_BR/LC_MESSAGES/django.po @@ -450,7 +450,6 @@ msgid "In one month" msgstr "" #: colab/custom_settings.py:313 -#, fuzzy msgid "Never" msgstr "Seriedade" diff --git a/src/proxy/views.py b/src/proxy/views.py index eb5efcb8..42a88db0 100644 --- a/src/proxy/views.py +++ b/src/proxy/views.py @@ -12,7 +12,7 @@ DIAZO_RULES_DIR = os.path.join(CWD, 'diazo') class TracProxyView(HitCounterViewMixin, ProxyView): - base_url = settings.COLAB_TRAC_URL + upstream = settings.COLAB_TRAC_URL add_remote_user = settings.REVPROXY_ADD_REMOTE_USER diazo_theme_template = 'proxy/trac.html' diazo_rules = os.path.join(DIAZO_RULES_DIR, 'trac.xml') @@ -50,7 +50,7 @@ def get_object(self): class JenkinsProxyView(ProxyView): - base_url = settings.COLAB_CI_URL + upstream = settings.COLAB_CI_URL add_remote_user = settings.REVPROXY_ADD_REMOTE_USER diazo_theme_template = 'base.html' diazo_rules = os.path.join(DIAZO_RULES_DIR, 'jenkins.xml') diff --git a/src/super_archives/models.py b/src/super_archives/models.py index 6e4c35db..77c72dc8 100644 --- a/src/super_archives/models.py +++ b/src/super_archives/models.py @@ -300,8 +300,11 @@ def unvote(self, user): @property def url(self): """Shortcut to get thread url""" - return reverse('thread_view', args=[self.mailinglist.name, - self.thread.subject_token]) + try: + return reverse('thread_view', args=[self.mailinglist.name, + self.thread.subject_token]) + except: + return '/' @property def description(self): diff --git a/src/templates/base.html b/src/templates/base.html index 8ac87182..7afc527e 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -1,5 +1,5 @@ -{% load i18n browserid conversejs gravatar %} +{% load i18n conversejs gravatar %} {% block head %} @@ -76,7 +76,7 @@ {% if user.is_active %}
  • {% trans "New Wiki Page" %}
  • {% endif %} -
  • {% trans "View Tickets" %}
  • +
  • {% trans "View Tickets" %}
  • {% if user.is_active %}
  • {% trans "New Ticket" %}
  • {% endif %} @@ -106,12 +106,12 @@ {% trans 'Login' as login_text %} - + {% else %} @@ -203,8 +203,8 @@ {% endif %} {% include "tz/set_utc_offset.html" %} - {% browserid_js %} {% block footer_js %}{% endblock %} +