Commit af02f78a authored by felix.herrmann's avatar felix.herrmann
Browse files

Merge branch '181-e-mail-notification-dashboard' into 'master'

Resolve "E-Mail notification & dashboard"

Closes #181

See merge request !391
parents 1502dc88 5e64f523
...@@ -99,7 +99,10 @@ class Category(models.Model): ...@@ -99,7 +99,10 @@ class Category(models.Model):
] ]
def get_curators_emails(self): def get_curators_emails(self):
return self.curators.all().values_list("email", flat=True) curators_emails = list()
for curator in self.curators.all():
curators_emails.append(curator.get_email())
return curators_emails
def get_published_datasets_category(self): def get_published_datasets_category(self):
return DataSet.objects.filter(published=True, published_categories__id=self.id) return DataSet.objects.filter(published=True, published_categories__id=self.id)
...@@ -482,7 +485,7 @@ class DataSetAccessRequest(models.Model): ...@@ -482,7 +485,7 @@ class DataSetAccessRequest(models.Model):
self.dataset, self.dataset.get_absolute_url() self.dataset, self.dataset.get_absolute_url()
) )
) )
email_to = [self.dataset.owner.email] email_to = [self.dataset.owner.get_email()]
send_update_email(subject, message, email_to) send_update_email(subject, message, email_to)
models.Model.save(self, *args, **kwargs) models.Model.save(self, *args, **kwargs)
...@@ -1384,7 +1387,7 @@ class DataSet(models.Model): ...@@ -1384,7 +1387,7 @@ class DataSet(models.Model):
mail_message = "Dataset {} at {}:\n{}".format( mail_message = "Dataset {} at {}:\n{}".format(
self, self.get_absolute_url_prep(), text self, self.get_absolute_url_prep(), text
) )
email_to = [self.owner.email] email_to = [self.owner.get_email()]
send_update_email(subject, mail_message, email_to) send_update_email(subject, mail_message, email_to)
# send emails to category curators # send emails to category curators
curators_subject = "[Curation] {}".format(subject,) curators_subject = "[Curation] {}".format(subject,)
...@@ -1435,7 +1438,7 @@ class DataSet(models.Model): ...@@ -1435,7 +1438,7 @@ class DataSet(models.Model):
mail_message += "\nYou can now publish the dataset at {}.\n".format( mail_message += "\nYou can now publish the dataset at {}.\n".format(
self.get_absolute_url_prep_versions() self.get_absolute_url_prep_versions()
) )
email_to = [self.owner.email] email_to = [self.owner.get_email()]
send_update_email(subject, mail_message, email_to) send_update_email(subject, mail_message, email_to)
# send emails to category curators # send emails to category curators
curators_subject = "[Curation] {}".format(subject,) curators_subject = "[Curation] {}".format(subject,)
...@@ -1484,7 +1487,7 @@ class DataSet(models.Model): ...@@ -1484,7 +1487,7 @@ class DataSet(models.Model):
message += "\nDARIAH-Repository entry: https://doi.org/{}".format( message += "\nDARIAH-Repository entry: https://doi.org/{}".format(
self.doi self.doi
) )
email_to = [self.owner.email] email_to = [self.owner.get_email()]
send_update_email(subject, message, email_to) send_update_email(subject, message, email_to)
# send emails to category curators # send emails to category curators
curators_subject = "[Curation] {}".format(subject,) curators_subject = "[Curation] {}".format(subject,)
......
# Generated by Django 2.2.17 on 2021-03-29 19:27
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ddusers', '0013_auto_20201116_1725'),
]
operations = [
migrations.AddField(
model_name='user',
name='email_alternative',
field=models.EmailField(blank=True, max_length=254),
),
]
...@@ -123,6 +123,7 @@ class User(AbstractUser): ...@@ -123,6 +123,7 @@ class User(AbstractUser):
show_first_steps = models.BooleanField( show_first_steps = models.BooleanField(
verbose_name="Show First Steps", default=True verbose_name="Show First Steps", default=True
) )
email_alternative = models.EmailField(blank=True)
class Meta: class Meta:
ordering = ["last_name"] ordering = ["last_name"]
...@@ -148,6 +149,12 @@ class User(AbstractUser): ...@@ -148,6 +149,12 @@ class User(AbstractUser):
return academic_name return academic_name
def get_email(self):
if self.email_alternative:
return self.email_alternative
else:
return self.email
def get_publications(self): def get_publications(self):
return self.publications.all().order_by("-year") return self.publications.all().order_by("-year")
......
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