Add user profile links for submiters who have profiles

This commit is contained in:
Timothy Hobbs
2018-08-20 01:08:45 +02:00
parent 13539e3056
commit 082b6b88f3
3 changed files with 23 additions and 2 deletions

View File

@ -9,6 +9,7 @@ models.py - Model (and hence database) definitions. This is the core of the
from __future__ import unicode_literals
from django.contrib.auth.models import Permission
from django.contrib.auth import get_user_model
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
@ -581,6 +582,13 @@ class Ticket(models.Model):
depends_on__status__in=OPEN_STATUSES).count() == 0
can_be_resolved = property(_can_be_resolved)
def get_submitter_userprofile(self):
User = get_user_model()
try:
return User.objects.get(email=self.submitter_email)
except User.DoesNotExist:
return None
class Meta:
get_latest_by = "created"
ordering = ('id',)