diff --git a/apps/auth/templates/auth/login.html b/apps/auth/templates/auth/login.html
index e69de29b..6db81cb1 100644
--- a/apps/auth/templates/auth/login.html
+++ b/apps/auth/templates/auth/login.html
@@ -0,0 +1,49 @@
+{% extends "templates/lilcity/layer.html" %} {% load static %}
+
+{% block layer_body %}
+
Для восстановления пароля нажмите кнопку ниже.
-
-
Нажмите для восстановления
-
Или скопируйте ссылку ниже, и вставьте её в адресную строку браузера.
-
{{ domain }}{% url 'lilcity:password_reset_confirm' uidb64=uid token=token %}
+{% block layer_body %}
+
+ {% include "templates/blocks/header.html" with no_auth_btn=True %}
+
+
+
+
Восстановление пароля
+
+
+
+
-{% endblock content %}
+{% endblock layer_body %}
diff --git a/apps/auth/templates/auth/password_reset_email.html b/apps/auth/templates/auth/password_reset_email.html
new file mode 100644
index 00000000..a9a3af16
--- /dev/null
+++ b/apps/auth/templates/auth/password_reset_email.html
@@ -0,0 +1,14 @@
+{% extends "notification/email/_base.html" %}
+
+{% block content %}
+
Для восстановления пароля нажмите кнопку ниже.
+
+
Нажмите для восстановления
+
Или скопируйте ссылку ниже, и вставьте её в адресную строку браузера.
+
{{ domain }}{% url 'lilcity:password_reset_confirm' uidb64=uid token=token %}
+
+{% endblock content %}
diff --git a/apps/auth/templates/auth/password_reset.txt b/apps/auth/templates/auth/password_reset_email.txt
similarity index 100%
rename from apps/auth/templates/auth/password_reset.txt
rename to apps/auth/templates/auth/password_reset_email.txt
diff --git a/apps/auth/templates/auth/registration-learner.html b/apps/auth/templates/auth/registration-learner.html
index de155ea5..fd223391 100644
--- a/apps/auth/templates/auth/registration-learner.html
+++ b/apps/auth/templates/auth/registration-learner.html
@@ -1,10 +1,92 @@
-
-
-
-
-
Title
-
-
-
-
-
\ No newline at end of file
+{% extends "templates/lilcity/layer.html" %} {% load static %}
+
+{% block layer_body %}
+
+ {% include "templates/blocks/header.html" with no_auth_btn=True %}
+
+
+{% endblock layer_body %}
diff --git a/apps/auth/views.py b/apps/auth/views.py
index 5db4d77c..d85a75aa 100644
--- a/apps/auth/views.py
+++ b/apps/auth/views.py
@@ -31,6 +31,7 @@ User = get_user_model()
class LearnerRegistrationView(FormView):
form_class = LearnerRegistrationForm
template_name = "auth/registration-learner.html"
+ success_url = '/'
def form_valid(self, form):
config = Config.load()
@@ -44,10 +45,15 @@ class LearnerRegistrationView(FormView):
)
if not created:
- return JsonResponse({
- "success": False,
- 'errors': {'__all__': [{'message': 'Возможно вы уже зарегистрированы?'}]}
- }, status=400)
+ if self.request.is_ajax():
+ return JsonResponse({
+ "success": False,
+ 'errors': {'__all__': [{'message': 'Возможно вы уже зарегистрированы?'}]}
+ }, status=400)
+ else:
+ context = self.get_context_data(form=form)
+ context['error'] = 'Возможно вы уже зарегистрированы?'
+ return self.render_to_response(context)
user.username = email
user.first_name = first_name
@@ -71,10 +77,16 @@ class LearnerRegistrationView(FormView):
url = http_referer + str(reverse_lazy('lilcity:verification-email', args=[token, user.id]))
send_email('Вы успешно прошли регистрацию', email, "notification/email/verification_email.html", url=url, config=config)
- return JsonResponse({"success": True}, status=201)
+ if self.request.is_ajax():
+ return JsonResponse({"success": True}, status=201)
+ else:
+ return super().form_valid(form)
def form_invalid(self, form):
- return JsonResponse(form.errors.get_json_data(escape_html=True), status=400)
+ if self.request.is_ajax():
+ return JsonResponse(form.errors.get_json_data(escape_html=True), status=400)
+ else:
+ return super().form_invalid(form)
class LogoutView(View):
@@ -86,14 +98,21 @@ class LogoutView(View):
class LoginView(FormView):
form_class = AuthenticationForm
template_name = "auth/login.html"
+ success_url = '/'
def form_valid(self, form):
login(self.request, form.get_user())
self.request.session['referrer'] = None
- return JsonResponse({"success": True})
+ if self.request.is_ajax():
+ return JsonResponse({"success": True})
+ else:
+ return super().form_valid(form)
def form_invalid(self, form):
- return JsonResponse({"success": False, "errors": form.errors.get_json_data(escape_html=True)}, status=400)
+ if self.request.is_ajax():
+ return JsonResponse({"success": False, "errors": form.errors.get_json_data(escape_html=True)}, status=400)
+ else:
+ return super().form_invalid(form)
class VerificationEmailView(View):
@@ -116,20 +135,19 @@ class SuccessVerificationEmailView(TemplateView):
template_name = 'auth/success-verification.html'
-class PasswordResetView(views.PasswordContextMixin, BaseFormView):
- email_template_name = 'auth/password_reset.txt'
+class PasswordResetView(views.PasswordContextMixin, FormView):
+ email_template_name = 'auth/password_reset_email.txt'
subject_template_name = "auth/password_reset_subject.txt"
form_class = views.PasswordResetForm
+ template_name = "auth/password_reset.html"
+ success_url = '/'
extra_email_context = None
from_email = None
- html_email_template_name = "auth/password_reset.html"
+ html_email_template_name = "auth/password_reset_email.html"
title = 'Password reset'
token_generator = views.default_token_generator
- def get(self, *args, **kwargs):
- raise Http404()
-
def form_valid(self, form):
config = Config.load()
extra_email_context = {'config': config}
@@ -147,7 +165,10 @@ class PasswordResetView(views.PasswordContextMixin, BaseFormView):
'extra_email_context': extra_email_context,
}
form.save(**opts)
- return JsonResponse({"success": True})
+ if self.request.is_ajax():
+ return JsonResponse({"success": True})
+ else:
+ return super().form_valid(form)
class PasswordResetConfirmView(views.PasswordResetConfirmView):
diff --git a/project/templates/blocks/user_menu.html b/project/templates/blocks/user_menu.html
index b491686c..ae3b9a4b 100644
--- a/project/templates/blocks/user_menu.html
+++ b/project/templates/blocks/user_menu.html
@@ -47,6 +47,7 @@
{% else %}
-
+ {% if not no_auth_btn %}
+
+ {% endif %}
{% endif %}
diff --git a/project/templates/lilcity/index.html b/project/templates/lilcity/index.html
index 222f57ca..de69fbf1 100644
--- a/project/templates/lilcity/index.html
+++ b/project/templates/lilcity/index.html
@@ -5,28 +5,6 @@
{% load compress %}
{% block layer_head %}
-
-
-
-
-
{% block head %}{% endblock head %}
{% endblock layer_head %}
@@ -52,6 +30,7 @@
{% include "templates/blocks/popup_capture_email.html" %}
{% include "templates/blocks/popup_bonuses_came.html" %}
+ {% block foot %}{% endblock foot %}
{% include 'templates/blocks/lil_store_js.html' %}
{% block pre_app_js %}{% endblock pre_app_js %}
@@ -63,6 +42,27 @@
- {% block foot %}{% endblock foot %}
+
+
+
+
+
{% block foot_js %}{% endblock foot_js %}
{% endblock layer_body %}
diff --git a/web/src/js/modules/auth.js b/web/src/js/modules/auth.js
index c921b0c7..1015db5f 100644
--- a/web/src/js/modules/auth.js
+++ b/web/src/js/modules/auth.js
@@ -143,46 +143,48 @@ $(document).ready(function () {
let authButton = $('#learner-auth__button');
authButton.addClass('loading');
- $.ajax(authForm.attr('action'), {
- method: 'POST',
- data: authForm.serialize(),
- })
- .done(function (data) {
- if (data.success === true) {
- const nextUrl = popup.data('next-url');
- if(nextUrl){
- window.location.href = nextUrl;
- }
- else{
- window.location.reload();
+ if(! authForm.data('no-ajax')){
+ $.ajax(authForm.attr('action'), {
+ method: 'POST',
+ data: authForm.serialize(),
+ })
+ .done(function (data) {
+ if (data.success === true) {
+ const nextUrl = popup.data('next-url');
+ if(nextUrl){
+ window.location.href = nextUrl;
+ }
+ else{
+ window.location.reload();
+ }
+ } else {
+ authButton.removeClass('loading');
}
- } else {
+ })
+ .fail(function (xhr) {
+ console.log('error', xhr);
authButton.removeClass('loading');
- }
- })
- .fail(function (xhr) {
- console.log('error', xhr);
- authButton.removeClass('loading');
- if (xhr.status === 400) {
- if (xhr.responseJSON.errors) {
- for (let errorField in xhr.responseJSON.errors) {
- if (!xhr.responseJSON.errors.hasOwnProperty(errorField)) {
- continue;
+ if (xhr.status === 400) {
+ if (xhr.responseJSON.errors) {
+ for (let errorField in xhr.responseJSON.errors) {
+ if (!xhr.responseJSON.errors.hasOwnProperty(errorField)) {
+ continue;
+ }
+ const errorMessage = xhr.responseJSON.errors[errorField][0].message;
+ if (errorField === '__all__') {
+ $('#learner-auth-field-error__all').text(errorMessage).show();
+ } else {
+ $(`#learner-auth-field-error__${errorField}`).text(errorMessage);
+ $(`#learner-auth-field__${errorField}`).addClass('error');
+ }
}
- const errorMessage = xhr.responseJSON.errors[errorField][0].message;
- if (errorField === '__all__') {
- $('#learner-auth-field-error__all').text(errorMessage).show();
- } else {
- $(`#learner-auth-field-error__${errorField}`).text(errorMessage);
- $(`#learner-auth-field__${errorField}`).addClass('error');
- }
- }
- return;
+ return;
+ }
}
- }
- $('#learner-auth-field-error__all').text('Произошла незвестная ошибка');
- });
+ $('#learner-auth-field-error__all').text('Произошла незвестная ошибка');
+ });
+ }
});
let registrationForm = $('#learner-registration-form');
@@ -230,10 +232,11 @@ $(document).ready(function () {
let registrationButton = $('#learner-registration-form__submit-button');
registrationButton.addClass('loading');
- $.ajax(registrationForm.attr('action'), {
- method: 'POST',
- data: registrationForm.serialize(),
- })
+ if(! registrationForm.data('no-ajax')){
+ $.ajax(registrationForm.attr('action'), {
+ method: 'POST',
+ data: registrationForm.serialize(),
+ })
.done(function (data) {
if (data.success === true) {
const nextUrl = popup.data('next-url');
@@ -271,12 +274,14 @@ $(document).ready(function () {
$('#learner-registration-field-error__all').text('Произошла незвестная ошибка');
});
+ }
});
$.ajaxSetup({cache: true});
load_facebook();
const facebookButton = $('button.btn_fb');
+ facebookButton.show();
facebookButton.on('click', function () {
$('.auth-register__common-error').hide();
facebookButton.addClass('loading');