Kaynağa Gözat

Removed the ability to sort tasks by type

TonyKurts 6 ay önce
ebeveyn
işleme
a4d86ccd95

+ 0 - 1
models/ticket.py

@@ -77,7 +77,6 @@ class Ticket(models.Model):
 
     TICKET_TYPES_CHOICES = tuple((item[0], item[1]) for item in TICKET_TYPES)
     LIFE_CYCLE_DICT = dict((item[0], item[2]) for item in TICKET_TYPES)
-    TICKET_TYPES_DICT = dict(TICKET_TYPES_CHOICES)
 
     title = models.CharField(max_length=128)
     ticket_list = models.ForeignKey(TicketList, on_delete=models.CASCADE)

+ 6 - 48
templates/tickets/ticket_list_detail.html

@@ -83,22 +83,13 @@
   {% endif %}
   
   <hr>
-  {% if tickets %} 
-    <div class="d-flex flex-wrap gap-1">
-      {% for ticket_type in ticket_types %}
-        <input type="radio" class="btn-check ticket_type-filter" name="btnradio" id="{{ ticket_type }}-radio">
-        <label class="btn btn-outline-secondary" for="{{ ticket_type }}-radio">
-          {{ ticket_type }}
-        </label>
-      {% endfor %}
-    </div>
-    <hr>
-    
+  {% if tickets %}   
     <div class="overflow-x-scroll">
       <table class="table" id="tickettable">
         <thead>
           <tr class="nodrop">
             <th>ID</th>
+            <th>Type</th>
             <th>Title</th>
             <th class="text-nowrap">Created at</th>
             <th class="text-nowrap">Due on</th>
@@ -115,6 +106,9 @@
               <td>
                 {{ ticket.pk }}
               </td>
+              <td>
+                {{ ticket.get_ticket_type_display }}
+              </td>
               <td>
                 <a href="{% url 'tickets:ticket_detail' ticket.pk %}">{{ ticket.title|truncatechars:48 }}</a>
               </td>
@@ -145,40 +139,4 @@
   {% else %}
     <h4>There are no Tickets!</h4>
   {% endif %}
-{% endblock %}
-
-{% block extra_js %}
-  {% if tickets %}
-    <script>
-      let tickets = $(".ticket");
-      let filters = $(".ticket_type-filter");
-      
-      filters.on("click", function() {
-        localStorage.setItem("checked", this.id);
-        apply_filters();
-      });
-
-      function apply_filters() {
-        tickets.hide();
-    
-        let checkedFilterId = localStorage.getItem("checked");
-        let checkedFilterEl = document.getElementById(checkedFilterId);
-        if (checkedFilterEl) {
-          checkedFilterEl.checked = true;
-        } else {
-          filters[0].checked = true;
-          checkedFilterId = filters[0].id;
-        }
-
-        let ticket_type = checkedFilterId.split("-")[0];
-        let filteredtickets = tickets.filter(function() {
-          return $(this).data("ticket-type") === ticket_type;
-        });
-    
-        filteredtickets.show();
-      }
-
-      document.addEventListener("DOMContentLoaded", apply_filters);
-    </script>
-  {% endif %}
-{% endblock extra_js %}
+{% endblock %}

+ 1 - 2
views/ticket_list_detail.py

@@ -39,8 +39,7 @@ def ticket_list_detail(request, pk=None, my_tickets=False, assignments=False):
         "tickets": tickets,
         "form": form,
         "my_tickets": my_tickets,
-        "assignments": assignments,
-        "ticket_types": Ticket.TICKET_TYPES_DICT.values
+        "assignments": assignments
     }
 
     return render(request, "tickets/ticket_list_detail.html", context)