diff --git a/AuthApp/js_urls.py b/AuthApp/js_urls.py
index 795d2f9..9cfcbcf 100644
--- a/AuthApp/js_urls.py
+++ b/AuthApp/js_urls.py
@@ -27,4 +27,7 @@ urlpatterns = [
path('change_profile/', change_profile_ajax, name='change_profile_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('request_offer/', request_offer_ajax, name='request_offer_ajax')
+
]
\ No newline at end of file
diff --git a/AuthApp/js_views.py b/AuthApp/js_views.py
index 5dffd9d..97e83f9 100644
--- a/AuthApp/js_views.py
+++ b/AuthApp/js_views.py
@@ -29,6 +29,44 @@ import base64
# html = render_to_string('blocks/profile/b_subscribe.html', Dict, request=request)
# return JsonResponse({'html': html}, status=200)
+
+
+def request_offer_ajax(request):
+ if request.method != 'POST':
+ raise Http404
+
+ data = request.POST
+ if not data and request.body:
+ data = request.body
+
+ from GeneralApp.funcs_options import get_options_by_opt_types, get_mail_send_options
+ sets = get_options_by_opt_types(['domain', 'project_name'], only_vals=True)
+
+ subject = 'Получен запрос на рекламу'
+
+ Dict = {
+ 'logo': f'{sets["domain"]}/static/img/svg/LogoMobile.svg',
+ 'project_name': sets['project_name'],
+ 'message_title': subject,
+ 'message_text': f'ДАННЫЕ ЗАПРОСА
'
+ f'Имя: {data["name"]}
'
+ f'Телефон: {data["phone"]}
'
+ }
+
+ 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('OK')
+
+
@login_required(login_url='/profile/login/')
def chats_ajax(request):
if request.method != 'POST':
diff --git a/BaseModels/mailSender.py b/BaseModels/mailSender.py
index 1417d09..8c2cfd3 100644
--- a/BaseModels/mailSender.py
+++ b/BaseModels/mailSender.py
@@ -91,7 +91,7 @@ def admin_send_mail_by_SMTPlib(sets, subject, from_email, to, html_content, atta
smtp_port = sets['mail_server_smtp_port']
smtp_password = sets['sender_mail_password']
smtp_login = sets['sender_mail_login']
- res = send_mail_by_SMTPlib(subject, from_email, to, html_content, smtp_server, smtp_port, smtp_login,
+ res = send_mail_by_SMTPlib(sets, subject, from_email, to, html_content, smtp_server, smtp_port, smtp_login,
smtp_password, attachments)
@@ -106,14 +106,14 @@ def admin_send_mail_by_SMTPlib(sets, subject, from_email, to, html_content, atta
def send_mail_by_SMTPlib(sets, subject, from_email, to_init, html_content, smtp_server, smtp_port, smtp_login, smtp_password,
attachments=None):
to = to_init
- if not settings.prod_server:
- to = 'web@syncsystems.net'
- else:
- to = to_init
- try:
- from settings_local import DEBUG
- except:
- print('get settings_local fail')
+ # if not settings.prod_server:
+ # to = 'web@syncsystems.net'
+ # else:
+ # to = to_init
+ # try:
+ # from settings_local import DEBUG
+ # except:
+ # print('get settings_local fail')
res = None
mail_lib = None
@@ -153,8 +153,8 @@ def send_mail_by_SMTPlib(sets, subject, from_email, to_init, html_content, smtp_
else:
to_str = to[0]
else:
- if to == sets['sender_email']:
- return None
+ # if to == sets['sender_email']:
+ # return None
to_str = to
to = []
to.append(to_str)
diff --git a/GeneralApp/funcs_options.py b/GeneralApp/funcs_options.py
index fb4c1ab..bf34d9d 100644
--- a/GeneralApp/funcs_options.py
+++ b/GeneralApp/funcs_options.py
@@ -10,8 +10,8 @@ def get_options_by_opt_types(opt_types, only_vals=False):
opts = Option.objects.filter(**kwargs)
if opts and only_vals:
- opts = opts.values('name', 'value')
- opts = {item['name']: item['value'] for item in opts}
+ opts = opts.values('opt_type', 'value')
+ opts = {item['opt_type']: item['value'] for item in opts}
return opts
def get_first_option_value_by_opt_type(opt_type):
diff --git a/templates/mail/m_request_offer.html b/templates/mail/m_request_offer.html
new file mode 100644
index 0000000..c039929
--- /dev/null
+++ b/templates/mail/m_request_offer.html
@@ -0,0 +1,65 @@
+
+
+ {{ message_title|safe }} +
+#} + {{ message_text|safe }} +{#
#} +