feat(itim): Add ticket tab to services

shows related tickets

ref: #296 #309
This commit is contained in:
2024-09-21 13:12:28 +09:30
parent c74b89e0d6
commit 0e987088a3
3 changed files with 39 additions and 1 deletions

View File

@ -128,7 +128,12 @@ class DetailForm(ServiceForm):
]
}
]
}
},
"tickets": {
"name": "Tickets",
"slug": "tickets",
"sections": []
},
}

View File

@ -72,4 +72,31 @@
</div>
<div id="tickets" class="content-tab">
{% include 'content/section.html.j2' with tab=form.tabs.tickets %}
<table>
<thead>
<th>Name</th>
<th>Status</th>
<th>&nbsp</th>
</thead>
{% if tickets %}
{% for ticket in tickets %}
<tr>
<td>{% concat_strings "#" ticket.ticket.id as ticket_ref %}{{ ticket_ref | markdown | safe}}</td>
<td>{% include 'core/ticket/badge_ticket_status.html.j2' with ticket_status_text=ticket.ticket.get_status_display ticket_status=ticket.ticket.get_status_display|ticket_status %}</td>
<td>&nbsp;</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="3">No related tickets exist</td>
</tr>
{% endif %}
</table>
</div>
{% endblock %}

View File

@ -4,6 +4,7 @@ from django.utils.decorators import method_decorator
from core.forms.comment import AddNoteForm
from core.models.notes import Notes
from core.models.ticket.ticket_linked_items import Ticket, TicketLinkedItem
from core.views.common import AddView, ChangeView, DeleteView, IndexView
from itim.forms.services import ServiceForm, DetailForm
@ -151,6 +152,11 @@ class View(ChangeView):
context = super().get_context_data(**kwargs)
context['tickets'] = TicketLinkedItem.objects.filter(
item = int(self.kwargs['pk']),
item_type = TicketLinkedItem.Modules.SERVICE
)
context['notes_form'] = AddNoteForm(prefix='note')
context['notes'] = Notes.objects.filter(service=self.kwargs['pk'])