diff --git a/dialing_app/locale/ru/LC_MESSAGES/django.po b/dialing_app/locale/ru/LC_MESSAGES/django.po index 4167365..4889f2b 100644 --- a/dialing_app/locale/ru/LC_MESSAGES/django.po +++ b/dialing_app/locale/ru/LC_MESSAGES/django.po @@ -94,3 +94,15 @@ msgstr "Несколько абонентов с указанным номеро #: dialing_app/views.py:29 msgid "User with the telephone number not found" msgstr "Абонент с таким номером телефона не найден" + +msgid "Voice mail" +msgstr "Оставленные сообщения" + +msgid "Type" +msgstr "Тип" + +msgid "Request" +msgstr "Заявка" + +msgid "Report" +msgstr "Поломка" \ No newline at end of file diff --git a/dialing_app/models.py b/dialing_app/models.py index fd74209..0e60f4f 100644 --- a/dialing_app/models.py +++ b/dialing_app/models.py @@ -51,9 +51,13 @@ class AsteriskCDR(models.Model): return _('Unknown') return '' - @staticmethod - def path_to_media(): - return getattr(settings, 'DIALING_MEDIA', '/media') + def path_to_media(self): + path = getattr(settings, 'DIALING_MEDIA', '/media') + if self.userfield == 'request': + return "%s/recording/request" % path + elif self.userfield == 'report': + return "%s/recording/bug" % path + return path class Meta: db_table = 'cdr' diff --git a/dialing_app/templates/ext.html b/dialing_app/templates/ext.html new file mode 100644 index 0000000..5d01acc --- /dev/null +++ b/dialing_app/templates/ext.html @@ -0,0 +1,40 @@ +{% extends request.is_ajax|yesno:'bajax.html,base.html' %} +{% load i18n %} +{% block main %} + + + + {% include 'message_block.html' %} + + + + + +
+
+ {% block content %}{% endblock %} +
+
+ +{% endblock %} diff --git a/dialing_app/templates/index.html b/dialing_app/templates/index.html index 776cab3..ed89478 100644 --- a/dialing_app/templates/index.html +++ b/dialing_app/templates/index.html @@ -1,17 +1,7 @@ -{% extends 'base.html' %} +{% extends request.is_ajax|yesno:'nullcont.htm,ext.html' %} {% load i18n %} {% load telephone_filters %} -{% block main %} - - - - -

{% trans 'Last calls' %}

- - {% include 'message_block.html' %} +{% block content %}
@@ -31,10 +21,14 @@ {% for log in logs %} - diff --git a/dialing_app/templates/vmail.html b/dialing_app/templates/vmail.html new file mode 100644 index 0000000..fb4169a --- /dev/null +++ b/dialing_app/templates/vmail.html @@ -0,0 +1,57 @@ +{% extends request.is_ajax|yesno:'nullcont.htm,ext.html' %} +{% load i18n %} +{% load telephone_filters %} +{% block content %} + +
+
- + + + + + {{ log.calldate|date:'d E Y, H:i:s' }} {{ log.src|abon_if_telephone|safe }}
+ + + + + + + + + + + + + + + {% for vmail in vmessages %} + + + + + + + + + + + + {% empty %} + + + + {% endfor %} + +
{% trans 'Play' %}{% trans 'calldate' %}{% trans 'src' %}{% trans 'Type' %}{% trans 'duration' %}{% trans 'start' %}{% trans 'answer' %}{% trans 'end' %}{% trans 'disposition' %}
+ + + + + {{ vmail.calldate|date:'d E Y, H:i:s' }}{{ vmail.src|abon_if_telephone|safe }} + {% if vmail.userfield == 'request' %}{% trans 'Request' %} + {% elif vmail.userfield == 'report' %}{% trans 'Report' %} + {% else %}{{ vmail.userfield }}{% endif %} + {{ vmail.duration }}{{ vmail.start|date:'d E Y, H:i:s' }}{{ vmail.answer|date:'d E Y, H:i:s' }}{{ vmail.end|date:'d E Y, H:i:s' }}{{ vmail.locate_disposition }}
{% trans 'Calls was not found' %}
+
+ + {% include 'toolbar_page.html' with pag=vmessages %} + +{% endblock %} diff --git a/dialing_app/urls.py b/dialing_app/urls.py index 20b529f..a35f0e2 100644 --- a/dialing_app/urls.py +++ b/dialing_app/urls.py @@ -4,5 +4,6 @@ from . import views urlpatterns = [ url(r'^$', views.home, name='home'), - url(r'^to_abon(?P\+?\d+)$', views.to_abon, name='to_abon') + url(r'^to_abon(?P\+?\d+)$', views.to_abon, name='to_abon'), + url(r'^voicemail$', views.vmail, name='vmail') ] diff --git a/dialing_app/views.py b/dialing_app/views.py index 9125ccc..a190c23 100644 --- a/dialing_app/views.py +++ b/dialing_app/views.py @@ -13,8 +13,10 @@ from .models import AsteriskCDR def home(request): logs = AsteriskCDR.objects.order_by('-calldate') logs = pag_mn(request, logs) + title = _('Last calls') return render(request, 'index.html', { - 'logs': logs + 'logs': logs, + 'title': title }) @@ -34,3 +36,14 @@ def to_abon(request, tel): else: return redirect('abonapp:group_list') + +@login_required +@only_admins +def vmail(request): + title = _('Voice mail') + cdr = AsteriskCDR.objects.filter(userfield='request').order_by('-calldate') + cdr = pag_mn(request, cdr) + return render(request, 'vmail.html', { + 'title': title, + 'vmessages': cdr + }) \ No newline at end of file diff --git a/static/js/my.js b/static/js/my.js index 34416b7..7dc9601 100644 --- a/static/js/my.js +++ b/static/js/my.js @@ -40,7 +40,6 @@ $(document).ajaxError(function (ev, jqXHR, ajaxSettings, thrownError) { var hr = a.attr('href'); var tx = a.text(); selecthid.val(hr.substr(1)); - console.debug(tx); selectbtn.text(tx).removeClass('hidden'); selectinp.addClass('hidden').val(tx); }; @@ -70,6 +69,54 @@ $(document).ajaxError(function (ev, jqXHR, ajaxSettings, thrownError) { })(jQuery); +// AudioPlayer +(function ($) { + $.fn.aplayer = function(){ + + var def_play = function(e){ + var audiotag = e.data['audiotag'][0]; + + if(audiotag.readyState == 0){ + $(this).prop('disabled', true); + return; + }else + $(this).prop('disabled', false); + + if(audiotag.paused) + audiotag.play(); + else + audiotag.pause(); + }; + + var def_canplay = function(){ + var els = $(this).parent(); + els.prop('disabled', false).removeClass('disabled'); + els.siblings().prop('disabled', false).removeClass('disabled'); + }; + + var def_on_play = function(){ + $(this).siblings('span.glyphicon').attr('class', 'glyphicon glyphicon-pause'); + }; + + var def_on_pause = function(){ + $(this).siblings('span.glyphicon').attr('class', 'glyphicon glyphicon-play'); + }; + + this.each(function(){ + var i = $(this); + var audiotag = i.children('audio'); + var icon = i.children('span.glyphicon'); + i.on('click', {'audiotag': audiotag}, def_play); + audiotag.on('canplay', def_canplay); + audiotag.on('play', def_on_play); + audiotag.on('pause', def_on_pause); + }); + + }; +})(jQuery); + + + $(document).ready(function () { // Live html5 image preview @@ -138,6 +185,8 @@ $(document).ready(function () { self.html(r.dat); }); return false; - }) + }); + + $('button.player-btn').aplayer(); });