1
0

ticket_detail.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. {% extends "tickets/base.html" %}
  2. {% load static %}
  3. {% block content %}
  4. <h3 class="card-title fw-bold my-3">{{ ticket.title }}</h3>
  5. <div class="row">
  6. <div class="col-12 col-md-8 mb-2 mb-md-0">
  7. <div class="card h-100">
  8. <div class="card-body">
  9. {% if ticket.note %}
  10. <div class="card-text overflow-auto">{{ ticket.note|safe|urlize|linebreaks }}</div>
  11. {% endif %}
  12. </div>
  13. </div>
  14. </div>
  15. <div class="col-12 col-md-4">
  16. <div class="card">
  17. <ul class="list-group list-group-flush">
  18. <li class="list-group-item">
  19. <strong>In list:</strong>
  20. <a href="{% url 'tickets:ticket_list_detail' ticket.ticket_list.pk %}">
  21. {{ ticket.ticket_list }}
  22. </a>
  23. </li>
  24. <li class="list-group-item">
  25. <strong>Created by:</strong>
  26. {{ ticket.created_by.username }}
  27. </li>
  28. <li class="list-group-item">
  29. <strong>Assigned to:</strong>
  30. {% if ticket.assigned_to.username %}{{ ticket.assigned_to.username }}{% else %}Anyone{% endif %}
  31. </li>
  32. <li class="list-group-item">
  33. <strong>Type:</strong>
  34. {{ ticket.get_ticket_type_display }}
  35. </li>
  36. <li class="list-group-item">
  37. <strong>Status:</strong>
  38. {{ ticket.get_status_display }}
  39. </li>
  40. <li class="list-group-item">
  41. <strong>Priority:</strong>
  42. {{ ticket.priority }}
  43. </li>
  44. <li class="list-group-item">
  45. <strong>Created at:</strong>
  46. {{ ticket.created_at }}
  47. </li>
  48. <li class="list-group-item">
  49. <strong>Due date:</strong>
  50. {{ ticket.due_date }}
  51. </li>
  52. <li class="list-group-item">
  53. <strong>Updated at:</strong>
  54. {{ ticket.updated_at }}
  55. </li>
  56. </ul>
  57. </div>
  58. {% if available_statuses %}
  59. <form class="my-3" method="POST">
  60. {% csrf_token %}
  61. <label for="select-ticket-status" class="form-label">Available statuses</label>
  62. <div class="input-group">
  63. <select class="form-select" id="select-ticket-status" name="ticket-status">
  64. {% for status in available_statuses %}
  65. <option {% if forloop.first %}selected{% endif %} value="{{ status.0 }}">{{ status.1 }}</option>
  66. {% endfor %}
  67. </select>
  68. <button class="btn btn-outline-secondary" type="submit">Change</button>
  69. </div>
  70. </form>
  71. {% else %}
  72. <p class="my-3">No available statuses</p>
  73. {% endif %}
  74. {% if ticket.created_by == user %}
  75. <div class="d-flex justify-content-between">
  76. <button type="button" data-bs-toggle="modal" data-bs-target="#ticket-edit-modal" class="btn btn-primary">
  77. <i class="fa-solid fa-pen-to-square pe-1"></i>
  78. Edit Ticket
  79. </button>
  80. <button type="button" class="btn btn-outline-danger" data-bs-toggle="modal" data-bs-target="#ticket-delete-modal">
  81. <i class="fa-solid fa-trash-can"></i>
  82. </button>
  83. </div>
  84. <!--Ticket edit modal-->
  85. <div class="modal fade" id="ticket-edit-modal" tabindex="-1">
  86. <div class="modal-dialog modal-dialog-centered">
  87. <div class="modal-content">
  88. <div class="modal-header">
  89. <h1 class="modal-title fs-5">
  90. <i class="fa-solid fa-pen-to-square pe-1"></i>
  91. Edit Ticket
  92. </div>
  93. <div class="modal-body">
  94. <form id="ticket-create-form" action="{% url 'tickets:ticket_edit' ticket.pk %}" method="post">
  95. {% include 'tickets/include/form.html' %}
  96. </form>
  97. </div>
  98. <div class="modal-footer">
  99. <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
  100. <i class="fa-solid fa-xmark pe-1"></i>
  101. Close
  102. </button>
  103. <button class="btn btn-primary" type="submit" form="ticket-create-form">
  104. <i class="fa-solid fa-check pe-1"></i>
  105. Confirm
  106. </button>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. <!--ticket delete modal-->
  112. <div class="modal fade" id="ticket-delete-modal" tabindex="-1">
  113. <div class="modal-dialog modal-dialog-centered">
  114. <div class="modal-content">
  115. <div class="modal-header">
  116. <h1 class="modal-title fs-5">
  117. <i class="fa-solid fa-trash-can pe-1"></i>
  118. Delete Ticket
  119. </h1>
  120. </div>
  121. <div class="modal-body">
  122. Are you sure you want to delete the ticket "{{ ticket.title }}"?
  123. </div>
  124. <div class="modal-footer">
  125. <button type="button" class="btn btn-primary" data-bs-dismiss="modal">
  126. <i class="fa-solid fa-xmark pe-1"></i>
  127. Close
  128. </button>
  129. <form method="post" action="{% url "tickets:ticket_delete" ticket.pk %}">
  130. {% csrf_token %}
  131. <button class="btn btn-outline-danger" type="submit">
  132. <i class="fa-solid fa-check pe-1"></i>
  133. Confirm
  134. </button>
  135. </form>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. {% endif %}
  141. </div>
  142. </div>
  143. <!--Attachments block-->
  144. <h4 class="mt-4">Attachments</h4>
  145. {% if ticket.attachment_set.count %}
  146. <div class="table-responsive">
  147. <table class="table mb-3">
  148. <thead>
  149. <tr>
  150. <th>File</th>
  151. <th>Uploaded</th>
  152. <th>By</th>
  153. <th>Remove</th>
  154. </tr>
  155. </thead>
  156. <tbody>
  157. {% for attachment in attachments %}
  158. <tr>
  159. <td><a href="{{ attachment.file.url }}">{{ attachment.filename }}</a></td>
  160. <td>{{ attachment.timestamp }}</td>
  161. <td>{{ attachment.added_by.username }}</td>
  162. <td>
  163. {% if attachment.added_by == user or ticket.created_by == user %}
  164. <form action="{% url "tickets:remove_attachment" attachment.id %}" method="POST">
  165. {% csrf_token %}
  166. <button type="submit" class="btn btn-danger btn-sm">
  167. <i class="fa-solid fa-xmark"></i>
  168. </button>
  169. </form>
  170. {% endif %}
  171. </td>
  172. </tr>
  173. {% endfor %}
  174. </tbody>
  175. </table>
  176. </div>
  177. {% endif %}
  178. <form method="post" enctype="multipart/form-data">
  179. {% csrf_token %}
  180. <div class="input-group">
  181. <input type="file" class="form-control" id="attachment_file_input" name="attachment_file_input">
  182. <button class="btn btn-primary">
  183. <i class="fa-solid fa-upload pe-1"></i>
  184. Upload
  185. </button>
  186. </div>
  187. </form>
  188. <!--Discussion block-->
  189. <h4 class="mt-4">Discussion</h4>
  190. <form class="mb-3" method="post">
  191. {% csrf_token %}
  192. <textarea class="form-control" name="comment-body" rows="2" placeholder="Write your comment here" required></textarea>
  193. <div class="d-flex justify-content-end">
  194. <button class="btn btn-primary mt-2" type="submit">
  195. <i class="fa-solid fa-paper-plane pe-1"></i>
  196. Post
  197. </button>
  198. </div>
  199. </form>
  200. {% if comment_list %}
  201. {% for comment in comment_list %}
  202. <div class="card mb-2 bg-body-secondary">
  203. <div class="card-body">
  204. <h5>{{ comment.author_username }}</h5>
  205. {{ comment.body|safe|urlize|linebreaks }}
  206. <div class="text-body-secondary d-flex justify-content-between">
  207. <small>{{ comment.author_email }}</small>
  208. <small>{{ comment.date }}</small>
  209. </div>
  210. </div>
  211. </div>
  212. {% endfor %}
  213. {% endif %}
  214. {% endblock %}
  215. {% block extra_js %}
  216. <script>
  217. // Support file attachment uploader
  218. $('#attachment_file_input').on('change',function(){
  219. // Get the file name and remove browser-added "fakepath."
  220. // Then replace the "Choose a file" label.
  221. var fileName = $(this).val().replace('C:\\fakepath\\', " ");
  222. $(this).next('.custom-file-label').html(fileName);
  223. })
  224. </script>
  225. {% endblock extra_js %}