Skip to content

Commit

Permalink
Merge pull request #5798 from smithellis/1556-subject-and-description…
Browse files Browse the repository at this point in the history
…-fix

1556 - Subject and Description changes
  • Loading branch information
akatsoulas authored Dec 7, 2023
2 parents 7081a3f + 7125f10 commit 1fd5d58
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 2 additions & 3 deletions kitsune/customercare/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ def __init__(self, *args, product, user=None, **kwargs):
else:
self.fields["email"].initial = user.email
self.label_suffix = ""

if product.slug not in PRODUCTS_WITH_OS:
del self.fields["os"]

def send(self, user):
def send(self, user, product_config):
client = ZendeskClient()
return client.create_ticket(user, self.cleaned_data)
return client.create_ticket(user, self.cleaned_data, product_config)
9 changes: 6 additions & 3 deletions kitsune/customercare/zendesk.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from django.conf import settings
from django.utils.translation import gettext_lazy as _lazy
from zenpy import Zenpy
from zenpy.lib.api_objects import Identity as ZendeskIdentity
from zenpy.lib.api_objects import Ticket
from zenpy.lib.api_objects import User as ZendeskUser

NO_RESPONSE = _lazy("No response provided.")


class ZendeskClient(object):
"""Client to connect to Zendesk API."""
Expand Down Expand Up @@ -105,7 +108,7 @@ def update_primary_email(self, zendesk_user_id, email):
user=zendesk_user_id, identity=ZendeskIdentity(id=identity_id, value=email)
)

def create_ticket(self, user, ticket_fields):
def create_ticket(self, user, ticket_fields, product_config):
"""Create a ticket in Zendesk."""
custom_fields = [
{"id": settings.ZENDESK_PRODUCT_FIELD_ID, "value": ticket_fields.get("product")},
Expand All @@ -130,8 +133,8 @@ def create_ticket(self, user, ticket_fields):
]
)
ticket = Ticket(
subject=ticket_fields.get("subject") or ticket_fields.get("category"),
comment={"body": ticket_fields.get("description") or ticket_fields.get("category")},
subject=ticket_fields.get("subject") or f"{product_config['name']} support",
comment={"body": ticket_fields.get("description") or str(NO_RESPONSE)},
ticket_form_id=settings.ZENDESK_TICKET_FORM_ID,
custom_fields=custom_fields,
)
Expand Down
2 changes: 1 addition & 1 deletion kitsune/questions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def aaq(request, product_key=None, category_key=None, step=1, is_loginless=False

if zendesk_form.is_valid() and not is_ratelimited(request, "loginless", "3/d"):
try:
zendesk_form.send(request.user)
zendesk_form.send(request.user, product_config)
email = zendesk_form.cleaned_data["email"]
messages.add_message(
request,
Expand Down

0 comments on commit 1fd5d58

Please sign in to comment.