Skip to content

Commit

Permalink
fix(UX): Nudge to disable user instead of deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Mar 6, 2024
1 parent 072c2a1 commit 081be53
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions frappe/core/doctype/user/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
toggle_notifications,
)
from frappe.desk.notifications import clear_notifications
from frappe.model.delete_doc import check_if_doc_is_linked
from frappe.model.document import Document
from frappe.query_builder import DocType
from frappe.rate_limiter import rate_limit
Expand Down Expand Up @@ -590,6 +591,12 @@ def on_trash(self):
# Delete EPS data
frappe.db.delete("Energy Point Log", {"user": self.name})

# Ask user to disable instead if document is still linked
try:
check_if_doc_is_linked(self)
except frappe.LinkExistsError:
frappe.throw(_("You can disable the user instead of deleting it."), frappe.LinkExistsError)

def before_rename(self, old_name, new_name, merge=False):
frappe.clear_cache(user=old_name)
self.validate_rename(old_name, new_name)
Expand Down

0 comments on commit 081be53

Please sign in to comment.