Skip to content

Commit

Permalink
fix(Member Data Import): validate that Address belongs to LANDA Member
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Jan 16, 2025
1 parent 8ddd3f7 commit b132ba0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from datetime import datetime

import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils.dateutils import parse_date

Expand Down Expand Up @@ -31,6 +32,21 @@ class MemberDataImport(Document):

ADDRESS_FIELDS = ["address_line1", "pincode", "city"]

def validate(self):
if self.address_name and not self.member:
frappe.throw(_("Please set the corresponding LANDA Member"))

if self.address_name and not frappe.db.exists(
"Dynamic Link",
{
"link_doctype": "LANDA Member",
"link_name": self.member,
"parenttype": "Address",
"parent": self.address_name,
},
):
frappe.throw(_("The selected address does not belong to the selected LANDA Member"))

def before_insert(self, *args, **kwargs):
self.preprocess()

Expand Down
1 change: 1 addition & 0 deletions landa/translations/de.csv
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,4 @@ Group By Fish Species,Nach Fischart gruppieren,
Member of,Mitglied von,
Permissions for,Berechtigungen für,
Please set the corresponding LANDA Member,Bitte tragen Sie das entsprechende Mitglied ein,
The selected address does not belong to the selected LANDA Member,Die ausgewählte Adresse gehört nicht zum ausgewählten Mitglied,

0 comments on commit b132ba0

Please sign in to comment.