You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
1.3 KiB

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, PrintDocuments
class HomeTemplateView(View):
template_name = 'home.html'
def get(self, request, *args, **kwargs):
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):
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})