-
+
+ + {% endblock content %} {% block javascripts %} From 77dc45044bfe279fd378c5621d0a9aeeed8bb9c9 Mon Sep 17 00:00:00 2001 From: corbz Date: Wed, 17 Jan 2024 21:54:35 +0000 Subject: [PATCH 043/103] moved fixtures into app folders --- .../fixtures}/defaultuser.json | 0 .../fixtures}/department.json | 0 apps/fixtures/home/ticketpriority.json | 38 ------------------- .../fixtures}/defaulttickets.json | 0 .../home => home/fixtures}/newtickets.json | 0 apps/home/fixtures/ticketpriority.json | 38 +++++++++++++++++++ .../home => home/fixtures}/tickettag.json | 0 scripts/fixtures.sh | 12 +++--- 8 files changed, 44 insertions(+), 44 deletions(-) rename apps/{fixtures/authentication => authentication/fixtures}/defaultuser.json (100%) rename apps/{fixtures/authentication => authentication/fixtures}/department.json (100%) delete mode 100644 apps/fixtures/home/ticketpriority.json rename apps/{fixtures/home => home/fixtures}/defaulttickets.json (100%) rename apps/{fixtures/home => home/fixtures}/newtickets.json (100%) create mode 100644 apps/home/fixtures/ticketpriority.json rename apps/{fixtures/home => home/fixtures}/tickettag.json (100%) diff --git a/apps/fixtures/authentication/defaultuser.json b/apps/authentication/fixtures/defaultuser.json similarity index 100% rename from apps/fixtures/authentication/defaultuser.json rename to apps/authentication/fixtures/defaultuser.json diff --git a/apps/fixtures/authentication/department.json b/apps/authentication/fixtures/department.json similarity index 100% rename from apps/fixtures/authentication/department.json rename to apps/authentication/fixtures/department.json diff --git a/apps/fixtures/home/ticketpriority.json b/apps/fixtures/home/ticketpriority.json deleted file mode 100644 index 5bd38d4..0000000 --- a/apps/fixtures/home/ticketpriority.json +++ /dev/null @@ -1,38 +0,0 @@ -[ -{ - "model": "home.ticketpriority", - "pk": "0ebc194c-b856-4e4f-9def-cd190d1e8d43", - "fields": { - "title": "Low", - "colour": "#388e3c", - "backgroundcolour": "#e8f5e9" - } -}, -{ - "model": "home.ticketpriority", - "pk": "a680328f-0680-456c-8e26-f594e05989ad", - "fields": { - "title": "High", - "colour": "#ef6c00", - "backgroundcolour": "#ffe0b2" - } -}, -{ - "model": "home.ticketpriority", - "pk": "d140a5be-cf24-4250-8b38-31338e69dffd", - "fields": { - "title": "Urgent", - "colour": "#c62828", - "backgroundcolour": "#ffcdd2" - } -}, -{ - "model": "home.ticketpriority", - "pk": "e79687c6-9054-4706-b9a2-34afccfaa7c8", - "fields": { - "title": "Normal", - "colour": "#2e7d32", - "backgroundcolour": "#c8e6c9" - } -} -] diff --git a/apps/fixtures/home/defaulttickets.json b/apps/home/fixtures/defaulttickets.json similarity index 100% rename from apps/fixtures/home/defaulttickets.json rename to apps/home/fixtures/defaulttickets.json diff --git a/apps/fixtures/home/newtickets.json b/apps/home/fixtures/newtickets.json similarity index 100% rename from apps/fixtures/home/newtickets.json rename to apps/home/fixtures/newtickets.json diff --git a/apps/home/fixtures/ticketpriority.json b/apps/home/fixtures/ticketpriority.json new file mode 100644 index 0000000..5b1a940 --- /dev/null +++ b/apps/home/fixtures/ticketpriority.json @@ -0,0 +1,38 @@ +[ + { + "model": "home.ticketpriority", + "pk": "d140a5be-cf24-4250-8b38-31338e69dffd", + "fields": { + "title": "Urgent", + "colour": "#c62828", + "backgroundcolour": "#ffcdd2" + } + }, + { + "model": "home.ticketpriority", + "pk": "a680328f-0680-456c-8e26-f594e05989ad", + "fields": { + "title": "High", + "colour": "#ef6c00", + "backgroundcolour": "#ffe0b2" + } + }, + { + "model": "home.ticketpriority", + "pk": "e79687c6-9054-4706-b9a2-34afccfaa7c8", + "fields": { + "title": "Normal", + "colour": "#2e7d32", + "backgroundcolour": "#c8e6c9" + } + }, + { + "model": "home.ticketpriority", + "pk": "0ebc194c-b856-4e4f-9def-cd190d1e8d43", + "fields": { + "title": "Low", + "colour": "#388e3c", + "backgroundcolour": "#e8f5e9" + } + } +] diff --git a/apps/fixtures/home/tickettag.json b/apps/home/fixtures/tickettag.json similarity index 100% rename from apps/fixtures/home/tickettag.json rename to apps/home/fixtures/tickettag.json diff --git a/scripts/fixtures.sh b/scripts/fixtures.sh index 602df4f..b5662d0 100755 --- a/scripts/fixtures.sh +++ b/scripts/fixtures.sh @@ -1,19 +1,19 @@ echo migrating python manage.py migrate -echo installing departments -python manage.py loaddata apps/fixtures/authentication/department.json +echo installing authentication fixtures +python manage.py loaddata apps/authentication/fixtures/department.json echo installing default users -python manage.py loaddata apps/fixtures/authentication/defaultuser.json +python manage.py loaddata apps/authentication/fixtures/defaultuser.json echo installing ticket priorities -python manage.py loaddata apps/fixtures/home/ticketpriority.json +python manage.py loaddata apps/home/fixtures/ticketpriority.json echo installing ticket tags -python manage.py loaddata apps/fixtures/home/tickettag.json +python manage.py loaddata apps/home/fixtures/tickettag.json echo installing default tickets -python manage.py loaddata apps/fixtures/home/defaulttickets.json +python manage.py loaddata apps/home/fixtures/newtickets.json echo all done! \ No newline at end of file From aa1ef52694b82cb5ea884ecd239fb7c129d6b0cc Mon Sep 17 00:00:00 2001 From: corbz Date: Wed, 17 Jan 2024 21:54:54 +0000 Subject: [PATCH 044/103] integrate API changes into frontend --- apps/api/views.py | 2 +- apps/static/assets/js/tickets.js | 57 ++++++++++++-------------------- apps/templates/home/tickets.html | 14 ++++---- 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/apps/api/views.py b/apps/api/views.py index 5ede093..da7c2a7 100644 --- a/apps/api/views.py +++ b/apps/api/views.py @@ -51,7 +51,7 @@ class TicketListApiView(generics.ListAPIView): queryset = Ticket.objects.all() filter_backends = [filters.SearchFilter, rest_filters.DjangoFilterBackend, filters.OrderingFilter] - filterset_fields = ["priority", "tags", "author"] + filterset_fields = ["uuid", "priority", "tags", "author", "author__department"] search_fields = ["author__forename", "author__surname", "title", "description"] ordering_fields = ["create_timestamp", "edit_timestamp"] diff --git a/apps/static/assets/js/tickets.js b/apps/static/assets/js/tickets.js index 6c8e3c7..1bc442b 100644 --- a/apps/static/assets/js/tickets.js +++ b/apps/static/assets/js/tickets.js @@ -49,7 +49,7 @@ $(document).ready(function() { }) setupFilter("#filterSidebar .filter-department", "author__department"); - setupFilter("#filterSidebar .filter-tag", "tags__in"); + setupFilter("#filterSidebar .filter-tag", "tags"); setupFilter("#filterSidebar .filter-priority", "priority"); loadFilterCounts(); @@ -81,7 +81,12 @@ function setupFilter(selector, key) { } } else if (input.is(":radio") && input.is(":checked")) { - filters[key] = [uuid]; + if (uuid === "all") { + delete filters[key]; + } + else { + filters[key] = [uuid]; + } } console.debug(`Filter applied '${key}' as '${uuid}'`) @@ -210,18 +215,18 @@ function loadAllTickets() { url: URL_Tickets, type: "GET", dataType: "json", - data: filters, + data: $.param(filters, true), success: function(data) { loadingTickets = false; console.log(JSON.stringify(data, null, 4)) - $("#ticketCounts .current").text(data.length); + $("#ticketCounts .current").text(data.results.length); $("#ticketsContainer .loading").hide(); - if (data.length === 0) $("#ticketsContainer .none-found").show(); + if (data.results.length === 0) $("#ticketsContainer .none-found").show(); else $("#ticketsContainer .none-found").hide(); - data.forEach(function(ticket) { + data.results.forEach(function(ticket) { var timestamp = new Date(ticket.timestamp); var formattedTime = timestampToHumanDate(timestamp, ticket.was_yesterday); @@ -229,31 +234,15 @@ function loadAllTickets() { formattedTime += " • edited"; } - var item = $(` - - `); - var template = $("#ticketItemTemplate").copy(); + var template = $($("#ticketItemTemplate").html()); + template.find(".ticket-item-author").text(`${ticket.author.forename} ${ticket.author.surname}`); + template.find(".ticket-item-datetime").text(formattedTime); + template.find(".ticket-item-title").text(ticket.title); + template.find(".ticket-item-desc").text(ticket.description); template.find(".ticket-item-icon").attr("src", ticket.author.icon); - template.find(".ticket-item-author").text(ticket.author.forename + " " + ticket.author.surname); + template.attr("data-uuid", ticket.uuid); - - $("#ticketsContainer .content").append(item); + $("#ticketsContainer .content").append(template); }); applyTicketClickFunction(); @@ -267,7 +256,7 @@ function loadAllTickets() { } function applyTicketClickFunction() { - $(".email-list-item").on("click", function(e) { + $(".ticket-item").on("click", function(e) { e.preventDefault(); displayTicket(this); $('.email-app').removeClass('side-active'); @@ -301,7 +290,7 @@ function changeTicket(next=true) { function displayTicket(ticketElement) { ticket = $(ticketElement); - ticketID = ticket.data("ticket-id"); + ticketID = ticket.data("uuid"); // $(".back-to-mailbox").off("click").on("click", function(event) { // event.preventDefault(); @@ -334,13 +323,11 @@ function displayTicket(ticketElement) { url: URL_Tickets, type: 'get', dataType: 'json', - data: { - uuid__in: [ticketID] - }, + data: $.param({uuid: ticketID}, true), success: function (data) { console.log(JSON.stringify(data, null, 4)); - var ticket = data[0]; + var ticket = data.results[0]; var author = ticket.author; var department = author.department; var priority = ticket.priority; diff --git a/apps/templates/home/tickets.html b/apps/templates/home/tickets.html index 9fc4eb1..e79967c 100644 --- a/apps/templates/home/tickets.html +++ b/apps/templates/home/tickets.html @@ -422,8 +422,12 @@
-