diff --git a/later42/settings.py b/later42/settings.py index 2432381..1067fa8 100644 --- a/later42/settings.py +++ b/later42/settings.py @@ -33,13 +33,13 @@ CSRF_TRUSTED_ORIGINS = ['https://' + os.getenv('DOMAIN', 'localhost')] # Application definition INSTALLED_APPS = [ + 'later42', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'later42', 'rest_framework', 'rest_framework.authtoken', ] @@ -162,6 +162,8 @@ URLS_PER_PAGE = 20 READABILITY_HOST = os.getenv('READABILITY_HOST', None) EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +if DEBUG: + EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' EMAIL_USE_TLS = os.getenv('EMAIL_USE_TLS', False) EMAIL_HOST = os.getenv('EMAIL_HOST', 'smtp') EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER', None) diff --git a/later42/templates/profile.html b/later42/templates/profile.html index 26b2546..60e9562 100644 --- a/later42/templates/profile.html +++ b/later42/templates/profile.html @@ -24,6 +24,13 @@ {{ user.email }} +
+
+
+
+ Сменить пароль +
+

diff --git a/later42/templates/email_activation.html b/later42/templates/registration/email_activation.html similarity index 99% rename from later42/templates/email_activation.html rename to later42/templates/registration/email_activation.html index 392ba21..986d3bf 100644 --- a/later42/templates/email_activation.html +++ b/later42/templates/registration/email_activation.html @@ -1,5 +1,6 @@ {% autoescape off %} Привет, {{ user.username }}. + Ссылка для активации аккаунта: https://{{ domain }}{% url 'activate' uidb64=uid token=token %} {% endautoescape %} \ No newline at end of file diff --git a/later42/templates/email_sent.html b/later42/templates/registration/email_sent.html similarity index 100% rename from later42/templates/email_sent.html rename to later42/templates/registration/email_sent.html diff --git a/later42/templates/registration/login.html b/later42/templates/registration/login.html index 4872c8b..9218197 100644 --- a/later42/templates/registration/login.html +++ b/later42/templates/registration/login.html @@ -5,8 +5,14 @@
{% csrf_token %} {{ form.as_p }} - +
+
+ +
+ +

{% endblock %} - diff --git a/later42/templates/registration/password_change_done.html b/later42/templates/registration/password_change_done.html new file mode 100644 index 0000000..eb2eb63 --- /dev/null +++ b/later42/templates/registration/password_change_done.html @@ -0,0 +1,6 @@ +{% extends "base.html" %} + +{% block content %} +

Пароль успешно изменен.

+

Перейти в Профиль.

+{% endblock %} \ No newline at end of file diff --git a/later42/templates/registration/password_change_form.html b/later42/templates/registration/password_change_form.html new file mode 100644 index 0000000..3968b76 --- /dev/null +++ b/later42/templates/registration/password_change_form.html @@ -0,0 +1,14 @@ +{% extends 'base.html' %} +{% block content %} +
+
+

Смена пароля

+
+{% csrf_token %} +{{ form.as_p }} + +
+
+
+
+{% endblock %} diff --git a/later42/templates/registration/password_reset_complete.html b/later42/templates/registration/password_reset_complete.html new file mode 100644 index 0000000..c58b876 --- /dev/null +++ b/later42/templates/registration/password_reset_complete.html @@ -0,0 +1,6 @@ +{% extends "base.html" %} + +{% block content %} +

Пароль успешно изменен.

+

Вы можете войти.

+{% endblock %} \ No newline at end of file diff --git a/later42/templates/registration/password_reset_confirm.html b/later42/templates/registration/password_reset_confirm.html new file mode 100644 index 0000000..8daf8bc --- /dev/null +++ b/later42/templates/registration/password_reset_confirm.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} + +{% block content %} + {% if validlink %} +

Введите новый пароль.

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

Сброс пароля прошел неудачно

+

Ссылка неверная или уже была использована.
+ Попробуйте сбросить пароль еще раз.

+ {% endif %} +{% endblock %} \ No newline at end of file diff --git a/later42/templates/registration/password_reset_done.html b/later42/templates/registration/password_reset_done.html new file mode 100644 index 0000000..1790614 --- /dev/null +++ b/later42/templates/registration/password_reset_done.html @@ -0,0 +1,6 @@ +{% extends "base.html" %} + +{% block content %} +

Сообщение успешно отправлено.

+

Вы должны получить его в скором времени.

+{% endblock %} \ No newline at end of file diff --git a/later42/templates/registration/password_reset_form.html b/later42/templates/registration/password_reset_form.html new file mode 100644 index 0000000..5eb7dd2 --- /dev/null +++ b/later42/templates/registration/password_reset_form.html @@ -0,0 +1,14 @@ +{% extends 'base.html' %} +{% block content %} +
+
+

Reset your password

+
+{% csrf_token %} +{{ form.as_p }} + +
+
+
+ +{% endblock %} diff --git a/later42/templates/signup.html b/later42/templates/registration/signup.html similarity index 100% rename from later42/templates/signup.html rename to later42/templates/registration/signup.html diff --git a/later42/urls.py b/later42/urls.py index 39d2929..fd49e48 100644 --- a/later42/urls.py +++ b/later42/urls.py @@ -17,11 +17,11 @@ from django.contrib import admin from django.urls import path, include from django.contrib.auth.models import User -from django.contrib.auth.views import LoginView +# from django.contrib.auth import views from rest_framework import routers, serializers, viewsets -from later42.forms import CustomLoginForm +# from later42.forms import CustomLoginForm from later42.views import account_activation, index, profile, api, api_token, reader, signup, about @@ -44,9 +44,7 @@ urlpatterns = [ path('signup/', signup.register, name='signup'), path(r'^activate/(?P[0-9A-Za-z_\-]+)/(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', account_activation.activate, name='activate'), - path("accounts/login/", - LoginView.as_view(authentication_form=CustomLoginForm), name="login"), - path("accounts/", include("django.contrib.auth.urls")), + path('accounts/', include('django.contrib.auth.urls')), path('profile/', profile.get, name='profile'), path('api/url/', api.URL.as_view(), name='urls'), path('delete/', index.delete, name='delete'), diff --git a/later42/views/signup.py b/later42/views/signup.py index 8902789..a303bee 100644 --- a/later42/views/signup.py +++ b/later42/views/signup.py @@ -15,18 +15,14 @@ def register(request): form = SignUpForm(request.POST) if form.is_valid(): user = form.save(commit=False) - # user.refresh_from_db() user.is_active = False user.save() raw_password = form.cleaned_data.get('password1') current_site = get_current_site(request) - # user = authenticate(username=user.username, password=raw_password) - # login(request, user) - mail_subject = 'Later42: Активация аккаунта' - message = render_to_string('email_activation.html', { + message = render_to_string('registration/email_activation.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)), @@ -39,7 +35,7 @@ def register(request): ) email.send() - return render(request, 'email_sent.html') + return render(request, 'registration/email_sent.html') else: form = SignUpForm() - return render(request, 'signup.html', {'form': form}) + return render(request, 'registration/signup.html', {'form': form})