Skip to content

Commit

Permalink
Merge pull request frappe#1519 from ssiyad/fix/ticket/perms
Browse files Browse the repository at this point in the history
fix: ticket: perms
  • Loading branch information
ssiyad authored Aug 22, 2023
2 parents 4686b38 + 326b620 commit 8bf4743
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions helpdesk/helpdesk/doctype/hd_ticket/hd_ticket.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import json
from datetime import timedelta
from email.utils import parseaddr
from functools import lru_cache
from typing import List

import frappe
from frappe import _
from frappe.core.utils import get_parent_doc
from frappe.desk.form.assign_to import add as assign
from frappe.desk.form.assign_to import clear as clear_all_assignments
from frappe.model.document import Document
from frappe.query_builder import Case, DocType, Order
from frappe.utils import date_diff, get_datetime, now_datetime, time_diff_in_seconds
from pypika.functions import Count
from pypika.queries import Query
from pypika.terms import Criterion
Expand Down Expand Up @@ -139,6 +136,17 @@ def by_priority(query: Query, direction: Order):
"Last modified on": "modified",
}

def has_permission(self, perm):
has_standard_permissions = super().has_permission(perm)
user = frappe.session.user
customer = get_customer(user)
user_is_agent = is_agent()
is_customer = self.customer == customer
is_contact = self.contact == user
is_raised = self.raised_by == user
has_extra_permissions = user_is_agent or is_customer or is_contact or is_raised
return has_standard_permissions and has_extra_permissions

def publish_update(self):
publish_event("helpdesk:ticket-update", {"name": self.name})
capture_event("ticket_updated")
Expand Down

0 comments on commit 8bf4743

Please sign in to comment.