Browse Source

Добавил к звонилке вкладку оставленных абонентских сообщений через автоответчик. И доделал аудио проигрыватель чтоб слушать записи

devel
bashmak 9 years ago
parent
commit
9e22152815
  1. 12
      dialing_app/locale/ru/LC_MESSAGES/django.po
  2. 10
      dialing_app/models.py
  3. 40
      dialing_app/templates/ext.html
  4. 26
      dialing_app/templates/index.html
  5. 57
      dialing_app/templates/vmail.html
  6. 3
      dialing_app/urls.py
  7. 15
      dialing_app/views.py
  8. 53
      static/js/my.js

12
dialing_app/locale/ru/LC_MESSAGES/django.po

@ -94,3 +94,15 @@ msgstr "Несколько абонентов с указанным номеро
#: dialing_app/views.py:29 #: dialing_app/views.py:29
msgid "User with the telephone number not found" msgid "User with the telephone number not found"
msgstr "Абонент с таким номером телефона не найден" msgstr "Абонент с таким номером телефона не найден"
msgid "Voice mail"
msgstr "Оставленные сообщения"
msgid "Type"
msgstr "Тип"
msgid "Request"
msgstr "Заявка"
msgid "Report"
msgstr "Поломка"

10
dialing_app/models.py

@ -51,9 +51,13 @@ class AsteriskCDR(models.Model):
return _('Unknown') return _('Unknown')
return '' 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: class Meta:
db_table = 'cdr' db_table = 'cdr'

40
dialing_app/templates/ext.html

@ -0,0 +1,40 @@
{% extends request.is_ajax|yesno:'bajax.html,base.html' %}
{% load i18n %}
{% block main %}
<ol class="breadcrumb">
<li><span class="glyphicon glyphicon-home"></span></li>
<li class="active">{% trans 'Last calls' %}</li>
</ol>
{% include 'message_block.html' %}
<div class="page-header">
<h3>{{ title }}</h3>
</div>
<ul class="nav nav-tabs">
{% url 'dialapp:home' as dialhome %}
<li{% if dialhome == request.path %} class="active"{% endif %}>
<a href="{{ dialhome }}">
{% trans 'Last calls' %}
</a>
</li>
{% url 'dialapp:vmail' as dialmail %}
<li{% if dialmail == request.path %} class="active"{% endif %}>
<a href="{{ dialmail }}">
{% trans 'Voice mail' %}
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active">
{% block content %}{% endblock %}
</div>
</div>
{% endblock %}

26
dialing_app/templates/index.html

@ -1,17 +1,7 @@
{% extends 'base.html' %}
{% extends request.is_ajax|yesno:'nullcont.htm,ext.html' %}
{% load i18n %} {% load i18n %}
{% load telephone_filters %} {% load telephone_filters %}
{% block main %}
<ol class="breadcrumb">
<li><span class="glyphicon glyphicon-home"></span></li>
<li class="active">{% trans 'Dialing' %}</li>
</ol>
<h3>{% trans 'Last calls' %}</h3>
{% include 'message_block.html' %}
{% block content %}
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">
@ -31,10 +21,14 @@
<tbody> <tbody>
{% for log in logs %} {% for log in logs %}
<tr> <tr>
<td>
<audio preload="metadata" controls>
<source src="{{ log.path_to_media }}/{{ log.calldate|date:"YmdHi" }}-{{ log.src }}-{{ log.dst }}.wav" type="audio/wav"/>
</audio>
<td class="btn-group btn-group-sm">
<button class="btn btn-default player-btn disabled">
<span class="glyphicon glyphicon-play"></span>
<audio preload="metadata" src="{{ log.path_to_media }}/{{ log.calldate|date:"YmdHi" }}-{{ log.src }}-{{ log.dst }}.wav"></audio>
</button>
<a href="{{ log.path_to_media }}/{{ log.calldate|date:"YmdHi" }}-{{ log.src }}-{{ log.dst }}.wav" class="btn btn-default disabled" target="_blank">
<span class="glyphicon glyphicon-download-alt"></span>
</a>
</td> </td>
<td>{{ log.calldate|date:'d E Y, H:i:s' }}</td> <td>{{ log.calldate|date:'d E Y, H:i:s' }}</td>
<td>{{ log.src|abon_if_telephone|safe }}</td> <td>{{ log.src|abon_if_telephone|safe }}</td>

57
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 %}
<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{% trans 'Play' %}</th>
<th>{% trans 'calldate' %}</th>
<th>{% trans 'src' %}</th>
<th>{% trans 'Type' %}</th>
<th>{% trans 'duration' %}</th>
<th>{% trans 'start' %}</th>
<th>{% trans 'answer' %}</th>
<th>{% trans 'end' %}</th>
<th>{% trans 'disposition' %}</th>
</tr>
</thead>
<tbody>
{% for vmail in vmessages %}
<tr>
<td class="btn-group btn-group-sm">
<button class="btn btn-default player-btn disabled">
<span class="glyphicon glyphicon-play"></span>
<audio preload="metadata" src="{{ vmail.path_to_media }}/{{ vmail.calldate|date:"YmdHi" }}-{{ vmail.src }}-{{ vmail.dst }}.wav"></audio>
</button>
<a href="{{ vmail.path_to_media }}/{{ vmail.calldate|date:"YmdHi" }}-{{ vmail.src }}-{{ vmail.dst }}.wav" class="btn btn-default disabled" target="_blank">
<span class="glyphicon glyphicon-download-alt"></span>
</a>
</td>
<td>{{ vmail.calldate|date:'d E Y, H:i:s' }}</td>
<td>{{ vmail.src|abon_if_telephone|safe }}</td>
<td>
{% if vmail.userfield == 'request' %}{% trans 'Request' %}
{% elif vmail.userfield == 'report' %}{% trans 'Report' %}
{% else %}{{ vmail.userfield }}{% endif %}
</td>
<td>{{ vmail.duration }}</td>
<td>{{ vmail.start|date:'d E Y, H:i:s' }}</td>
<td>{{ vmail.answer|date:'d E Y, H:i:s' }}</td>
<td>{{ vmail.end|date:'d E Y, H:i:s' }}</td>
<td>{{ vmail.locate_disposition }}</td>
</tr>
{% empty %}
<tr>
<td colspan="9">{% trans 'Calls was not found' %}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% include 'toolbar_page.html' with pag=vmessages %}
{% endblock %}

3
dialing_app/urls.py

@ -4,5 +4,6 @@ from . import views
urlpatterns = [ urlpatterns = [
url(r'^$', views.home, name='home'), url(r'^$', views.home, name='home'),
url(r'^to_abon(?P<tel>\+?\d+)$', views.to_abon, name='to_abon')
url(r'^to_abon(?P<tel>\+?\d+)$', views.to_abon, name='to_abon'),
url(r'^voicemail$', views.vmail, name='vmail')
] ]

15
dialing_app/views.py

@ -13,8 +13,10 @@ from .models import AsteriskCDR
def home(request): def home(request):
logs = AsteriskCDR.objects.order_by('-calldate') logs = AsteriskCDR.objects.order_by('-calldate')
logs = pag_mn(request, logs) logs = pag_mn(request, logs)
title = _('Last calls')
return render(request, 'index.html', { return render(request, 'index.html', {
'logs': logs
'logs': logs,
'title': title
}) })
@ -34,3 +36,14 @@ def to_abon(request, tel):
else: else:
return redirect('abonapp:group_list') 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
})

53
static/js/my.js

@ -40,7 +40,6 @@ $(document).ajaxError(function (ev, jqXHR, ajaxSettings, thrownError) {
var hr = a.attr('href'); var hr = a.attr('href');
var tx = a.text(); var tx = a.text();
selecthid.val(hr.substr(1)); selecthid.val(hr.substr(1));
console.debug(tx);
selectbtn.text(tx).removeClass('hidden'); selectbtn.text(tx).removeClass('hidden');
selectinp.addClass('hidden').val(tx); selectinp.addClass('hidden').val(tx);
}; };
@ -70,6 +69,54 @@ $(document).ajaxError(function (ev, jqXHR, ajaxSettings, thrownError) {
})(jQuery); })(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 () { $(document).ready(function () {
// Live html5 image preview // Live html5 image preview
@ -138,6 +185,8 @@ $(document).ready(function () {
self.html(r.dat); self.html(r.dat);
}); });
return false; return false;
})
});
$('button.player-btn').aplayer();
}); });
Loading…
Cancel
Save