diff --git a/helpdesk/models.py b/helpdesk/models.py
index 6b166d7a..9b0b822a 100644
--- a/helpdesk/models.py
+++ b/helpdesk/models.py
@@ -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',)
diff --git a/helpdesk/templates/helpdesk/ticket_desc_table.html b/helpdesk/templates/helpdesk/ticket_desc_table.html
index fb46e4ce..b3f9d891 100644
--- a/helpdesk/templates/helpdesk/ticket_desc_table.html
+++ b/helpdesk/templates/helpdesk/ticket_desc_table.html
@@ -38,7 +38,7 @@
{{ ticket.resolution|force_escape|urlizetrunc:50|linebreaksbr }} |
{% endif %}
-
+
{% trans "Due Date" %} |
{{ ticket.due_date|date:"r" }} ({{ ticket.due_date|naturaltime }}) |
@@ -55,7 +55,9 @@
{% trans "Submitter E-Mail" %} |
- {{ ticket.submitter_email }}{% if user.is_superuser %} {% endif %} |
+ {{ ticket.submitter_email }}
+ {% if user.is_superuser %} {% if submitter_userprofile_url %}{% endif %}
+ {% endif %} |
diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py
index bb63e2dd..e6496694 100644
--- a/helpdesk/views/staff.py
+++ b/helpdesk/views/staff.py
@@ -14,6 +14,7 @@ from django import VERSION as DJANGO_VERSION
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import user_passes_test
+from django.contrib.contenttypes.models import ContentType
from django.urls import reverse
from django.core.exceptions import ValidationError, PermissionDenied
from django.db import connection
@@ -319,8 +320,18 @@ def view_ticket(request, ticket_id):
ticketcc_string, show_subscribe = \
return_ticketccstring_and_show_subscribe(request.user, ticket)
+ submitter_userprofile = ticket.get_submitter_userprofile()
+ if submitter_userprofile is not None:
+ content_type = ContentType.objects.get_for_model(submitter_userprofile)
+ submitter_userprofile_url = reverse(
+ 'admin:{app}_{model}_change'.format(app=content_type.app_label, model=content_type.model),
+ kwargs={'object_id': submitter_userprofile.id}
+ )
+ else:
+ submitter_userprofile_url = None
return render(request, 'helpdesk/ticket.html', {
'ticket': ticket,
+ 'submitter_userprofile_url': submitter_userprofile_url,
'form': form,
'active_users': users,
'priorities': Ticket.PRIORITY_CHOICES,