Replace numbers with question marks in signal name

This commit is contained in:
Mark Veidemanis 2022-12-07 07:20:05 +00:00
parent 575b6a240f
commit aa8ee887d3
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 4 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import re import re
from string import digits
import orjson import orjson
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
@ -98,6 +99,9 @@ class HookAPI(APIView):
# 'Stoch Exit' # 'Stoch Exit'
signal_name = " ".join(hook_resp.message.split(":")[0].split(" ")[2:]) signal_name = " ".join(hook_resp.message.split(":")[0].split(" ")[2:])
for x in signal_name:
if x in digits:
signal_name = signal_name.replace(x, "?")
try: try:
signal = Signal.objects.get(signal=signal_name) signal = Signal.objects.get(signal=signal_name)
except Signal.DoesNotExist: except Signal.DoesNotExist: