0.8.7
processing send messages by mail
This commit is contained in:
@@ -28,6 +28,6 @@ urlpatterns = [
|
|||||||
path('change_profile_confirm/', change_profile_confirm_ajax, name='change_profile_confirm_ajax'),
|
path('change_profile_confirm/', change_profile_confirm_ajax, name='change_profile_confirm_ajax'),
|
||||||
path('change_avatar_confirm/', change_avatar_confirm_ajax, name='change_avatar_confirm_ajax'),
|
path('change_avatar_confirm/', change_avatar_confirm_ajax, name='change_avatar_confirm_ajax'),
|
||||||
|
|
||||||
path('request_offer/', request_offer_ajax, name='request_offer_ajax')
|
path('send_message/', send_message_ajax, name='send_message_ajax')
|
||||||
|
|
||||||
]
|
]
|
||||||
@@ -31,53 +31,90 @@ import base64
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def request_offer_ajax(request):
|
def send_message_ajax(request):
|
||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
data = request.POST
|
try:
|
||||||
if not data and request.body:
|
|
||||||
data = request.body
|
|
||||||
|
|
||||||
from GeneralApp.funcs_options import get_options_by_opt_types, get_mail_send_options
|
data = request.POST
|
||||||
sets = get_options_by_opt_types(['domain', 'project_name'], only_vals=True)
|
if not data and request.body:
|
||||||
|
data = request.body
|
||||||
|
|
||||||
request_type = None
|
from GeneralApp.funcs_options import get_options_by_opt_types, get_mail_send_options
|
||||||
subject = _('Получен запрос')
|
sets = get_options_by_opt_types(['domain', 'project_name'], only_vals=True)
|
||||||
if 'form_name' in data:
|
|
||||||
if data['form_name'] == 'msg_from_advertisement':
|
request_type = None
|
||||||
subject = _('Получен запрос на рекламу')
|
subject = _('Получен запрос')
|
||||||
request_type = _('запрос на рекламу')
|
if 'form_name' in data:
|
||||||
|
if data['form_name'] == 'msg_from_advertisement':
|
||||||
|
subject = _('Получен запрос на рекламу')
|
||||||
|
request_type = _('запрос на рекламу')
|
||||||
|
if data['form_name'] == 'msg_from_partners':
|
||||||
|
subject = _('Получен запрос на подключение к партнерской сети')
|
||||||
|
request_type = _('запрос на партнерство')
|
||||||
|
if data['form_name'] == 'msg_from_customer_service':
|
||||||
|
subject = _('Получен запрос в службу техподдержки')
|
||||||
|
request_type = _('запрос в техподдержку')
|
||||||
|
if data['form_name'] == 'msg_from_contacts':
|
||||||
|
subject = _('Получен запрос со страницы контактов')
|
||||||
|
request_type = _('запрос со страницы контактов')
|
||||||
|
if data['form_name'] == 'msg_from_about_service':
|
||||||
|
subject = _('Получен запрос со страницы О сервисе')
|
||||||
|
request_type = _('запрос со страницы о сервисе')
|
||||||
|
if data['form_name'] == 'footer':
|
||||||
|
subject = _('Получен запрос на рассылку')
|
||||||
|
request_type = _('запрос на рассылку')
|
||||||
|
|
||||||
if request_type:
|
|
||||||
request_type_str = f'<b>{_("Тип запроса")}:</b> {request_type}<br>'
|
|
||||||
else:
|
|
||||||
request_type_str = ''
|
request_type_str = ''
|
||||||
|
name_str = ''
|
||||||
|
phone_str = ''
|
||||||
|
email_str = ''
|
||||||
|
msg_str = ''
|
||||||
|
if request_type:
|
||||||
|
request_type_str = f'<b>{_("Тип запроса")}:</b> {request_type}<br>'
|
||||||
|
if 'name' in data:
|
||||||
|
name_str = f'<b>{_("Имя")}:</b> {data["name"]}<br>'
|
||||||
|
if 'phone' in data:
|
||||||
|
phone_str = f'<b>{_("Телефон")}:</b> {data["phone"]}<br>'
|
||||||
|
if 'email' in data:
|
||||||
|
email_str = f'<b>{_("email")}:</b> {data["email"]}<br>'
|
||||||
|
if 'text_msg' in data:
|
||||||
|
msg_str = (f'<b>{_("Сообщение")}:</b><br>'
|
||||||
|
f'<div style="margin-left: 40px; line-height: 20px;">{data["text_msg"]}</div><br>')
|
||||||
|
|
||||||
Dict = {
|
|
||||||
'logo': f'{request.scheme}://{sets["domain"]}/static/img/svg/LogoMobile.svg',
|
|
||||||
'project_name': sets['project_name'],
|
|
||||||
'message_title': subject,
|
|
||||||
'message_text': f'<p><b>{_("ДАННЫЕ ЗАПРОСА")}</b></p>'
|
|
||||||
f'<p style="padding-left: 20px; line-height: 30px;">'
|
|
||||||
f'{request_type_str}'
|
|
||||||
f'<b>{_("Имя")}:</b> {data["name"]}<br>'
|
|
||||||
f'<b>{_("Телефон")}:</b> {data["phone"]}'
|
|
||||||
f'</p>'
|
|
||||||
}
|
|
||||||
|
|
||||||
html = render_to_string('mail/m_request_offer.html', Dict, request)
|
Dict = {
|
||||||
from BaseModels.mailSender import admin_send_mail_by_SMTPlib
|
'logo': f'{request.scheme}://{sets["domain"]}/static/img/svg/LogoMobile.svg',
|
||||||
mail_sets = get_mail_send_options()
|
'project_name': sets['project_name'],
|
||||||
to = [mail_sets['sender_email'], 'web@syncsystems.net']
|
'message_title': subject,
|
||||||
res = admin_send_mail_by_SMTPlib(
|
'message_text': f'<p><b>{_("ДАННЫЕ ЗАПРОСА")}</b></p>'
|
||||||
mail_sets,
|
f'<p style="padding-left: 20px; line-height: 30px;">'
|
||||||
subject=subject,
|
f'{request_type_str}'
|
||||||
from_email=mail_sets['sender_email'], to=to,
|
f'{name_str}'
|
||||||
html_content=html
|
f'{phone_str}'
|
||||||
)
|
f'{email_str}'
|
||||||
|
f'{msg_str}'
|
||||||
|
f'</p>'
|
||||||
|
}
|
||||||
|
|
||||||
return JsonResponse({'status': 'sended'})
|
html = render_to_string('mail/m_request_offer.html', Dict, request)
|
||||||
|
from BaseModels.mailSender import admin_send_mail_by_SMTPlib
|
||||||
|
mail_sets = get_mail_send_options()
|
||||||
|
to = [mail_sets['sender_email'], 'web@syncsystems.net']
|
||||||
|
res = admin_send_mail_by_SMTPlib(
|
||||||
|
mail_sets,
|
||||||
|
subject=subject,
|
||||||
|
from_email=mail_sets['sender_email'], to=to,
|
||||||
|
html_content=html
|
||||||
|
)
|
||||||
|
|
||||||
|
return JsonResponse({'status': 'sended'})
|
||||||
|
except Exception as e:
|
||||||
|
return JsonResponse({
|
||||||
|
'status': 'error',
|
||||||
|
'error': str(e)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
@login_required(login_url='/profile/login/')
|
@login_required(login_url='/profile/login/')
|
||||||
|
|||||||
@@ -1,15 +1,23 @@
|
|||||||
|
|
||||||
<div style="font-family:Calibri,Candara,Segoe,'Segoe UI',Optima,Arial,sans-serif; padding:10px; background-color: #F8F8F8;">
|
<div style="font-family:Calibri,Candara,Segoe,'Segoe UI',Optima,Arial,sans-serif;
|
||||||
<div style="line-height:1.0em;width: 660px">
|
padding:10px; background-color: #F8F8F8;"
|
||||||
|
>
|
||||||
|
<div style="line-height:1.0em; width: 660px">
|
||||||
<div style="padding:5px; text-align: center;">
|
<div style="padding:5px; text-align: center;">
|
||||||
<img src="{{ logo }}" alt="{{ project_name }}" style="margin:0;padding:0;">
|
<img src="{{ logo }}" alt="{{ project_name }}" style="margin:0;padding:0;">
|
||||||
</div>
|
</div>
|
||||||
<p style="font-weight:700;font-size:25px;text-align:center;padding:0;line-height:1em; text-transform: uppercase; color: #ff613a;">
|
<p style="font-weight:700; font-size:25px; text-align:center;
|
||||||
|
padding:0; line-height:1em; text-transform: uppercase; color: #ff613a;
|
||||||
|
margin: auto; max-width: 90%;
|
||||||
|
">
|
||||||
{{ message_title|safe }}
|
{{ message_title|safe }}
|
||||||
</p>
|
</p>
|
||||||
<div style="line-height:1.0em;font-size:18px;margin-top: 5px; margin-left: 30px; box-shadow: -1px 4px 10px 0 rgba(198, 199, 203, 0.20), 0 -1px 10px 0 rgba(198, 199, 203, 0.20); padding: 30px; border-radius: 10px; background-color: #FFF;">
|
<div style="line-height:1.0em; font-size:18px; margin: 5px 30px;
|
||||||
|
box-shadow: -1px 4px 10px 0 rgba(198, 199, 203, 0.20), 0 -1px 10px 0 rgba(198, 199, 203, 0.20);
|
||||||
|
padding: 30px; border-radius: 10px; background-color: #FFF;"
|
||||||
|
>
|
||||||
{# <p style="line-height:1.0em;font-size:18px;margin-top: 5px; margin-left: 80px">#}
|
{# <p style="line-height:1.0em;font-size:18px;margin-top: 5px; margin-left: 80px">#}
|
||||||
{{ message_text|safe }}
|
{{ message_text|safe|linebreaksbr }}
|
||||||
{# </p>#}
|
{# </p>#}
|
||||||
</div>
|
</div>
|
||||||
{% for button in message_buttons %}
|
{% for button in message_buttons %}
|
||||||
|
|||||||
Reference in New Issue
Block a user