mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-25 17:33:08 +01:00
Add user profile links for submiters who have profiles
This commit is contained in:
parent
13539e3056
commit
082b6b88f3
@ -9,6 +9,7 @@ models.py - Model (and hence database) definitions. This is the core of the
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from django.contrib.auth.models import Permission
|
from django.contrib.auth.models import Permission
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.db import models
|
from django.db import models
|
||||||
@ -581,6 +582,13 @@ class Ticket(models.Model):
|
|||||||
depends_on__status__in=OPEN_STATUSES).count() == 0
|
depends_on__status__in=OPEN_STATUSES).count() == 0
|
||||||
can_be_resolved = property(_can_be_resolved)
|
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:
|
class Meta:
|
||||||
get_latest_by = "created"
|
get_latest_by = "created"
|
||||||
ordering = ('id',)
|
ordering = ('id',)
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan='2'>{{ ticket.resolution|force_escape|urlizetrunc:50|linebreaksbr }}</td>
|
<td colspan='2'>{{ ticket.resolution|force_escape|urlizetrunc:50|linebreaksbr }}</td>
|
||||||
</tr>{% endif %}
|
</tr>{% endif %}
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Due Date" %}</th>
|
<th>{% trans "Due Date" %}</th>
|
||||||
<td>{{ ticket.due_date|date:"r" }} ({{ ticket.due_date|naturaltime }})</td>
|
<td>{{ ticket.due_date|date:"r" }} ({{ ticket.due_date|naturaltime }})</td>
|
||||||
@ -55,7 +55,9 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Submitter E-Mail" %}</th>
|
<th>{% trans "Submitter E-Mail" %}</th>
|
||||||
<td>{{ ticket.submitter_email }}{% if user.is_superuser %} <strong><a href='{% url 'helpdesk:email_ignore_add' %}?email={{ ticket.submitter_email }}'><button type="button" class="btn btn-warning btn-xs"><i class="fa fa-eye-slash"></i> {% trans "Ignore" %}</button></a></strong>{% endif %}</td>
|
<td>{{ ticket.submitter_email }}
|
||||||
|
{% if user.is_superuser %} {% if submitter_userprofile_url %}<strong><a href='{{submitter_userprofile_url}}'><button type="button" class="btn btn-primary btn-xs"><i class="fa fa-address-book"></i> {% trans "Profile" %}</button></a></strong>{% endif %}
|
||||||
|
<strong><a href='{% url 'helpdesk:email_ignore_add' %}?email={{ ticket.submitter_email }}'><button type="button" class="btn btn-warning btn-xs"><i class="fa fa-eye-slash"></i> {% trans "Ignore" %}</button></a></strong>{% endif %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -14,6 +14,7 @@ from django import VERSION as DJANGO_VERSION
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.contrib.auth.decorators import user_passes_test
|
from django.contrib.auth.decorators import user_passes_test
|
||||||
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.core.exceptions import ValidationError, PermissionDenied
|
from django.core.exceptions import ValidationError, PermissionDenied
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
@ -319,8 +320,18 @@ def view_ticket(request, ticket_id):
|
|||||||
ticketcc_string, show_subscribe = \
|
ticketcc_string, show_subscribe = \
|
||||||
return_ticketccstring_and_show_subscribe(request.user, ticket)
|
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', {
|
return render(request, 'helpdesk/ticket.html', {
|
||||||
'ticket': ticket,
|
'ticket': ticket,
|
||||||
|
'submitter_userprofile_url': submitter_userprofile_url,
|
||||||
'form': form,
|
'form': form,
|
||||||
'active_users': users,
|
'active_users': users,
|
||||||
'priorities': Ticket.PRIORITY_CHOICES,
|
'priorities': Ticket.PRIORITY_CHOICES,
|
||||||
|
Loading…
Reference in New Issue
Block a user