diff --git a/integrationtests/create_analysis.py b/integrationtests/create_analysis.py index 40abc07220d310e066f5c55fe0c896012c3f1d31..1b7aa0d2d6671f14a3c65cf5ed135dfecb0aa69c 100644 --- a/integrationtests/create_analysis.py +++ b/integrationtests/create_analysis.py @@ -52,9 +52,12 @@ def main(): ) da.add_property("date", "2020-01-01") da.add_property("identifier", "TEST") - da.add_property("responsible", db.execute_query( + only = db.execute_query( "FIND RECORD Person WITH firstname=Only", - unique=True)) + unique=True) + only.add_property(db.Property("Email").retrieve().id, "only@example.com") + only.update() + da.add_property("responsible", only) da.insert() diff --git a/src/caosadvancedtools/serverside/examples/example_script.py b/src/caosadvancedtools/serverside/examples/example_script.py index d06d25c9cfe204181445d7c229f656d93cfc7d7b..63d2bf9924593559b31467863bf5f613d56e5014 100755 --- a/src/caosadvancedtools/serverside/examples/example_script.py +++ b/src/caosadvancedtools/serverside/examples/example_script.py @@ -47,7 +47,7 @@ logger = logging.getLogger(__name__) guard.set_level(level=UPDATE) -def send_mail(self, changes): +def send_mail(self, changes, receipient): """ calls sendmail in order to send a mail to the curator about pending changes @@ -64,7 +64,7 @@ The following changes where done automatically. """.format(changes="\n".join(changes)) try: fro = caosdb_config["advancedtools"]["automated_updates.from_mail"] - to = caosdb_config["advancedtools"]["automated_updates.to_mail"] + to = receipient except KeyError: logger.error("Server Configuration is missing a setting for " "sending mails. The administrator should check " @@ -141,7 +141,12 @@ def main(args): ) if len(to_be_updated) > 0: - send_mail(to_be_updated) + people = db.execute_query("FIND RECORD Person WHICH IS REFERENCEED BY " + "{}".format(dataAnalysisRecord.id)) + for person in people: + if person.get_property("Email") is not None: + send_mail(to_be_updated, receipient=person.get_property( + "Email")) # TODO (must) what should be done with the old file? Removed if not referenced?