diff --git a/archilance/settings/base.py b/archilance/settings/base.py index 2c61f25..4327834 100644 --- a/archilance/settings/base.py +++ b/archilance/settings/base.py @@ -249,16 +249,17 @@ REST_FRAMEWORK = { SITE_ID = 1 -EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'localhost' EMAIL_HOST_PASSWORD = '' EMAIL_HOST_USER = '' EMAIL_PORT = 25 -EMAIL_USE_TLS = False -EMAIL_USE_SSL = False -EMAIL_TIMEOUT = 60 -EMAIL_DEFAULT = 'noreply@archilance.ru' +# EMAIL_USE_TLS = False +# EMAIL_USE_SSL = False +# EMAIL_TIMEOUT = 60 +# EMAIL_DEFAULT = 'noreply@archilance.ru' +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' SHELL_PLUS_POST_IMPORTS = ( # Extra auto imports 'natsort', diff --git a/archilance/views.py b/archilance/views.py index adc0eab..b397333 100644 --- a/archilance/views.py +++ b/archilance/views.py @@ -1,8 +1,10 @@ from django.views.generic import TemplateView, View from django.shortcuts import render +from django.template.loader import render_to_string from projects.models import Order -from common.models import MainPage +from common.models import MainPage, PrintDocuments + class HomeTemplateView(View): template_name = 'home.html' @@ -11,9 +13,33 @@ class HomeTemplateView(View): main_settings = MainPage.objects.get(pk=1) return render(request, self.template_name, {'main_settings': main_settings}) + class TestChatTemplateView(View): template_name = 'chat_test.html' - def get(self,request,*args,**kwargs): - order = Order.objects.get(pk=6) - return render(request, self.template_name, {'order': order}) + def get(self, request, *args, **kwargs): + from common.models import PrintDocuments + + print_documents = PrintDocuments.objects.all() + limit_size = 10 * 1024 * 1024 + attachments = [] + link_files = [] + + for f in print_documents: + if f.file.size > limit_size: + link_files.append(f.file.path) + else: + attachments.append(f.file.path) + + + html_content = render_to_string('document_email.txt', + { + 'username': 'Mukhtar', + 'phone': '89634004278', + 'files': link_files, + } + ) + + print(html_content) + + return render(request, 'chat_test.html', {'html_content': html_content}) diff --git a/common/management/__init__.py b/common/management/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/common/templates/document_email.html b/common/templates/document_email.html index 547defd..6be5a45 100644 --- a/common/templates/document_email.html +++ b/common/templates/document_email.html @@ -1,4 +1,10 @@ -Welcome {{ username }}! +Заявка на распечатку от {{ username }}! -Your username is {{ username }} and your password is {{ files }}. +Контактные данные: +Телефон : {{ phone }} + +