From c68eebba41e78b62570318b50c03e48943e83b4c Mon Sep 17 00:00:00 2001 From: bashmak Date: Tue, 23 May 2017 13:49:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D1=81=D0=BB=D1=83=D1=88=D0=B8=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B5=D0=B9?= =?UTF-8?q?=20=D0=B7=D0=B2=D0=BE=D0=BD=D0=BA=D0=BE=D0=B2,=20=D0=B8=20?= =?UTF-8?q?=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D1=83=20=D0=BD=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B8=D1=81=D0=BA=20=D0=B0=D0=B1=D0=BE=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=BE=D0=B2=20=D1=81=20=D0=BD=D0=BE=D0=BC=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=D0=BC=D0=B8=20=D1=82=D0=B5=D0=BB=D0=B5=D1=84=D0=BE=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dialing_app/locale/ru/LC_MESSAGES/django.po | 37 +++++---------------- dialing_app/models.py | 19 +++++++++++ dialing_app/urls.py | 1 + dialing_app/views.py | 19 ++++++++++- 4 files changed, 47 insertions(+), 29 deletions(-) diff --git a/dialing_app/locale/ru/LC_MESSAGES/django.po b/dialing_app/locale/ru/LC_MESSAGES/django.po index a5c9f8c..482b2b0 100644 --- a/dialing_app/locale/ru/LC_MESSAGES/django.po +++ b/dialing_app/locale/ru/LC_MESSAGES/django.po @@ -59,30 +59,10 @@ msgstr "кто" msgid "dst" msgstr "куда" -#: dialing_app/templates/index.html:22 -msgid "dcontext" -msgstr "контекст" - -#: dialing_app/templates/index.html:23 -msgid "channel" -msgstr "канал" - -#: dialing_app/templates/index.html:24 -msgid "dstchannel" -msgstr "канал назначения" - -#: dialing_app/templates/index.html:25 -msgid "lastdata" -msgstr "lastdata" - #: dialing_app/templates/index.html:26 msgid "duration" msgstr "продолжительность" -#: dialing_app/templates/index.html:27 -msgid "billsec" -msgstr "вся продолж." - #: dialing_app/templates/index.html:28 msgid "start" msgstr "начало" @@ -99,14 +79,15 @@ msgstr "конец" msgid "disposition" msgstr "состояние" -#: dialing_app/templates/index.html:32 -msgid "amaflags" -msgstr "amaflags" - -#: dialing_app/templates/index.html:33 -msgid "uniqueid" -msgstr "uniqueid" - #: dialing_app/templates/index.html:57 msgid "Calls was not found" msgstr "Звонки не найдены" + +msgid "Play" +msgstr "Слушать" + +msgid "User with the telephone number not found" +msgstr "Абонент с таким номером телефона не найден" + +msgid "Multiple users with the telephone number" +msgstr "Несколько абонентов с указанным номером телефона" diff --git a/dialing_app/models.py b/dialing_app/models.py index 29ab683..c1ab834 100644 --- a/dialing_app/models.py +++ b/dialing_app/models.py @@ -1,5 +1,6 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ +from djing import settings class AsteriskCDR(models.Model): @@ -36,6 +37,24 @@ class AsteriskCDR(models.Model): def delete(self, *args, **kwargs): return + def locate_disposition(self): + dsp = self.disposition + if dsp == 'NO ANSWER': + return _('No answer') + elif dsp == 'FAILED': + return _('Failed') + elif dsp == 'BUSY': + return _('Busy') + elif dsp == 'ANSWERED': + return _('Answered') + elif dsp == 'UNKNOWN': + return _('Unknown') + return '' + + @staticmethod + def path_to_media(): + return getattr(settings, 'DIALING_MEDIA', '/media') + class Meta: abstract = True diff --git a/dialing_app/urls.py b/dialing_app/urls.py index c114c32..20b529f 100644 --- a/dialing_app/urls.py +++ b/dialing_app/urls.py @@ -4,4 +4,5 @@ from . import views urlpatterns = [ url(r'^$', views.home, name='home'), + url(r'^to_abon(?P\+?\d+)$', views.to_abon, name='to_abon') ] diff --git a/dialing_app/views.py b/dialing_app/views.py index 0a1292e..9013817 100644 --- a/dialing_app/views.py +++ b/dialing_app/views.py @@ -1,6 +1,9 @@ from django.contrib.auth.decorators import login_required -from django.shortcuts import render +from django.contrib import messages +from django.shortcuts import render, redirect +from django.utils.translation import ugettext_lazy as _ +from abonapp.models import Abon from mydefs import only_admins from .models import getModel @@ -13,3 +16,17 @@ def home(request): return render(request, 'index.html', { 'logs': logs }) + + +@login_required +@only_admins +def to_abon(request, tel): + abon = Abon.objects.filter(telephone=tel) + abon_count = abon.count() + if abon_count > 1: + messages.warning(request, _('Multiple users with the telephone number')) + abon = abon[0] + elif abon_count == 0: + messages.error(request, _('User with the telephone number not found')) + return redirect('dialapp:home') + return redirect('abonapp:abon_home', gid=abon.group_id, uid=abon.pk)