mail: display user as unknown if it doesn't exist anymore (#13923)

This commit is contained in:
Frédéric Péters 2016-11-12 21:09:32 +01:00
parent f45a55dc57
commit 27dc0bd814
1 changed files with 5 additions and 1 deletions

View File

@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
import requests
import subprocess
from django.conf import settings
@ -98,7 +99,10 @@ class Mail(models.Model):
def contact_name(self):
if not self.contact_id:
return ''
user_details = get_wcs_data('api/users/%s/' % self.contact_id)
try:
user_details = get_wcs_data('api/users/%s/' % self.contact_id)
except requests.HTTPError:
return _('unknown')
return user_details.get('user_display_name')
def html_note(self):