remove unused variables

This commit is contained in:
DavidVadnais 2025-03-24 08:37:09 -10:00
parent 232c4e2a2c
commit d7202b618e
9 changed files with 15 additions and 27 deletions

View File

@ -221,7 +221,7 @@ class EditTicketCustomFieldForm(EditTicketForm):
for field, value in self.cleaned_data.items(): for field, value in self.cleaned_data.items():
if field.startswith("custom_"): if field.startswith("custom_"):
if value != self.fields[field].initial: if value != self.fields[field].initial:
c = followup.ticketchange_set.create( followup.ticketchange_set.create(
field=field.replace("custom_", "", 1), field=field.replace("custom_", "", 1),
old_value=self.fields[field].initial, old_value=self.fields[field].initial,
new_value=value, new_value=value,

View File

@ -415,7 +415,7 @@ class UserTicketTest(APITestCase):
ticket_1 = Ticket.objects.create( ticket_1 = Ticket.objects.create(
queue=self.queue, title="Test 1", submitter_email="foo@example.com" queue=self.queue, title="Test 1", submitter_email="foo@example.com"
) )
ticket_2 = Ticket.objects.create( Ticket.objects.create(
queue=self.queue, title="Test 2", submitter_email="bar@example.com" queue=self.queue, title="Test 2", submitter_email="bar@example.com"
) )
ticket_3 = Ticket.objects.create( ticket_3 = Ticket.objects.create(
@ -432,10 +432,10 @@ class UserTicketTest(APITestCase):
staff_user = User.objects.create_user( staff_user = User.objects.create_user(
username="test2", is_staff=True, email="staff@example.com" username="test2", is_staff=True, email="staff@example.com"
) )
ticket_1 = Ticket.objects.create( Ticket.objects.create(
queue=self.queue, title="Test 1", submitter_email="staff@example.com" queue=self.queue, title="Test 1", submitter_email="staff@example.com"
) )
ticket_2 = Ticket.objects.create( Ticket.objects.create(
queue=self.queue, title="Test 2", submitter_email="foo@example.com" queue=self.queue, title="Test 2", submitter_email="foo@example.com"
) )
self.client.force_authenticate(staff_user) self.client.force_authenticate(staff_user)
@ -444,7 +444,7 @@ class UserTicketTest(APITestCase):
self.assertEqual(len(response.data["results"]), 1) self.assertEqual(len(response.data["results"]), 1)
def test_not_logged_in_user(self): def test_not_logged_in_user(self):
ticket_1 = Ticket.objects.create( Ticket.objects.create(
queue=self.queue, title="Test 1", submitter_email="ex@example.com" queue=self.queue, title="Test 1", submitter_email="ex@example.com"
) )
self.client.logout() self.client.logout()

View File

@ -148,7 +148,7 @@ class StaffUsersOnlyTestCase(StaffUserTestCaseMixin, TestCase):
""" """
user = self.non_staff_user user = self.non_staff_user
self.client.login(username=user.username, password=self.non_staff_user_password) self.client.login(username=user.username, password=self.non_staff_user_password)
queue = Queue.objects.create( Queue.objects.create(
title="Foo", title="Foo",
slug="test_queue", slug="test_queue",
) )
@ -217,7 +217,7 @@ class HomePageAnonymousUserTestCase(TestCase):
def test_homepage(self): def test_homepage(self):
helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT = True helpdesk_settings.HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT = True
response = self.client.get(reverse("helpdesk:home")) self.client.get(reverse("helpdesk:home"))
self.assertTemplateUsed("helpdesk/public_homepage.html") self.assertTemplateUsed("helpdesk/public_homepage.html")
def test_redirect_to_login(self): def test_redirect_to_login(self):

View File

@ -366,7 +366,7 @@ class TicketActionsTestCase(TestCase):
"comment": "first follow-up in new queue", "comment": "first follow-up in new queue",
"queue": str(new_queue.id), "queue": str(new_queue.id),
} }
response = self.client.post( self.client.post(
reverse("helpdesk:update", kwargs={"ticket_id": ticket_id}), post_data reverse("helpdesk:update", kwargs={"ticket_id": ticket_id}), post_data
) )

View File

@ -97,8 +97,6 @@ class TicketBasicsTestCase(TestCase):
self.assertIsNone(ticket.followup_set.first().user) self.assertIsNone(ticket.followup_set.first().user)
def test_create_ticket_public_with_hidden_fields(self): def test_create_ticket_public_with_hidden_fields(self):
email_count = len(mail.outbox)
response = self.client.get(reverse("helpdesk:home")) response = self.client.get(reverse("helpdesk:home"))
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
@ -503,8 +501,6 @@ class EmailInteractionsTestCase(TestCase):
msg.__setitem__("Content-Type", "text/plain;") msg.__setitem__("Content-Type", "text/plain;")
msg.set_payload(self.ticket_data["description"]) msg.set_payload(self.ticket_data["description"])
email_count = len(mail.outbox)
extract_email_metadata(str(msg), self.queue_public, logger=logger) extract_email_metadata(str(msg), self.queue_public, logger=logger)
followup = FollowUp.objects.get(message_id=message_id) followup = FollowUp.objects.get(message_id=message_id)
@ -595,8 +591,6 @@ class EmailInteractionsTestCase(TestCase):
msg.__setitem__("Content-Type", "text/plain;") msg.__setitem__("Content-Type", "text/plain;")
msg.set_payload(self.ticket_data["description"]) msg.set_payload(self.ticket_data["description"])
email_count = len(mail.outbox)
extract_email_metadata(str(msg), self.queue_public, logger=logger) extract_email_metadata(str(msg), self.queue_public, logger=logger)
followup = FollowUp.objects.get(message_id=message_id) followup = FollowUp.objects.get(message_id=message_id)
@ -1044,8 +1038,6 @@ class EmailInteractionsTestCase(TestCase):
msg.__setitem__("Content-Type", "text/plain;") msg.__setitem__("Content-Type", "text/plain;")
msg.set_payload(self.ticket_data["description"]) msg.set_payload(self.ticket_data["description"])
email_count = len(mail.outbox)
extract_email_metadata(str(msg), self.queue_public, logger=logger) extract_email_metadata(str(msg), self.queue_public, logger=logger)
followup = FollowUp.objects.get(message_id=message_id) followup = FollowUp.objects.get(message_id=message_id)

View File

@ -428,7 +428,7 @@ class TimeSpentAutoTestCase(TestCase):
"comment": "ticket in queue {}".format(queue), "comment": "ticket in queue {}".format(queue),
"queue": queues[queue].id, "queue": queues[queue].id,
} }
response = self.client.post( self.client.post(
reverse("helpdesk:update", kwargs={"ticket_id": ticket.id}), post_data reverse("helpdesk:update", kwargs={"ticket_id": ticket.id}), post_data
) )
latest_fup = ticket.followup_set.latest("id") latest_fup = ticket.followup_set.latest("id")

View File

@ -270,9 +270,6 @@ class WebhookTest(APITestCase):
self.assertEqual(len(handled_webhook_requests["follow_up_requests"]), 0) self.assertEqual(len(handled_webhook_requests["follow_up_requests"]), 0)
ticket_id = handled_webhook_requests["new_ticket_requests"][-1]["ticket"]["id"] ticket_id = handled_webhook_requests["new_ticket_requests"][-1]["ticket"]["id"]
from .. import models
ticket = models.Ticket.objects.get(id=ticket_id)
payload = { payload = {
"body": "hello", "body": "hello",

View File

@ -272,7 +272,7 @@ def update_ticket(
files = process_attachments(f, files) if files else [] files = process_attachments(f, files) if files else []
if title and title != ticket.title: if title and title != ticket.title:
c = f.ticketchange_set.create( f.ticketchange_set.create(
field=_("Title"), field=_("Title"),
old_value=ticket.title, old_value=ticket.title,
new_value=title, new_value=title,
@ -280,21 +280,21 @@ def update_ticket(
ticket.title = title ticket.title = title
if new_status != old_status: if new_status != old_status:
c = f.ticketchange_set.create( f.ticketchange_set.create(
field=_("Status"), field=_("Status"),
old_value=old_status_str, old_value=old_status_str,
new_value=ticket.get_status_display(), new_value=ticket.get_status_display(),
) )
if ticket.assigned_to != old_owner: if ticket.assigned_to != old_owner:
c = f.ticketchange_set.create( f.ticketchange_set.create(
field=_("Owner"), field=_("Owner"),
old_value=old_owner, old_value=old_owner,
new_value=ticket.assigned_to, new_value=ticket.assigned_to,
) )
if priority != ticket.priority: if priority != ticket.priority:
c = f.ticketchange_set.create( f.ticketchange_set.create(
field=_("Priority"), field=_("Priority"),
old_value=ticket.priority, old_value=ticket.priority,
new_value=priority, new_value=priority,
@ -302,7 +302,7 @@ def update_ticket(
ticket.priority = priority ticket.priority = priority
if queue != ticket.queue.id: if queue != ticket.queue.id:
c = f.ticketchange_set.create( f.ticketchange_set.create(
field=_("Queue"), field=_("Queue"),
old_value=ticket.queue.id, old_value=ticket.queue.id,
new_value=queue, new_value=queue,
@ -310,7 +310,7 @@ def update_ticket(
ticket.queue_id = queue ticket.queue_id = queue
if due_date != ticket.due_date: if due_date != ticket.due_date:
c = f.ticketchange_set.create( f.ticketchange_set.create(
field=_("Due on"), field=_("Due on"),
old_value=ticket.due_date, old_value=ticket.due_date,
new_value=due_date, new_value=due_date,

View File

@ -637,7 +637,6 @@ def update_ticket_view(request, ticket_id, public=False):
if new_checklist != old_completed: if new_checklist != old_completed:
changes_in_checklists = True changes_in_checklists = True
time_spent = get_time_spent_from_request(request)
# NOTE: jQuery's default for dates is mm/dd/yy # NOTE: jQuery's default for dates is mm/dd/yy
# very US-centric but for now that's the only format supported # very US-centric but for now that's the only format supported
# until we clean up code to internationalize a little more # until we clean up code to internationalize a little more