# -*- coding: utf-8 -*- import json from django.views.generic import TemplateView from django.core.mail import EmailMessage from django.http import HttpResponse from django.conf import settings class SeminarLendingView(TemplateView): template_name = 'client/simple_pages/expo_seminar.html' def send_to_organiser(request): mail_send = 'expomap@mail.ru' fname = request.POST.get('name') lname = request.POST.get('surname') email = request.POST.get('email', '') company = request.POST.get('company', '') office = request.POST.get('office', '') phone = request.POST.get('phone', '') title = request.POST.get('type', '') text = u"""Имя: %s; Фамилия:%s; Email: %s; Телефон: %s; компния:%s; должность: %s"""%(fname, lname, email, phone, company, office) msg = EmailMessage(title, text, settings.DEFAULT_FROM_EMAIL, [mail_send]) msg.content_subtype = "html" msg.send() redirect_to = '/service/thanks/' if title.endswith(u'семинар'): message = u"""Мы получили Ваш запрос и очень рады, что Вам интересно участие в семинаре Expomap. Если места еще есть, мы пришлем Вам приглашение на указанную Вами электронную почту. Увидимся на welcome-coffee ☺""" else: message = u"""Благодарим за интерес к нашему семинару! За несколько дней до мероприятия мы пришлем Вам ссылку для подключения к онлайн-трансляции!""" return HttpResponse(json.dumps({'success':True, 'redirect_to': redirect_to, 'message': message}), content_type='application/json')