This commit is contained in:
filimonov
2024-05-21 18:03:49 +07:00
parent 4f85cd81de
commit e03a34c47a
28 changed files with 1344 additions and 322 deletions

View File

@@ -3,12 +3,14 @@ from flask import Flask, jsonify, render_template, url_for, request, redirect
import json
import datetime
from pymongo import MongoClient
import requests
CONNECTION_STRING = "mongodb://mongodb:Cc03Wz5XX3iI3uY3@mongo"
db_connection = MongoClient(CONNECTION_STRING)
db_base = db_connection["phone-dev"]
coll = db_base["phone"]
bl = db_base["blacklist"]
rep = False
# coll_call = db_base["phone"]
@@ -27,8 +29,6 @@ def root():
return redirect("/notanswer")
IgnoreList = ['83919865589', '83912051046', '83912051045', '84950213944', '84951252791', '83919865589',
'84951183750', '89919237009', '89919241441', '89919863883', '89919505445', '89919398228', '89919500798']
ImportantNumber = ['839122051045']
@@ -58,18 +58,83 @@ def rcallFalse():
'time', -1).limit(Findlimit)
return render_template("falserecall.html", call=call) if rep == False else render_template("repair.html")
@app.route("/blacklist")
def blacklist():
call = bl.find().sort('_id')
return render_template("blacklist.html", call=call) if rep == False else render_template("repair.html")
@app.route("/test")
def ttt():
res = []
for p in request.environ:
try:
res.append(p + " = " + request.environ[p])
except:
pass
# #"<br>".join(request.environ)
return str(res)
@app.route("/work/<uuid>")
def work_uuid(uuid):
coll.update_one({"uuid": uuid}, {"$set": {"status": "INWORK"}})
call = coll.find({"uuid": uuid})
return render_template("work.html", call=call) if rep == False else render_template("repair.html")
# API
@app.route("/api/v1/call/set/", methods=["POST"])
def call_put():
print(request.form)
# print(request.form)
if request.form["act"] == "delete":
coll.update_one({"uuid": request.form["uuid"]}, {
"$set": {"status": "DELETED"}})
coll.update_many({"uuid": request.form["uuid"], "status": "RECALL_FALSE"}, {
"$set": {"status": "DELETED"}})
return redirect("/falserecall")
@app.route("/api/v1/work/", methods=["POST"])
def work():
dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
coll.update_one({"uuid": request.form["uuid"]}, {"$set": {"status": "RECALL_" + str(request.form["recall"]).upper(), "dt": dt}})
return redirect("/")
@app.route("/api/v1/blacklist/add/<number>", methods=["POST"])
def blacklist_put(number):
insdict = {"_id": number, "desc": datetime.datetime.now()}
bl.update_one({"_id": number}, {"$set": insdict}, True)
coll.update_many({"client": number, "status": {
"$in": ["RECALL_TRUE", "RECALL_FALSE", "NOT_ANSWERED"]}}, {"$set": {"status": "IGNORED"}})
return redirect("/blacklist")
@app.route("/api/v1/blacklist/delete/<number>", methods=["POST"])
def blacklist_delete(number):
bl.delete_many({"_id": number})
return redirect("/blacklist")
@app.route("/api/v1/blacklist/get/<number>")
def blacklist_get(number):
try:
return [i for i in bl.find({"_id": number})][0]
except:
return {}
@app.route("/api/v1/sync")
def sync():
j = []
for x in coll.find({"status": "NOT_ANSWERED"}):
t_req = "https://callinfo.services.mobilon.ru/api/call/info/1e86a98e026578eb5f6bf8c092c0c4a2/" + \
x["uuid"]
res: dict = json.loads(requests.get(t_req).content)
j.append(res)
coll.update_one({"uuid": x["uuid"]}, {"$set": res})
return j
if __name__ == "__main__":
app.debug = True
app.run(host="0.0.0.0", port=6001)

View File

@@ -8,3 +8,4 @@ MarkupSafe==2.1.2
pymongo==4.3.3
Werkzeug==2.2.3
zipp==3.15.0
requests==2.28.2

View File

@@ -1,43 +0,0 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='main.css') }}">
<title>Lost Calls</title>
</head>
<header>
<a href="/web/call/status/0">Входящий вызов принят</a>
<a href="/web/call/status/1">Входящий вызов не принят</a>
<a href="/web/call/status/2">Перезвонили</a>
</header>
<table>
<tr>
<td>Номер клиента</td>
<!-- <td>Номер оператора</td> -->
<td>Дата время</td>
<td>Ссылка на запись</td>
</tr>
<body>
{% for entry in call %}
<tr>
<!-- <td>{{ entry.client }}</td> -->
<td><a href="tel:{{ entry.client }}">{{ "%s %s %s %s"|format(entry.client[0:1], entry.client[1:4], entry.client[4:7], entry.client[7:11]) }}</a></td>
<!-- <td>{{ entry.Operator }}</td> -->
<td>{{ entry.time }}</td>
<td>
{% if entry.recordUrl|length > 1 %}
<audio src="{{ entry.recordUrl }}" type="audio/mp3" preload="none" controls>Запись</audio>
{% endif %}
</td>
</tr>
{% endfor %}
</body>
</table>
</html>

View File

@@ -1,79 +0,0 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='main.css') }}">
<title>Lost Calls</title>
</head>
<header>
<a href="/web/call/status/0">Входящий вызов принят</a>
<a href="/web/call/status/1">Входящий вызов не принят</a>
<<<<<<< HEAD
<a href="/web/call/status/2">Перезвонили успешно</a>
<a href="/web/call/status/4">Перезвонили безуспешно</a>
<p>
<form name="search" action="/web/call/find/" method="get" class="search">
<label class="search_label">Поиск</label>
<input class="search_text" type="text" name="client">
<input class="search_btn" type="submit" title="Найти">
</form>
</p>
=======
<a href="/web/call/status/2">Перезвонили</a>
>>>>>>> parent of c52dc73 (Добавил поиск)
</header>
<table>
<tr>
<td>Номер клиента</td>
<!-- <td>Номер оператора</td> -->
<td>Дата время</td>
<td>Ссылка на запись</td>
</tr>
<body>
{% for entry in call %}
<tr>
<!-- <td>{{ entry.client }}</td> -->
{% if entry.important == True %}
<td>
<font color="#C30000">{{ "%s %s %s %s"|format(entry.client[0:1], entry.client[1:4], entry.client[4:7],
entry.client[7:11]) }}</font>
</td>
{% else %}
<td>{{ "%s %s %s %s"|format(entry.client[0:1], entry.client[1:4], entry.client[4:7], entry.client[7:11]) }}
</td>
{% endif %}
<!-- <td>{{ entry.Operator }}</td> -->
<td>{{ entry.time }}</td>
<td>
<<<<<<< HEAD
{% if entry.status == 0 %}
Вызов принят
{% elif entry.status == 1 %}
Вызов не принят
{% elif entry.status == 2 %}
Перезвонили
{% elif entry.status == 2 %}
Абонент не взял трубку
{% elif entry.status == 9 %}
Абонент заблокирован
{% endif %}
</td>
<td>
=======
>>>>>>> parent of c52dc73 (Добавил поиск)
{% if entry.recordUrl|length > 1 %}
<audio src="{{ entry.recordUrl }}" type="audio/mp3" preload="none" controls>Запись</audio>
{% endif %}
</td>
</tr>
{% endfor %}
</body>
</table>
</html>

View File

@@ -48,7 +48,7 @@
a {
font-size: large;
font-family: Verdana, Geneva, Tahoma, sans-serif;
color: chocolate;
color: #7A1E99;
padding-right: 50px;
}
@@ -60,14 +60,20 @@
form {
height: 40px;
}
.inl {display: inline;}
.inl-active {
display: inline;
background-color: #FFD300;
}
</style>
<body>
<div>
<a href="/answer">Входящий вызов принят</a>
<a href="/notanswer">Входящий вызов не принят</a>
<a href="/truerecall">Перезвонили успешно</a>
<a href="/falserecall">Перезвонили безуспешно</a>
<div class="inl-active"><a href="/answer">Входящий вызов принят</a></div>
<div class="inl"><a href="/notanswer">Входящий вызов не принят</a></div>
<div class="inl"><a href="/truerecall">Перезвонили успешно</a></div>
<div class="inl"><a href="/falserecall">Перезвонили безуспешно</a></div>
</div>
<!-- <div>
<form name="search" action="/web/call/find/" method="get" class="search">

View File

@@ -0,0 +1,97 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='main.css') }}"> -->
<title>Черный список</title>
</head>
<style type="text/css" media="screen">
table {
width: 100%;
margin-bottom: 20px;
border: 5px solid #fff;
border-top: 5px solid #fff;
border-bottom: 3px solid #fff;
border-collapse: collapse;
outline: 3px solid #ffd300;
font-size: 15px;
background: #fff !important;
font-family: Verdana, Geneva, Tahoma, sans-serif;
}
table th {
font-weight: bold;
padding: 7px;
background: #ffd300;
border: none;
text-align: left;
font-size: 15px;
border-top: 3px solid #fff;
border-bottom: 3px solid #ffd300;
}
table td {
padding: 7px;
border: none;
border-top: 3px solid #fff;
border-bottom: 3px solid #fff;
font-size: 15px;
}
table tbody tr:nth-child(even) {
background: #f8f8f8 !important;
}
a {
font-size: large;
font-family: Verdana, Geneva, Tahoma, sans-serif;
color: chocolate;
padding-right: 50px;
}
header {
height: 50px;
vertical-align: middle;
}
form {
height: 40px;
}
</style>
<body>
<div>
<a href="/answer">Входящий вызов принят</a>
<a href="/notanswer">Входящий вызов не принят</a>
<a href="/truerecall">Перезвонили успешно</a>
<a href="/falserecall">Перезвонили безуспешно</a>
</div>
<table>
<thead>
<tr>
<th>Номер клиента</th>
<th>Комментарий</th>
<th>Действие</th>
</tr>
</thead>
<tbody>
{% for c in call %}
<tr>
<td>{{ c._id }}</td>
<td>{{ c.desc }}</td>
<td>
<form method="post" action="/api/v1/blacklist/delete/{{ c._id }}">
<input type="submit" value="Удалить" />
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>

View File

@@ -48,7 +48,7 @@
a {
font-size: large;
font-family: Verdana, Geneva, Tahoma, sans-serif;
color: chocolate;
color: #7A1E99;
padding-right: 50px;
}
@@ -60,31 +60,26 @@
form {
height: 40px;
}
.inl {display: inline;}
.inl-active {
display: inline;
background-color: #FFD300;
}
</style>
<body>
<div>
<a href="/answer">Входящий вызов принят</a>
<a href="/notanswer">Входящий вызов не принят</a>
<a href="/truerecall">Перезвонили успешно</a>
<a href="/falserecall">Перезвонили безуспешно</a>
<div class="inl"><a href="/answer">Входящий вызов принят</a></div>
<div class="inl"><a href="/notanswer">Входящий вызов не принят</a></div>
<div class="inl"><a href="/truerecall">Перезвонили успешно</a></div>
<div class="inl-active"><a href="/falserecall">Перезвонили безуспешно</a></div>
</div>
<!-- <div>
<form name="search" action="/web/call/find/" method="get" class="search">
<label class="search_label">Поиск</label>
<input class="search_text" type="text" name="client">
<input class="search_btn" type="submit" title="Найти">
</form>
</div> -->
<table>
<thead>
<tr>
<th>Номер клиента</th>
<th>Кол-во попыток</th>
<th>Дата и время</th>
<th>Продолжительность</th>
<th>Оператор</th>
<th>Запись</th>
<th>Действие</th>
</tr>
</thead>
@@ -99,16 +94,7 @@
{% else %}
<td>{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}</td>
{% endif %}
<td>{{ c.count_try }}</td>
<td>{{ c.time }}</td>
<td>{{ c.answered_duration // 60 }}:{{ "{:02}".format(c.answered_duration % 60) }}</td>
<td>{{ c.operator }}</td>
<td>
{% if c.has_record == true: %}
<audio src="{{ c.record_url }}" type="audio/mp3" preload="none" controls>Запись</audio>
{% else %}
Отсутствует
{% endif %}
<td>{{ c.dt }}</td>
<td style="vertical-align: middle;">
<div>
<form action="/api/v1/call/set/" method="post" style="border: 0;">

View File

@@ -49,7 +49,7 @@
a {
font-size: large;
font-family: Verdana, Geneva, Tahoma, sans-serif;
color: chocolate;
color: #7A1E99;
padding-right: 50px;
}
@@ -61,22 +61,27 @@
form {
height: 40px;
}
.inl {
display: inline;
}
.inl-active {
display: inline;
background-color: #FFD300;
}
</style>
<body>
<div>
<a href="/answer">Входящий вызов принят</a>
<a href="/notanswer">Входящий вызов не принят</a>
<a href="/truerecall">Перезвонили успешно</a>
<a href="/falserecall">Перезвонили безуспешно</a>
<div class="inl"><a href="/answer">Входящий вызов принят</a></div>
<div class="inl-active"><a href="/notanswer">Входящий вызов не принят</a></div>
<div class="inl"><a href="/truerecall">Перезвонили успешно</a></div>
<div class="inl"><a href="/falserecall">Перезвонили безуспешно</a></div>
</div>
<div>
<!-- <form name="search" action="/web/call/find/" method="get" class="search">
<label class="search_label">Поиск</label>
<input class="search_text" type="text" name="client">
<input class="search_btn" type="submit" title="Найти">
</form> -->
</div>
@@ -86,7 +91,7 @@
<th>Номер клиента</th>
<th>Дата и время</th>
<th>Продолжительность</th>
<!-- <th>Смена статуса</th> -->
<th>Действие</th>
</tr>
</thead>
<tbody>
@@ -95,28 +100,27 @@
{% if c.mkt_phone == "83912051045": %}
<td>
<font color="#C30000">{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7],
c.client[7:11]) }}</font>
<font color="#C30000">
<a href="/work/{{ c.uuid }}">
{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}
</a>
</font>
</td>
{% else %}
<td>{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}</td>
<td>
<a href="/work/{{ c.uuid }}">
{{ "%s %s %s %s" |format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}
</a>
</td>
{% endif %}
<td>{{ c.time }} {{ c.important }}</td>
<td>{{ c.answered_duration // 60 }}:{{ "{:02}".format(c.answered_duration % 60) }}</td>
<!-- <td>
<form action="/api/v1/call/set/" method="post" style="border: 0;">
<input type="hidden" name="uuid" value="{{ c._id }}" />
<input type="hidden" name="res" value="truerecall" />
<input type="submit" value="Дозвонились" style="background-color: chartreuse;" />
<td>
<form action="/api/v1/blacklist/add/{{ c.client }}" method="post" style="border: 0;" />
<input type="submit" value="В черный список" style="background-color: dimgray; color: #fff;" />
</form>
<form action="/api/v1/call/set/" method="post">
<input type="hidden" name="uuid" value="{{ c._id }}" />
<input type="hidden" name="res" value="falserecall" />
<input type="submit" value="Не дозвонились" style="background-color: #FFAAAA;" />
</form>
</td> -->
</td>
</tr>
{% endfor %}
</tbody>

View File

@@ -48,7 +48,7 @@
a {
font-size: large;
font-family: Verdana, Geneva, Tahoma, sans-serif;
color: chocolate;
color: #7A1E99;
padding-right: 50px;
}
@@ -60,30 +60,26 @@
form {
height: 40px;
}
.inl {display: inline;}
.inl-active {
display: inline;
background-color: #FFD300;
}
</style>
<body>
<div>
<a href="/answer">Входящий вызов принят</a>
<a href="/notanswer">Входящий вызов не принят</a>
<a href="/truerecall">Перезвонили успешно</a>
<a href="/falserecall">Перезвонили безуспешно</a>
<div class="inl"><a href="/answer">Входящий вызов принят</a></div>
<div class="inl"><a href="/notanswer">Входящий вызов не принят</a></div>
<div class="inl-active"><a href="/truerecall">Перезвонили успешно</a></div>
<div class="inl"><a href="/falserecall">Перезвонили безуспешно</a></div>
</div>
<!-- <div>
<form name="search" action="/web/call/find/" method="get" class="search">
<label class="search_label">Поиск</label>
<input class="search_text" type="text" name="client">
<input class="search_btn" type="submit" title="Найти">
</form>
</div> -->
<table>
<thead>
<tr>
<th>Номер клиента</th>
<th>Дата и время</th>
<th>Продолжительность</th>
<th>Оператор</th>
<th>Запись разговора</th>
</tr>
</thead>
<tbody>
@@ -98,11 +94,7 @@
{% else %}
<td>{{ "%s %s %s %s"|format(c.client[0:1], c.client[1:4], c.client[4:7], c.client[7:11]) }}</td>
{% endif %}
<td>{{ c.time }}</td>
<td>{{ c.answered_duration // 60 }}:{{ "{:02}".format(c.answered_duration % 60) }}</td>
<td>{{ c.operator }}</td>
<td><audio src="{{ c.record_url }}" type="audio/mp3" preload="none" controls>Запись</audio></td>
<td>{{ c.dt }}</td>
</tr>
{% endfor %}
</tbody>

View File

@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>В работе</title>
</head>
<body style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;">
{% for c in call %}
<h3>{{ c.client }}</h3>
<table style="width: 500px; border: 1px; border-radius: 5px;">
<tr>
<td>Направление:</td>
<td> {{ c.direction }}</td>
</tr>
<tr>
<td>Продолжительность:</td>
<td> {{ c.answered_duration }}</td>
</tr>
<tr>
<td>Время события:</td>
<td>{{ c.time }}</td>
</tr>
<tr>
<td>Вызываемый номер:</td>
<td>{{ c.mkt_phone }}</td>
</tr>
</table>
<form action="/api/v1/work/" method="post">
<fieldset style="width: 500px;">
<legend>Результат</legend>
<div>
<input type="radio" name="recall" value="true" />
<label for="true">Дозвонились</label>
</div>
<div>
<input type="radio" name="recall" value="false" checked />
<label for="false">Не дозвонились</label>
</div>
<input type="hidden" name="uuid" value="{{ c.uuid }}" />
<p>
<div>
<input type="submit" value="Принять">
</div>
</fieldset>
</form>
{% endfor %}
</body>
</html>