Commit 0eaa2dcb authored by felix.herrmann's avatar felix.herrmann
Browse files

fix(mails): send ds publish status update mails also to curators

parent ad4b0328
......@@ -518,7 +518,7 @@ class DataSetPublicationRequest(models.Model):
notification.save()
self.notification = notification
# send email to all curators
subject = text
subject = "[Curation] {}".format(text,)
message = _(
"The dataset {} has been submitted for publication in the category {}:\n\n{}\n\nPlease conduct a technical review of the uploaded data and metadata prior to your decision about the publication.".format(
self.dataset, self.category, self.dataset.get_absolute_url_curation()
......@@ -1039,6 +1039,11 @@ class DataSet(models.Model):
"dddatasets:prep_edit", args=[str(self.uuid)]
)
def get_absolute_url_prep_versions(self):
return settings.DISCUSS_DATA_HOST + reverse(
"dddatasets:prep_edit_versions", args=[str(self.uuid)]
)
def get_absolute_url_curation(self):
return settings.DISCUSS_DATA_HOST + reverse(
"dddatasets:prep_curation", args=[str(self.uuid)]
......@@ -1362,8 +1367,9 @@ class DataSet(models.Model):
self.get_main_category()
)
)
subject = text
if message:
text = "{}\n\n{}".format(text, message)
text = "{}\n\n{}'s curators message:\n{}".format(text, user, message)
notification = Notification(
owner=user,
......@@ -1374,6 +1380,16 @@ class DataSet(models.Model):
notification_type=Notification.PUB_REQUEST,
)
notification.save()
# send email to dataset owner
mail_message = "Dataset {} at {}:\n{}".format(
self, self.get_absolute_url_prep(), text
)
email_to = [self.owner.email]
send_update_email(subject, mail_message, email_to)
# send emails to category curators
curators_subject = "[Curation] {}".format(subject,)
curators_to = self.get_main_category().get_curators_emails()
send_update_email(curators_subject, mail_message, curators_to)
pubreq.delete()
else:
raise PermissionDenied
......@@ -1399,8 +1415,9 @@ class DataSet(models.Model):
self.get_main_category()
)
)
subject = text
if message:
text = "{}\n\n{}".format(text, message)
text = "{}\n\n{}'s curators message:\n{}\n".format(text, user, message)
notification = Notification(
owner=user,
......@@ -1411,6 +1428,19 @@ class DataSet(models.Model):
notification_type=Notification.PUB_REQUEST,
)
notification.save()
# send email to dataset owner
mail_message = "Dataset {} at {}:\n{}".format(
self, self.get_absolute_url_prep(), text
)
mail_message += "\nYou can now publish the dataset at {}.\n".format(
self.get_absolute_url_prep_versions()
)
email_to = [self.owner.email]
send_update_email(subject, mail_message, email_to)
# send emails to category curators
curators_subject = "[Curation] {}".format(subject,)
curators_to = self.get_main_category().get_curators_emails()
send_update_email(curators_subject, mail_message, curators_to)
pubreq.delete()
else:
raise PermissionDenied
......@@ -1445,6 +1475,21 @@ class DataSet(models.Model):
action.send(
user, verb="published the dataset", target=self,
)
# send email to dataset owner
subject = "Dataset {} has been published successfully!".format(self,)
message = "{}\n\nIt is accessible via DOI https://doi.org/{}".format(
subject, self.doi
)
if self.dhdoi:
message += "\nDARIAH-Repository entry: https://doi.org/{}".format(
self.doi
)
email_to = [self.owner.email]
send_update_email(subject, message, email_to)
# send emails to category curators
curators_subject = "[Curation] {}".format(subject,)
curators_to = self.get_main_category().get_curators_emails()
send_update_email(curators_subject, message, curators_to)
else:
raise PermissionDenied
logger.debug("DS PUBLISH ended")
......
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