From 90755147fdad713f675b7501129002fc23659bea Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 7 Aug 2019 20:08:28 +0300 Subject: [PATCH 1/6] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=87=D0=BD=D1=83=D1=8E=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8E=20=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D1=8B=20=D0=9B=D0=BE=D0=B3=D0=B8=D0=BD=20/?= =?UTF-8?q?=20=D0=A0=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/auth/templates/auth/login.html | 49 +++++++++ .../templates/auth/password_reset_email.html | 14 +++ ...ord_reset.txt => password_reset_email.txt} | 0 .../templates/auth/registration-learner.html | 102 ++++++++++++++++-- apps/auth/views.py | 51 ++++++--- project/templates/blocks/user_menu.html | 6 +- project/templates/lilcity/index.html | 46 ++++---- web/src/js/modules/auth.js | 83 +++++++------- 8 files changed, 262 insertions(+), 89 deletions(-) create mode 100644 apps/auth/templates/auth/password_reset_email.html rename apps/auth/templates/auth/{password_reset.txt => password_reset_email.txt} (100%) 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 %} +
+ {% include "templates/blocks/header.html" with no_auth_btn=True %} +
+
+
+
Авторизация
+
+ {% csrf_token %} +
+
ПОЧТА
+
+ +
+ {% for error in form.username.errors %} +
{{ error }}
+ {% endfor %} +
+
+ +
+ +
+ {% for error in form.password.errors %} +
{{ error }}
+ {% endfor %} + {% for error in form.non_field_errors %} +
{{ error }}
+ {% endfor %} +
+
+ +
или
+ Зарегистрироваться +
+
+
+
+
+
+{% 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 %} +
+
+
+
Регистрация
+
+ {% csrf_token %} + + {% if referrer %} + +
+ Спасибо за то, что вы с нами! Вас пригласил ваш друг {{ referrer.get_full_name }}. + При первой покупке {{ config.REFERRAL_BONUS }}% от суммы услуги будут зачислены на ваш бонусный счет. + Приятного обучения! +
+ {% endif %} +
+
+
ИМЯ
+
+ +
+ {% for error in form.first_name.errors %} +
{{ error }}
+ {% endfor %} +
+
+
ФАМИЛИЯ
+
+ +
+ {% for error in form.last_name.errors %} +
{{ error }}
+ {% endfor %} +
+
+
+
ПОЧТА
+
+ +
+ {% for error in form.email.errors %} +
{{ error }}
+ {% endfor %} +
+
+
ПАРОЛЬ
+
+ + +
+ {% for error in form.password.errors %} +
{{ error }}
+ {% endfor %} + + {% for error in form.non_field_errors %} +
{{ error }}
+ {% endfor %} + {% if error %} +
{{ error }}
+ {% endif %} +
+ + +
+ +
+
+
+
+
+
+{% 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..f1735fba 100644 --- a/project/templates/blocks/user_menu.html +++ b/project/templates/blocks/user_menu.html @@ -47,6 +47,8 @@ {% 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'); From 68b84788aee11fc21e63b883378e0833928b0a15 Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 7 Aug 2019 20:12:58 +0300 Subject: [PATCH 2/6] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=87=D0=BD=D1=83=D1=8E=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8E=20=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D1=8B=20=D0=9B=D0=BE=D0=B3=D0=B8=D0=BD=20/?= =?UTF-8?q?=20=D0=A0=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/auth/templates/auth/password_reset.html | 42 ++++++++++++++------ project/templates/blocks/user_menu.html | 3 +- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/apps/auth/templates/auth/password_reset.html b/apps/auth/templates/auth/password_reset.html index a9a3af16..05377160 100644 --- a/apps/auth/templates/auth/password_reset.html +++ b/apps/auth/templates/auth/password_reset.html @@ -1,14 +1,32 @@ -{% extends "notification/email/_base.html" %} +{% extends "templates/lilcity/layer.html" %} {% load static %} -{% block content %} -

Для восстановления пароля нажмите кнопку ниже.

-
- Нажмите для восстановления -

Или скопируйте ссылку ниже, и вставьте её в адресную строку браузера.

-

{{ domain }}{% url 'lilcity:password_reset_confirm' uidb64=uid token=token %}

+{% block layer_body %} +
+ {% include "templates/blocks/header.html" with no_auth_btn=True %} +
+
+
+
Восстановление пароля
+
+ {% csrf_token %} +
+
+
ПОЧТА + Войти +
+
+ +
+
+
+
+
+ +
+
+
+
+
+
-{% endblock content %} +{% endblock layer_body %} diff --git a/project/templates/blocks/user_menu.html b/project/templates/blocks/user_menu.html index f1735fba..ae3b9a4b 100644 --- a/project/templates/blocks/user_menu.html +++ b/project/templates/blocks/user_menu.html @@ -48,7 +48,6 @@
{% else %} {% if not no_auth_btn %} - ВХОД / РЕГИСТРАЦИЯ + ВХОД / РЕГИСТРАЦИЯ {% endif %} - {% endif %} From 3357ebb50b39280aaa8248dfe57e11432e48618a Mon Sep 17 00:00:00 2001 From: gzbender Date: Thu, 8 Aug 2019 14:05:57 +0300 Subject: [PATCH 3/6] =?UTF-8?q?=D0=BD=D0=B5=20=D0=BE=D1=82=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D1=8F=D0=B5=D1=82=D1=81=D1=8F=20=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D1=82=D0=B8=D1=81=D1=82=D0=B8=D0=BA=D0=B0=20roistat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/payment/tasks.py | 9 ++++++- project/settings.py | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/apps/payment/tasks.py b/apps/payment/tasks.py index e30f4e19..cc2e2f03 100644 --- a/apps/payment/tasks.py +++ b/apps/payment/tasks.py @@ -55,4 +55,11 @@ def transaction_to_roistat(user_id, payment_id, event_name, amount, time, status key = settings.ROISTAT_KEY url = settings.ROISTAT_API_URL + f'/project/add-orders?key={key}&project={project}' resp = requests.post(url, json=body) - logger.info('TRANSACTION_TO_ROISTAT: ' + str(resp)) + try: + resp_json = resp.json() + except: + resp_json = None + if resp.status_code != 200 or not resp_json or not resp_json.get('processed'): + logger.error('TRANSACTION_TO_ROISTAT for payment # %d, %s RUB: %s' % (payment_id, amount, resp.text)) + else: + logger.info('TRANSACTION_TO_ROISTAT: ' + str(resp)) diff --git a/project/settings.py b/project/settings.py index 0cfc970e..75d0013e 100644 --- a/project/settings.py +++ b/project/settings.py @@ -162,6 +162,68 @@ USE_L10N = True # USE_TZ = True +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse' + }, + 'require_debug_true': { + '()': 'django.utils.log.RequireDebugTrue' + } + }, + 'formatters': { + 'verbose': { + 'format': '%(levelname)s:%(name)s: %(message)s ' + '(%(asctime)s; %(filename)s:%(lineno)d)', + 'datefmt': "%Y-%m-%d %H:%M:%S", + }, + 'simple': { + 'format': '{levelname} {message}', + 'style': '{', + }, + }, + 'handlers': { + 'mail_admins': { + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'django.utils.log.AdminEmailHandler' + }, + 'console': { + 'level': 'DEBUG', + 'filters': ['require_debug_true'], + 'class': 'logging.StreamHandler', + 'formatter': 'verbose', + }, + 'log_file': { + 'level': 'INFO', + 'class': 'logging.handlers.RotatingFileHandler', + 'filename': 'logs/main.log', + 'maxBytes': 1024 * 1024 * 5, # 5 MB + 'backupCount': 7, + 'formatter': 'verbose', + 'filters': ['require_debug_false'], + }, + }, + 'loggers': { + 'django.request': { + 'handlers': ['mail_admins', 'console'], + 'level': 'ERROR', + 'propagate': True, + }, + 'django': { + 'handlers': ['console', ], + }, + 'py.warnings': { + 'handlers': ['console', ], + }, + '': { + 'handlers': ['console', 'log_file',], + 'level': "INFO", + }, + } +} # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.0/howto/static-files/ From fe57c41691f7a08c45c818752c3ec7957fe96927 Mon Sep 17 00:00:00 2001 From: gzbender Date: Thu, 8 Aug 2019 20:48:57 +0300 Subject: [PATCH 4/6] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=87=D0=BD=D1=83=D1=8E=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8E=20=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D1=8B=20=D0=9B=D0=BE=D0=B3=D0=B8=D0=BD=20/?= =?UTF-8?q?=20=D0=A0=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/auth/templates/auth/login.html | 2 +- apps/auth/templates/auth/password_reset.html | 2 +- apps/auth/templates/auth/registration-learner.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/auth/templates/auth/login.html b/apps/auth/templates/auth/login.html index 6db81cb1..861ed328 100644 --- a/apps/auth/templates/auth/login.html +++ b/apps/auth/templates/auth/login.html @@ -5,7 +5,7 @@ {% include "templates/blocks/header.html" with no_auth_btn=True %}
-
+
Авторизация
{% csrf_token %} diff --git a/apps/auth/templates/auth/password_reset.html b/apps/auth/templates/auth/password_reset.html index 05377160..8563d244 100644 --- a/apps/auth/templates/auth/password_reset.html +++ b/apps/auth/templates/auth/password_reset.html @@ -5,7 +5,7 @@ {% include "templates/blocks/header.html" with no_auth_btn=True %}
-
+
Восстановление пароля
{% csrf_token %} diff --git a/apps/auth/templates/auth/registration-learner.html b/apps/auth/templates/auth/registration-learner.html index fd223391..46480246 100644 --- a/apps/auth/templates/auth/registration-learner.html +++ b/apps/auth/templates/auth/registration-learner.html @@ -5,7 +5,7 @@ {% include "templates/blocks/header.html" with no_auth_btn=True %}
-
+
Регистрация
{% csrf_token %} From 6cdf6583a290ccc8fd153d85641b1a3127956c18 Mon Sep 17 00:00:00 2001 From: gzbender Date: Thu, 8 Aug 2019 20:58:56 +0300 Subject: [PATCH 5/6] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=87=D0=BD=D1=83=D1=8E=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8E=20=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D1=8B=20=D0=9B=D0=BE=D0=B3=D0=B8=D0=BD=20/?= =?UTF-8?q?=20=D0=A0=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/settings.py b/project/settings.py index 75d0013e..817c2938 100644 --- a/project/settings.py +++ b/project/settings.py @@ -199,7 +199,7 @@ LOGGING = { 'log_file': { 'level': 'INFO', 'class': 'logging.handlers.RotatingFileHandler', - 'filename': 'logs/main.log', + 'filename': 'media/logs/main.log', 'maxBytes': 1024 * 1024 * 5, # 5 MB 'backupCount': 7, 'formatter': 'verbose', From a6d9e828195583265c4fa3e65600c325c543ecba Mon Sep 17 00:00:00 2001 From: gzbender Date: Thu, 8 Aug 2019 21:28:23 +0300 Subject: [PATCH 6/6] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=87=D0=BD=D1=83=D1=8E=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8E=20=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D1=8B=20=D0=9B=D0=BE=D0=B3=D0=B8=D0=BD=20/?= =?UTF-8?q?=20=D0=A0=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/settings.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/project/settings.py b/project/settings.py index 817c2938..3218b5a2 100644 --- a/project/settings.py +++ b/project/settings.py @@ -197,13 +197,10 @@ LOGGING = { 'formatter': 'verbose', }, 'log_file': { - 'level': 'INFO', - 'class': 'logging.handlers.RotatingFileHandler', - 'filename': 'media/logs/main.log', - 'maxBytes': 1024 * 1024 * 5, # 5 MB - 'backupCount': 7, + 'level': 'DEBUG', + 'filters': ['require_debug_true'], + 'class': 'logging.StreamHandler', 'formatter': 'verbose', - 'filters': ['require_debug_false'], }, }, 'loggers': { @@ -225,6 +222,17 @@ LOGGING = { } } +if os.path.exists(os.path.join(BASE_DIR, '/media/logs')): + LOGGING['handlers']['log_file'] = { + 'level': 'INFO', + 'class': 'logging.handlers.RotatingFileHandler', + 'filename': 'media/logs/main.log', + 'maxBytes': 1024 * 1024 * 15, # 5 MB + 'backupCount': 7, + 'formatter': 'verbose', + 'filters': ['require_debug_false'], + } + # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.0/howto/static-files/