Skip to content

Commit

Permalink
fix(User): append base role before validation
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Sep 26, 2024
1 parent aeac5af commit b15d5a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions landa/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@
"on_trash": "landa.address_and_contact.on_trash",
},
"User": {
"before_validate": "landa.organization_management.user.user.before_validate",
"validate": "landa.organization_management.user.user.validate",
"after_insert": "landa.organization_management.user.user.after_insert",
"on_update": "landa.organization_management.user.user.on_update",
Expand Down
7 changes: 5 additions & 2 deletions landa/organization_management/user/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
from landa.utils import delete_records_linked_to, get_default_company, remove_from_table


def before_validate(doc: User, event=None):
if doc.landa_member and doc.enabled and doc.name not in STANDARD_USERS:
doc.append_roles("LANDA Member")


def validate(doc: User, event=None):
if (not doc.enabled) or (doc.name in STANDARD_USERS):
return

doc.append_roles("LANDA Member")

if doc.landa_member:
existing_user = frappe.db.exists(
"User",
Expand Down

0 comments on commit b15d5a1

Please sign in to comment.