0.10.2 mail alert by new routes

This commit is contained in:
SDE
2024-01-11 19:03:25 +03:00
parent ad909b98bf
commit 6c1011e59e
13 changed files with 267 additions and 22 deletions

View File

@@ -10,8 +10,15 @@ def get_options_by_opt_types(opt_types, only_vals=False):
opts = Option.objects.filter(**kwargs)
if opts and only_vals:
opts = opts.values('opt_type', 'value')
opts = {item['opt_type']: item['value'] for item in opts}
res = {}
opts = opts.values('opt_type', 'value', 'prefix')
for item in opts:
if item['prefix']:
res.update({item['opt_type']: f"{item['prefix']}{item['value']}"})
else:
res.update({item['opt_type']: f"{item['value']}"})
return res
return opts
def get_first_option_value_by_opt_type(opt_type):

View File

@@ -19,18 +19,21 @@ def test_code(request):
from RoutesApp.models import Route
from ReferenceDataApp.models import Airport, City
try:
# body = request.body
# data = json.loads(body)
# if 'head' not in data or 'body' not in data or 'id' not in data:
# return JsonResponse(status=400, data={"message": "Invalid data format"})
# user_id = data['id']
user = request.user
payload = {'head': '123', 'body': 'qwerty'}
send_user_notification(user=user, payload=payload, ttl=1000)
return JsonResponse(status=200, data={"message": "Web push successful"})
except TypeError:
return JsonResponse(status=500, data={"message": "An error occurred"})
from RoutesApp.search_matches import search_matches
search_matches()
# try:
# # body = request.body
# # data = json.loads(body)
# # if 'head' not in data or 'body' not in data or 'id' not in data:
# # return JsonResponse(status=400, data={"message": "Invalid data format"})
# # user_id = data['id']
# user = request.user
# payload = {'head': '123', 'body': 'qwerty'}
# send_user_notification(user=user, payload=payload, ttl=1000)
# return JsonResponse(status=200, data={"message": "Web push successful"})
# except TypeError:
# return JsonResponse(status=500, data={"message": "An error occurred"})
# routes = Route.objects.all()
#
@@ -49,7 +52,7 @@ def test_code(request):
# if required_save:
# route.save()
# return HttpResponse('finished')
return HttpResponse('finished')