summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas NOEL <tnoel@entrouvert.com>2016-02-04 01:54:51 (GMT)
committerThomas NOEL <tnoel@entrouvert.com>2016-02-04 08:36:15 (GMT)
commite6536f2091929c4f2d6a9eccf3c22286386f5dde (patch)
tree49e78103eb03e769154d2ec5d6d8d8f0c0319c57
parent201ad7ed04261f3b405417097912032d04a65ccb (diff)
downloadwelco-0.16.zip
welco-0.16.tar.gz
welco-0.16.tar.bz2
phone: use mellon username as a phone line (#9598)v0.16
-rw-r--r--welco/sources/phone/migrations/0004_auto_20160204_0252.py32
-rw-r--r--welco/sources/phone/models.py6
-rw-r--r--welco/sources/phone/views.py9
3 files changed, 44 insertions, 3 deletions
diff --git a/welco/sources/phone/migrations/0004_auto_20160204_0252.py b/welco/sources/phone/migrations/0004_auto_20160204_0252.py
new file mode 100644
index 0000000..10efdac
--- /dev/null
+++ b/welco/sources/phone/migrations/0004_auto_20160204_0252.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('phone', '0003_auto_20151103_1202'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='phonecall',
+ name='callee',
+ field=models.CharField(max_length=80, verbose_name='Callee'),
+ preserve_default=True,
+ ),
+ migrations.AlterField(
+ model_name='phonecall',
+ name='caller',
+ field=models.CharField(max_length=80, verbose_name='Caller'),
+ preserve_default=True,
+ ),
+ migrations.AlterField(
+ model_name='phoneline',
+ name='callee',
+ field=models.CharField(unique=True, max_length=80, verbose_name='Callee'),
+ preserve_default=True,
+ ),
+ ]
diff --git a/welco/sources/phone/models.py b/welco/sources/phone/models.py
index cc3bf4e..4ea4f4b 100644
--- a/welco/sources/phone/models.py
+++ b/welco/sources/phone/models.py
@@ -26,8 +26,8 @@ class PhoneCall(models.Model):
class Meta:
verbose_name = _('Phone Call')
- caller = models.CharField(_('Caller'), max_length=20)
- callee = models.CharField(_('Callee'), max_length=20)
+ caller = models.CharField(_('Caller'), max_length=80)
+ callee = models.CharField(_('Callee'), max_length=80)
start = models.DateTimeField(_('Start'), auto_now_add=True)
stop = models.DateTimeField(_('Stop'), null=True, blank=True)
data = models.TextField(_('Data'), blank=True)
@@ -78,7 +78,7 @@ class PhoneCall(models.Model):
return '%02d:%02d' % (seconds//60, seconds%60)
class PhoneLine(models.Model):
- callee = models.CharField(_('Callee'), unique=True, max_length=20)
+ callee = models.CharField(_('Callee'), unique=True, max_length=80)
users = models.ManyToManyField('auth.User', verbose_name=_('User'))
@classmethod
diff --git a/welco/sources/phone/views.py b/welco/sources/phone/views.py
index 7c8c854..e8a5c7b 100644
--- a/welco/sources/phone/views.py
+++ b/welco/sources/phone/views.py
@@ -47,6 +47,15 @@ class Home(object):
class PhoneZone(TemplateView):
template_name = 'welco/phone_home.html'
+ def get(self, request, *args, **kwargs):
+ username = request.session.get('mellon_session', {}).get('username')
+ if username:
+ # user is from SSO, username is a phone line (callee), create a link to it
+ username = username[0].split('@', 1)[0][:80] # remove realm
+ if username:
+ PhoneLine.take(callee=username, user=self.request.user)
+ return super(PhoneZone, self).get(request, *args, **kwargs)
+
def get_context_data(self, **kwargs):
context = super(PhoneZone, self).get_context_data(**kwargs)
context['source_type'] = ContentType.objects.get_for_model(PhoneCall)