1.1.1 autosubscribe to null price subscribe
This commit is contained in:
@@ -16,13 +16,16 @@ from django.urls import reverse
|
||||
from .forms import *
|
||||
from .funcs import *
|
||||
from GeneralApp.funcs import get_and_set_lang
|
||||
|
||||
from SubscribesApp.funcs import check_option_in_cur_user_subscribe
|
||||
|
||||
|
||||
def del_route_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
if not check_option_in_cur_user_subscribe(request.user, 'размещение заявок'):
|
||||
return JsonResponse({'html': 'нет доступа'}, status=403)
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
try:
|
||||
@@ -58,6 +61,9 @@ def edit_route_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
if not check_option_in_cur_user_subscribe(request.user, 'размещение заявок'):
|
||||
return JsonResponse({'html': 'нет доступа'}, status=403)
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
data = json.loads(request.body)
|
||||
@@ -108,6 +114,8 @@ def edit_route_ajax(request):
|
||||
def new_route_view_ajax(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
if not check_option_in_cur_user_subscribe(request.user, 'размещение заявок'):
|
||||
return JsonResponse({'html': 'нет доступа'}, status=403)
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
@@ -222,6 +230,9 @@ def create_or_change_route_ajax(request, route_id=None):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
if not check_option_in_cur_user_subscribe(request.user, 'размещение заявок'):
|
||||
return JsonResponse({'html': 'нет доступа'}, status=403)
|
||||
|
||||
lang = get_and_set_lang(request)
|
||||
|
||||
Dict = {}
|
||||
|
||||
@@ -4,7 +4,7 @@ from django.utils.translation import gettext as _
|
||||
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
|
||||
|
||||
from SubscribesApp.funcs import check_option_in_cur_user_subscribe
|
||||
|
||||
|
||||
def get_Dict_for_send_msgs(kwargs, search_owner_type):
|
||||
@@ -36,6 +36,9 @@ def send_push_message_for_found_matches_routes(route, data_Dict):
|
||||
if not route.owner.is_authenticated:
|
||||
return None
|
||||
|
||||
if not check_option_in_cur_user_subscribe(route.owner, 'push уведомления'):
|
||||
return False
|
||||
|
||||
from PushMessages.views import send_push
|
||||
title = 'Мы нашли исполнителя по Вашему объявлению!'
|
||||
text = 'Для просмотра результата нажмите на кнопку ниже'
|
||||
@@ -126,24 +129,38 @@ def search_matches(for_routes=None):
|
||||
if found_routes:
|
||||
msg = f'found routes for send messages = {found_routes.count()}'
|
||||
|
||||
data_Dict = None
|
||||
try:
|
||||
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
|
||||
except Exception as e:
|
||||
msg = f'<br>\n! search_matches Error send_push_message_for_found_matches_routes = {str(e)}'
|
||||
msg = f'<br>\n! search_matches Error get_Dict_for_send_msgs = {str(e)}'
|
||||
print(msg)
|
||||
log += msg
|
||||
|
||||
try:
|
||||
msg = send_mail_found_matches_routes(route, data_Dict)
|
||||
if msg:
|
||||
if data_Dict and check_option_in_cur_user_subscribe(
|
||||
route.owner, 'push уведомления'
|
||||
):
|
||||
try:
|
||||
msg = send_push_message_for_found_matches_routes(route, data_Dict)
|
||||
if msg:
|
||||
log += msg
|
||||
except Exception as e:
|
||||
msg = f'<br>\n! search_matches Error send_push_message_for_found_matches_routes = {str(e)}'
|
||||
print(msg)
|
||||
log += msg
|
||||
|
||||
if data_Dict and check_option_in_cur_user_subscribe(
|
||||
route.owner,
|
||||
'уведомление на e-mail о появлении перевозчика по заданным критериям'
|
||||
):
|
||||
try:
|
||||
msg = send_mail_found_matches_routes(route, data_Dict)
|
||||
if msg:
|
||||
log += msg
|
||||
except Exception as e:
|
||||
msg = f'<br>\n! search_matches Error send_mail_found_matches_routes = {str(e)}'
|
||||
print(msg)
|
||||
log += msg
|
||||
except Exception as e:
|
||||
msg = f'<br>\n! search_matches Error send_mail_found_matches_routes = {str(e)}'
|
||||
print(msg)
|
||||
log += msg
|
||||
|
||||
except Exception as e:
|
||||
msg = f'<br>\n! search_matches Error = {str(e)}'
|
||||
|
||||
Reference in New Issue
Block a user