0.11.20 push w link
This commit is contained in:
@@ -150,6 +150,16 @@ def get_routes_Dict(user=None, data=None):
|
||||
res_Dict = {}
|
||||
|
||||
if data:
|
||||
|
||||
type_transport = None
|
||||
if 'type_transport' in data and data['type_transport']:
|
||||
items_list = data['type_transport'].split(',')
|
||||
kwargs.update({f'type_transport__in': items_list})
|
||||
|
||||
if len(items_list) == 1:
|
||||
type_transport = items_list[0]
|
||||
|
||||
|
||||
for key, val in data.items():
|
||||
if val:
|
||||
if key == 'weight':
|
||||
@@ -162,9 +172,9 @@ def get_routes_Dict(user=None, data=None):
|
||||
else:
|
||||
kwargs.update({f'{key}__lte': int(weight_list[0])})
|
||||
|
||||
if key == 'type_transport':
|
||||
items_list = val.split(',')
|
||||
kwargs.update({f'{key}__in': items_list})
|
||||
# if key == 'type_transport':
|
||||
# items_list = val.split(',')
|
||||
# kwargs.update({f'{key}__in': items_list})
|
||||
|
||||
|
||||
if key in (
|
||||
@@ -184,19 +194,18 @@ def get_routes_Dict(user=None, data=None):
|
||||
kwargs.update({key: val})
|
||||
|
||||
if key == 'from_address_point':
|
||||
kwargs.update({f'from_city__id': val})
|
||||
city = get_city_by_type_transport_and_address_point(type_transport, val)
|
||||
kwargs.update({f'from_city': city})
|
||||
|
||||
res_Dict.update({
|
||||
'from_address_point_txt': get_country_n_city_str_by_type_transport_and_address_point(
|
||||
'road', val
|
||||
)
|
||||
'from_address_point_txt': city.get_country_n_city_str()
|
||||
})
|
||||
|
||||
if key == 'to_address_point':
|
||||
kwargs.update({f'to_city__id': val})
|
||||
city = get_city_by_type_transport_and_address_point(type_transport, val)
|
||||
kwargs.update({f'to_city': city})
|
||||
res_Dict.update({
|
||||
'to_address_point_txt': get_country_n_city_str_by_type_transport_and_address_point(
|
||||
'road', val
|
||||
)
|
||||
'to_address_point_txt': city.get_country_n_city_str()
|
||||
})
|
||||
|
||||
if key == 'from_el':
|
||||
|
||||
@@ -5,22 +5,49 @@ from django.template.loader import render_to_string
|
||||
from GeneralApp.funcs_options import get_options_by_opt_types, get_mail_send_options
|
||||
from BaseModels.mailSender import admin_send_mail_by_SMTPlib, techSendMail
|
||||
|
||||
def send_mail_found_matches_routes(route, kwargs, search_owner_type):
|
||||
|
||||
|
||||
def get_Dict_for_send_msgs(kwargs, search_owner_type):
|
||||
|
||||
Dict = {
|
||||
'route': route,
|
||||
'search_owner_type': search_owner_type
|
||||
}
|
||||
sets = get_options_by_opt_types(['domain', 'project_name'], only_vals=True)
|
||||
Dict.update(sets)
|
||||
Dict.update({'logo': f'{sets["domain"]}/static/img/svg/LogoMobile.svg',})
|
||||
|
||||
|
||||
Dict.update({'logo': f'{sets["domain"]}/static/img/svg/LogoMobile.svg', })
|
||||
|
||||
find_routes_page_url = f'{sets["domain"]}/routes/route_search_results/?'
|
||||
kwargs_list = [f'{key}={value}' for key, value in kwargs.items()]
|
||||
kwargs_list.append(f'owner_type={search_owner_type}')
|
||||
find_routes_page_url += f'{"&".join(kwargs_list)}'
|
||||
|
||||
Dict.update({'find_routes_page_url': find_routes_page_url})
|
||||
|
||||
return Dict
|
||||
|
||||
|
||||
|
||||
def send_push_message_for_found_matches_routes(route, data_Dict):
|
||||
if not route.owner.is_authenticated:
|
||||
return None
|
||||
|
||||
from PushMessages.views import send_push
|
||||
title = 'Мы нашли исполнителя по Вашему объявлению!'
|
||||
text = 'Для просмотра результата нажмите на кнопку ниже'
|
||||
send_push(route.owner, title, text, url=data_Dict['find_routes_page_url'], button_name=_('Перейти к найденному'))
|
||||
return None
|
||||
|
||||
|
||||
|
||||
def send_mail_found_matches_routes(route, data_Dict):
|
||||
|
||||
Dict = {
|
||||
'route': route,
|
||||
}
|
||||
Dict.update(data_Dict)
|
||||
|
||||
html = render_to_string('mail/m_found_matched_routes.html', Dict)
|
||||
|
||||
|
||||
@@ -87,7 +114,11 @@ def search_matches(for_routes=None):
|
||||
)
|
||||
|
||||
if found_routes:
|
||||
msg = send_mail_found_matches_routes(route, params, found_routes[0].owner_type)
|
||||
data_Dict = get_Dict_for_send_msgs(params, found_routes[0].owner_type)
|
||||
msg = send_push_message_for_found_matches_routes(route, data_Dict)
|
||||
if msg:
|
||||
log += msg
|
||||
msg = send_mail_found_matches_routes(route, data_Dict)
|
||||
if msg:
|
||||
log += msg
|
||||
|
||||
@@ -96,6 +127,6 @@ def search_matches(for_routes=None):
|
||||
log += msg
|
||||
|
||||
mail_sets = get_mail_send_options()
|
||||
techSendMail(mail_sets, log, msg)
|
||||
techSendMail(mail_sets, log, title='search_matches fail')
|
||||
|
||||
return log
|
||||
|
||||
Reference in New Issue
Block a user