From 3c893440fc8af15ca91bd66992e47839990fcd96 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 28 Jun 2023 15:44:44 +0000 Subject: [PATCH] people: Drop old calls page Signed-off-by: Michael Tremer --- Makefile.am | 4 -- src/backend/accounts.py | 3 - src/backend/talk.py | 99 --------------------------- src/templates/people/call.html | 95 ------------------------- src/templates/people/calls.html | 42 ------------ src/templates/people/modules/cdr.html | 50 -------------- src/templates/people/modules/mos.html | 21 ------ src/templates/users/show.html | 11 --- src/web/__init__.py | 4 -- src/web/people.py | 55 --------------- 10 files changed, 384 deletions(-) delete mode 100644 src/templates/people/call.html delete mode 100644 src/templates/people/calls.html delete mode 100644 src/templates/people/modules/cdr.html delete mode 100644 src/templates/people/modules/mos.html diff --git a/Makefile.am b/Makefile.am index ca5382f1..76a37282 100644 --- a/Makefile.am +++ b/Makefile.am @@ -275,8 +275,6 @@ templates_nopaste_modulesdir = $(templates_nopastedir)/modules templates_people_DATA = \ src/templates/people/conferences.html \ - src/templates/people/call.html \ - src/templates/people/calls.html \ src/templates/people/index.html \ src/templates/people/sip.html \ src/templates/people/subscribed.html \ @@ -292,9 +290,7 @@ templates_people_messagesdir = $(templates_peopledir)/messages templates_people_modules_DATA = \ src/templates/people/modules/agent.html \ - src/templates/people/modules/cdr.html \ src/templates/people/modules/channels.html \ - src/templates/people/modules/mos.html \ src/templates/people/modules/password.html \ src/templates/people/modules/password.js \ src/templates/people/modules/registrations.html diff --git a/src/backend/accounts.py b/src/backend/accounts.py index ade04f7d..c2f19e64 100644 --- a/src/backend/accounts.py +++ b/src/backend/accounts.py @@ -1152,9 +1152,6 @@ class Account(LDAPObject): return await self.backend.asterisk.get_sip_channels(self.sip_id) - def get_cdr(self, date=None, limit=None): - return self.backend.talk.freeswitch.get_cdr_by_account(self, date=date, limit=limit) - # Phone Numbers @lazy_property diff --git a/src/backend/talk.py b/src/backend/talk.py index e37fb854..590d79a5 100644 --- a/src/backend/talk.py +++ b/src/backend/talk.py @@ -52,24 +52,6 @@ class Freeswitch(Object): "inbound", account.sip_id, "outbound", account.sip_id, account._all_telephone_numbers, "DOWN") - def get_cdr_by_account(self, account, date=None, limit=None): - res = self.db.query("SELECT * FROM cdr \ - WHERE ((caller_id_number = ANY(%s) AND bleg_uuid IS NOT NULL) \ - OR (destination_number = ANY(%s) AND bleg_uuid IS NULL)) \ - AND (%s IS NULL OR start_stamp::date = %s) \ - ORDER BY end_stamp DESC LIMIT %s", account._all_telephone_numbers, - account._all_telephone_numbers, date, date, limit) - - for row in res: - yield CDR(self, data=row) - - def get_call_by_uuid(self, uuid): - res = self.db.get("SELECT * FROM cdr \ - WHERE uuid = %s", uuid) - - if res: - return CDR(self, data=res) - def get_conferences(self): res = self.db.query("SELECT DISTINCT application_data AS handle FROM channels \ WHERE application = %s AND application_data LIKE %s \ @@ -209,87 +191,6 @@ class Channel(object): return "%s: %s" % (key_negotiation.upper(), cipher_suite.replace("_", "-")) -class CDR(object): - def __init__(self, freeswitch, data): - self.freeswitch = freeswitch - self.data = data - - @property - def backend(self): - return self.freeswitch.backend - - @property - def db(self): - return self.freeswitch.db - - @property - def uuid(self): - return self.data.uuid - - @lazy_property - def bleg(self): - if self.data.bleg_uuid: - return self.freeswitch.get_call_by_uuid(self.data.bleg_uuid) - - # If we are the bleg, we need to search for one where UUID is the bleg - res = self.db.get("SELECT * FROM cdr WHERE bleg_uuid = %s", self.uuid) - - if res: - return CDR(self.freeswitch, data=res) - - @property - def direction(self): - if self.data.bleg_uuid: - return "inbound" - - return "outbound" - - @lazy_property - def caller(self): - return self.backend.accounts.get_by_phone_number(self.data.caller_id_number) - - @property - def caller_number(self): - return self.data.caller_id_number - - @lazy_property - def callee(self): - return self.backend.accounts.get_by_phone_number(self.data.destination_number) - - @property - def callee_number(self): - return self.data.destination_number - - @property - def time_start(self): - return self.data.start_stamp - - @property - def time_answered(self): - return self.data.answer_stamp - - @property - def duration(self): - return self.data.duration - - @property - def codec(self): - return format_codec(self.data.write_codec, int(self.data.write_rate or 0), int(self.data.write_bit_rate or 0)) - - @property - def user_agent(self): - if self.data.user_agent: - return self.data.user_agent.replace("_", " ") - - @property - def size(self): - return sum((self.data.rtp_audio_in_raw_bytes or 0, self.data.rtp_audio_out_raw_bytes or 0)) - - @property - def mos(self): - return self.data.rtp_audio_in_mos - - class Conference(object): def __init__(self, freeswitch, handle): self.freeswitch = freeswitch diff --git a/src/templates/people/call.html b/src/templates/people/call.html deleted file mode 100644 index 83edd816..00000000 --- a/src/templates/people/call.html +++ /dev/null @@ -1,95 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ account }} - {{ _("Call") }}{% end block %} - -{% block container %} -
-
-

- {% if call.direction == "inbound" %} - {{ _("Call to") }} - - {% if call.callee %} - {{ call.callee }} - {% else %} - {{ format_phone_number(call.callee_number) }} - {% end %} - {% elif call.direction == "outbound" %} - {{ _("Call from") }} - - {% if call.caller %} - {{ call.caller }} - {% else %} - {{ format_phone_number(call.caller_number) }} - {% end %} - {% end %} -

- -
    -
  • - {{ locale.format_date(call.time_answered or call.time_start, relative=False) }} -
  • - -
  • - {% if call.duration %} - {{ format_time(call.duration) }} - {% else %} - {{ _("Not Answered") }} - {% end %} -
  • -

    -
-
- -
-
-

{{ _("Media Information") }}

- -
- {% for c in (call, call.bleg) %} - {% if c %} -
-
-
-
- {% if c == call %} - {{ _("Your Leg") }} - {% else %} - {{ _("Other Leg") }} - {% end %} - - {% if c.user_agent %} - - ({{ c.user_agent }}) - - {% end %} -
- - - -

- {% module MOS(c) %} -

- -
    - {% if c.codec %} -
  • - {{ c.codec }} -
  • - {% end %} - - {% if c.size %} -
  • - {{ format_size(c.size) }} -
  • - {% end %} -
-
-
-
- {% end %} - {% end %} -
-
-
-{% end %} diff --git a/src/templates/people/calls.html b/src/templates/people/calls.html deleted file mode 100644 index bb92d927..00000000 --- a/src/templates/people/calls.html +++ /dev/null @@ -1,42 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ account }} - {{ _("Calls") }}{% end block %} - -{% block container %} -
-
-

{{ _("Calls") }}

- -

- {{ locale.format_day(date) }} -

-
-
- -
-
- {% module Channels(account) %} - - - - {% module CDR(account, date=date) %} -
-
-{% end block %} diff --git a/src/templates/people/modules/cdr.html b/src/templates/people/modules/cdr.html deleted file mode 100644 index a810b15b..00000000 --- a/src/templates/people/modules/cdr.html +++ /dev/null @@ -1,50 +0,0 @@ -{% if cdr %} - -{% else %} -

- {{ _("There are no calls") }} -

-{% end %} diff --git a/src/templates/people/modules/mos.html b/src/templates/people/modules/mos.html deleted file mode 100644 index 493fc4d0..00000000 --- a/src/templates/people/modules/mos.html +++ /dev/null @@ -1,21 +0,0 @@ -{% if call.mos %} - {% if call.mos >= 4.5 %} - {% set color = "text-success" %} - {% elif call.mos >= 4.3 %} - {% set color = "text-warning" %} - {% else %} - {% set color = "text-danger" %} - {% end %} - - - {% for i in range(5) %} - {% if call.mos > (i + 0.5) %} - - {% elif call.mos > i %} - - {% else %} - - {% end %} - {% end %} - -{% end %} diff --git a/src/templates/users/show.html b/src/templates/users/show.html index 1a949607..5adb0665 100644 --- a/src/templates/users/show.html +++ b/src/templates/users/show.html @@ -84,17 +84,6 @@ {% end %} {% if account.can_be_managed_by(current_user) %} - {% if account.has_sip() %} - - - - - - {{ _("Calls") }} - - - {% end %} - {{ _("Change Password") }} diff --git a/src/web/__init__.py b/src/web/__init__.py index 0f89e4c5..49c861db 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -76,9 +76,7 @@ class Application(tornado.web.Application): # People "Agent" : people.AgentModule, - "CDR" : people.CDRModule, "Channels" : people.ChannelsModule, - "MOS" : people.MOSModule, "Password" : people.PasswordModule, "Registrations" : people.RegistrationsModule, @@ -329,8 +327,6 @@ class Application(tornado.web.Application): (r"/activate/([a-z_][a-z0-9_-]{0,31})/(\w+)", auth.ActivateHandler), (r"/conferences", people.ConferencesHandler), (r"/register", auth.RegisterHandler), - (r"/users/([a-z_][a-z0-9_-]{0,31})/calls/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})", people.CallHandler), - (r"/users/([a-z_][a-z0-9_-]{0,31})/calls(?:/(\d{4}-\d{2}-\d{2}))?", people.CallsHandler), (r"/users/([a-z_][a-z0-9_-]{0,31})/sip", people.SIPHandler), # Promotional Consent Stuff diff --git a/src/web/people.py b/src/web/people.py index 1e0b331a..a7b4c43f 100644 --- a/src/web/people.py +++ b/src/web/people.py @@ -13,48 +13,6 @@ class IndexHandler(base.BaseHandler): self.render("people/index.html") -class CallsHandler(base.BaseHandler): - @tornado.web.authenticated - def get(self, uid, date=None): - account = self.backend.accounts.get_by_uid(uid) - if not account: - raise tornado.web.HTTPError(404, "Could not find account %s" % uid) - - # Check for permissions - if not account.can_be_managed_by(self.current_user): - raise tornado.web.HTTPError(403, "%s cannot manage %s" % (self.current_user, account)) - - if date: - try: - date = datetime.datetime.strptime(date, "%Y-%m-%d").date() - except ValueError: - raise tornado.web.HTTPError(400, "Invalid date: %s" % date) - else: - date = datetime.date.today() - - self.render("people/calls.html", account=account, date=date) - - -class CallHandler(base.BaseHandler): - @tornado.web.authenticated - def get(self, uid, uuid): - account = self.backend.accounts.get_by_uid(uid) - if not account: - raise tornado.web.HTTPError(404, "Could not find account %s" % uid) - - # Check for permissions - if not account.can_be_managed_by(self.current_user): - raise tornado.web.HTTPError(403, "%s cannot manage %s" % (self.current_user, account)) - - call = self.backend.talk.freeswitch.get_call_by_uuid(uuid) - if not call: - raise tornado.web.HTTPError(404, "Could not find call %s" % uuid) - - # XXX limit - - self.render("people/call.html", account=account, call=call) - - class ConferencesHandler(base.BaseHandler): @tornado.web.authenticated def get(self): @@ -105,25 +63,12 @@ class AgentModule(ui_modules.UIModule): return self.render_string("people/modules/agent.html", account=account) -class CDRModule(ui_modules.UIModule): - def render(self, account, date=None, limit=None): - cdr = account.get_cdr(date=date, limit=limit) - - return self.render_string("people/modules/cdr.html", - account=account, cdr=list(cdr)) - - class ChannelsModule(ui_modules.UIModule): def render(self, account): return self.render_string("people/modules/channels.html", account=account, channels=account.sip_channels) -class MOSModule(ui_modules.UIModule): - def render(self, call): - return self.render_string("people/modules/mos.html", call=call) - - class PasswordModule(ui_modules.UIModule): def render(self, account=None): return self.render_string("people/modules/password.html", account=account) -- 2.47.3