phone: get mellon username in all zone views (#9598 fix)

This commit is contained in:
Thomas NOËL 2016-02-04 10:15:47 +01:00
parent e6536f2091
commit 467f7bb9a0
1 changed files with 2 additions and 5 deletions

View File

@ -47,16 +47,13 @@ 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')
def get_context_data(self, **kwargs):
username = self.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)
context['phonelines'] = PhoneLine.objects.filter(users__id=self.request.user.id)