Compare commits

...

7 Commits

Author SHA1 Message Date
Saqib Ansari
db5b0cf638 chore: move devDependencies to dependencies 2024-02-02 13:09:16 +05:30
Suhail
6abdc36913 fix(install-script): create fallback ticket types earlier (#1615) 2023-10-30 20:33:08 +05:30
Sabu Siyad
e591111b1f chore: ticket: move first response logic 2023-10-12 08:06:35 +00:00
Sabu Siyad
e9500fd648 fix: knowledge base: scroll 2023-10-12 08:06:20 +00:00
Sabu Siyad
fd723793e6 fix: tickets: perms: allow if owner (#1595) 2023-10-12 08:06:11 +00:00
Sabu Siyad
8adbf67e0a chore: hooks: use on_communication_update (#1594) 2023-10-12 08:05:59 +00:00
Dany Robert
771c3af6fb fix: unable to view ticket if no assignee 2023-10-12 08:05:48 +00:00
8 changed files with 34 additions and 46 deletions

View File

@@ -34,9 +34,7 @@
"vue-echarts": "^6.5.4",
"vue-router": "^4.1.6",
"vuedraggable": "^4.1.0",
"zod": "^3.21.4"
},
"devDependencies": {
"zod": "^3.21.4",
"@iconify-json/lucide": "^1.1.99",
"@iconify-json/ph": "^1.1.5",
"@iconify/vue": "^4.1.1",

View File

@@ -1,5 +1,5 @@
<template>
<div class="flex flex-col overflow-hidden">
<div class="flex h-full flex-col overflow-hidden">
<PageTitle v-if="!route.meta.public">
<template #title>
<BreadCrumbs

View File

@@ -84,7 +84,7 @@ def get_customer_criteria():
def get_assignee(_assign: str):
j = frappe.parse_json(_assign)
if len(j) < 1:
if not j or len(j) < 1:
return
return get_user_info_for_avatar(j.pop())

View File

@@ -165,7 +165,6 @@ class HDTicket(Document):
self.set_contact()
self.set_customer()
self.set_priority()
self.set_first_responded_on()
self.set_feedback_values()
self.apply_escalation_rule()
self.set_sla()
@@ -224,10 +223,6 @@ class HDTicket(Document):
or DEFAULT_TICKET_PRIORITY
)
def set_first_responded_on(self):
if self.status == "Replied" and not self.first_responded_on:
self.first_responded_on = frappe.utils.now_datetime()
def set_feedback_values(self):
if not self.feedback:
return
@@ -714,12 +709,33 @@ class HDTicket(Document):
sla = frappe.get_doc("HD Service Level Agreement", self.sla)
sla.apply(self)
# `on_communication_update` is a special method exposed from `Communication` doctype.
# It is called when a communication is updated. Beware of changes as this effectively
# is an external dependency. Refer `communication.py` of Frappe framework for more.
# Since this is called from communication itself, `c` is the communication doc.
def on_communication_update(self, c):
if c.sent_or_received == "Sent":
# If communication is outgoing, then it is a reply from agent.
self.status = "Replied"
# Set first response time. This must be set only once
self.first_responded_on = (
self.first_responded_on or frappe.utils.now_datetime()
)
# Fetch description from communication if not set already. This might not be needed
# anymore as a communication is created when a ticket is created.
self.description = self.description or c.content
# Save the ticket, allowing for hooks to run.
self.save()
def has_permission(doc):
user = frappe.session.user
customer = get_customer(user)
is_customer = doc.customer == customer
is_contact = doc.contact == user
is_raised = doc.raised_by == user
has_extra_permissions = is_customer or is_contact or is_raised or is_agent()
return has_extra_permissions
# Check if `user` has access to this specific ticket (`doc`). This implements extra
# permission checks which is not possible with standard permission system. This function
# is being called from hooks. `doc` is the ticket to check against
def has_permission(doc, user=None):
return (
doc.contact == user
or doc.raised_by == user
or doc.owner == user
or doc.customer == get_customer(user)
or is_agent(user)
)

View File

@@ -1,23 +0,0 @@
import frappe
from helpdesk.utils import publish_event
def after_insert(c, method=None):
# DocType against which the communication is created. We only want those
# which related to Helpdesk
if not c.reference_doctype == "HD Ticket":
return
# Skip if doc is not mentioned
if not c.reference_name:
return
t = frappe.get_last_doc("HD Ticket", {"name": c.reference_name})
if not t.description and not t.via_customer_portal:
t.description = c.content
t.save()
event = "helpdesk:new-communication"
data = {"ticket_id": c.reference_name}
publish_event(event, data)

View File

@@ -18,9 +18,6 @@ website_route_rules = [
]
doc_events = {
"Communication": {
"after_insert": "helpdesk.helpdesk.hooks.communication.after_insert",
},
"Contact": {
"before_insert": "helpdesk.helpdesk.hooks.contact.before_insert",
},

View File

@@ -15,6 +15,7 @@ def before_install():
def after_install():
create_fallback_ticket_type()
add_default_categories_and_articles()
add_default_ticket_priorities()
add_default_sla()
@@ -23,7 +24,6 @@ def after_install():
add_default_assignment_rule()
add_system_preset_filters()
create_default_template()
create_fallback_ticket_type()
create_helpdesk_folder()
create_ootb_ticket_types()
create_welcome_ticket()

View File

@@ -5,7 +5,7 @@
"dev": "cd desk && yarn dev",
"build": "cd desk && yarn build"
},
"devDependencies": {
"dependencies": {
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"eslint": "^8.36.0",