phone: display previous phone calls
This commit is contained in:
parent
97bfd57641
commit
4f900879e6
|
@ -66,6 +66,16 @@ class PhoneCall(models.Model):
|
|||
'channel': 'phone',
|
||||
}
|
||||
|
||||
def previous_calls(self):
|
||||
return PhoneCall.objects.filter(caller=self.caller).exclude(
|
||||
id=self.id).order_by('-start')[:5]
|
||||
|
||||
@property
|
||||
def duration(self):
|
||||
if not self.stop:
|
||||
return 'n.a.'
|
||||
seconds = (self.stop - self.start).seconds
|
||||
return '%02d:%02d' % (seconds//60, seconds%60)
|
||||
|
||||
class PhoneLine(models.Model):
|
||||
callee = models.CharField(_('Callee'), unique=True, max_length=20)
|
||||
|
|
|
@ -35,6 +35,17 @@
|
|||
<div class="phonecall active" data-source-pk="{{phonecall.id}}"
|
||||
data-active-call-url="{% url 'phone-active-call' pk=phonecall.id %}">
|
||||
<h1>{% trans 'Current Call:' %} <strong>{{phonecall.caller}}</strong></h1>
|
||||
|
||||
{% if phonecall.previous_calls %}
|
||||
<div class="previous-calls">
|
||||
<h2>{% trans 'Previous calls from same number' %}</h2>
|
||||
<ul>
|
||||
{% for call in phonecall.previous_calls %}
|
||||
<li>{{ call.start }} ({{ call.duration }})</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue