Commit 8b173d92 authored by Jérome Perrin's avatar Jérome Perrin

Only send notifications if the recipient have an email address and is a user in the system.

Add some missing /view in URLs included in messages.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21597 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2595ae93
......@@ -72,7 +72,13 @@ source_person = task_report.getSourceValue(portal_type="Person")\n
destination_decision_person = task_report.getDestinationDecisionValue(portal_type="Person")\n
if destination_decision_person is None:\n
destination_decision_person = task_report.getDestinationValue(portal_type="Person")\n
if source_person is not None and destination_decision_person is not None:\n
\n
# We send a message only if the requester have an email and is a user in the\n
# system.\n
if source_person is not None \\\n
and destination_decision_person is not None \\\n
and destination_decision_person.getDefaultEmailText() \\\n
and destination_decision_person.getReference():\n
message = """\n
%s has finished the task report titled with %s.\n
Please look at this URL:\n
......
......@@ -86,7 +86,13 @@ source_person = task_report.getSourceValue(portal_type="Person")\n
destination_decision_person = task_report.getDestinationDecisionValue(portal_type="Person")\n
if destination_decision_person is None:\n
destination_decision_person = task_report.getDestinationValue(portal_type="Person")\n
if source_person is not None and destination_decision_person is not None:\n
\n
# send notification only if the source have a valid email and is a user in the\n
# system\n
if source_person is not None \\\n
and destination_decision_person is not None\\\n
and source_person.getDefaultEmailText() \\\n
and source_person.getReference():\n
message = """\n
A question from task has been assigned to you by %(assignor)s.\n
\n
......@@ -105,7 +111,7 @@ Please visit ERP5: %(url)s\n
""" % {\n
\'assignor\': destination_decision_person.getTitle(),\n
\'title\' : task_report.getTitle(),\n
\'url\' : \'%s/%s\' % (task_report.ERP5Site_getAbsoluteUrl(),\n
\'url\' : \'%s/%s/view\' % (task_report.ERP5Site_getAbsoluteUrl(),\n
task_report.getRelativeUrl()),\n
\'comment\' : task_report.getComment(),\n
\'start_date\': task_report.getStartDate().Date(),\n
......
......@@ -72,7 +72,13 @@ source_person = task_report.getSourceValue(portal_type="Person")\n
destination_decision_person = task_report.getDestinationDecisionValue(portal_type="Person")\n
if destination_decision_person is None:\n
destination_decision_person = task_report.getDestinationValue(portal_type="Person")\n
if source_person is not None and destination_decision_person is not None:\n
\n
# send notification only if the source have a valid email and is a user in the\n
# system\n
if source_person is not None \\\n
and destination_decision_person is not None\\\n
and source_person.getDefaultEmailText() \\\n
and source_person.getReference():\n
message = """\n
Restarted task has been assigned to you by %(assignor)s.\n
\n
......@@ -88,7 +94,7 @@ Please visit ERP5: %(url)s\n
""" % {\n
\'assignor\': destination_decision_person.getTitle(),\n
\'title\' : task_report.getTitle(),\n
\'url\' : \'%s/%s\' % (task_report.ERP5Site_getAbsoluteUrl(),\n
\'url\' : \'%s/%s/view\' % (task_report.ERP5Site_getAbsoluteUrl(),\n
  • @jerome @romain , I wonder what is the best way to set it so it can link to renderjs site (if any). One way is preference, but maybe something better?

  • There is a feature request for that #20170830-17B2A2B /cc @tatuya

    I think I added ERP5Site_getAbsoluteUrl 10 years ago, with the idea that it could be configured if needed, but I don't think it was ever configured by anyone and I'm not sure it was a good idea.

    Using a preference seems hard, we cannot query other users preferences so easily (at least we cannot do this restricted python).

    But isn't something that should also be covered by !431 (merged) ?

Please register or sign in to reply
task_report.getRelativeUrl()),\n
\'comment\' : task_report.getComment(),\n
\'start_date\': task_report.getStartDate().Date(),\n
......
528
\ No newline at end of file
529
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment