Team mail fix #226
@ -92,11 +92,14 @@ class Mailer:
|
|||||||
msg
|
msg
|
||||||
)
|
)
|
||||||
|
|
||||||
def send_mail_shared_access_given_team(self, obj_identifier, obj_title, team):
|
def send_mail_shared_access_given_team(self, obj_identifier, obj_title, team, users_to_notify):
|
||||||
""" Send a mail if a team just got access to the object
|
""" Send a mail if a team just got access to the object
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj_identifier (str): The object identifier
|
obj_identifier (str): The object identifier
|
||||||
|
obj_title (str): Title of the main object
|
||||||
|
team (Team): Team to be notified
|
||||||
|
users_to_notify (QueryDict): Contains the team users which should be notified
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
@ -108,18 +111,21 @@ class Mailer:
|
|||||||
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
||||||
}
|
}
|
||||||
msg = render_to_string("email/sharing/shared_access_given_team.html", context)
|
msg = render_to_string("email/sharing/shared_access_given_team.html", context)
|
||||||
user_mail_address = team.users.values_list("email", flat=True)
|
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||||
self.send(
|
self.send(
|
||||||
user_mail_address,
|
user_mail_address,
|
||||||
_("{} - Shared access given").format(obj_identifier),
|
_("{} - Shared access given").format(obj_identifier),
|
||||||
msg
|
msg
|
||||||
)
|
)
|
||||||
|
|
||||||
def send_mail_shared_access_removed_team(self, obj_identifier, obj_title, team):
|
def send_mail_shared_access_removed_team(self, obj_identifier, obj_title, team, users_to_notify):
|
||||||
""" Send a mail if a team just lost access to the object
|
""" Send a mail if a team just lost access to the object
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj_identifier (str): The object identifier
|
obj_identifier (str): The object identifier
|
||||||
|
obj_title (str): Title of the main object
|
||||||
|
team (Team): Team to be notified
|
||||||
|
users_to_notify (QueryDict): Contains the team users which should be notified
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
@ -131,18 +137,21 @@ class Mailer:
|
|||||||
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
||||||
}
|
}
|
||||||
msg = render_to_string("email/sharing/shared_access_removed_team.html", context)
|
msg = render_to_string("email/sharing/shared_access_removed_team.html", context)
|
||||||
user_mail_address = team.users.values_list("email", flat=True)
|
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||||
self.send(
|
self.send(
|
||||||
user_mail_address,
|
user_mail_address,
|
||||||
_("{} - Shared access removed").format(obj_identifier),
|
_("{} - Shared access removed").format(obj_identifier),
|
||||||
msg
|
msg
|
||||||
)
|
)
|
||||||
|
|
||||||
def send_mail_shared_data_unrecorded_team(self, obj_identifier, obj_title, team):
|
def send_mail_shared_data_unrecorded_team(self, obj_identifier, obj_title, team, users_to_notify):
|
||||||
""" Send a mail if data has just been unrecorded
|
""" Send a mail if data has just been unrecorded
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj_identifier (str): The object identifier
|
obj_identifier (str): The object identifier
|
||||||
|
obj_title (str): Title of the main object
|
||||||
|
team (Team): Team to be notified
|
||||||
|
users_to_notify (QueryDict): Contains the team users which should be notified
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
@ -154,18 +163,21 @@ class Mailer:
|
|||||||
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
||||||
}
|
}
|
||||||
msg = render_to_string("email/recording/shared_data_unrecorded_team.html", context)
|
msg = render_to_string("email/recording/shared_data_unrecorded_team.html", context)
|
||||||
user_mail_address = team.users.values_list("email", flat=True)
|
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||||
self.send(
|
self.send(
|
||||||
user_mail_address,
|
user_mail_address,
|
||||||
_("{} - Shared data unrecorded").format(obj_identifier),
|
_("{} - Shared data unrecorded").format(obj_identifier),
|
||||||
msg
|
msg
|
||||||
)
|
)
|
||||||
|
|
||||||
def send_mail_shared_data_recorded_team(self, obj_identifier, obj_title, team):
|
def send_mail_shared_data_recorded_team(self, obj_identifier, obj_title, team, users_to_notify):
|
||||||
""" Send a mail if data has just been recorded
|
""" Send a mail if data has just been recorded
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj_identifier (str): The object identifier
|
obj_identifier (str): The object identifier
|
||||||
|
obj_title (str): Title of the main object
|
||||||
|
team (Team): Team to be notified
|
||||||
|
users_to_notify (QueryDict): Contains the team users which should be notified
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
@ -177,18 +189,21 @@ class Mailer:
|
|||||||
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
||||||
}
|
}
|
||||||
msg = render_to_string("email/recording/shared_data_recorded_team.html", context)
|
msg = render_to_string("email/recording/shared_data_recorded_team.html", context)
|
||||||
user_mail_address = team.users.values_list("email", flat=True)
|
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||||
self.send(
|
self.send(
|
||||||
user_mail_address,
|
user_mail_address,
|
||||||
_("{} - Shared data recorded").format(obj_identifier),
|
_("{} - Shared data recorded").format(obj_identifier),
|
||||||
msg
|
msg
|
||||||
)
|
)
|
||||||
|
|
||||||
def send_mail_shared_data_checked_team(self, obj_identifier, obj_title, team):
|
def send_mail_shared_data_checked_team(self, obj_identifier, obj_title, team, users_to_notify):
|
||||||
""" Send a mail if data has just been checked
|
""" Send a mail if data has just been checked
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
obj_identifier (str): The object identifier
|
obj_identifier (str): The object identifier
|
||||||
|
obj_title (str): Title of the main object
|
||||||
|
team (Team): Team to be notified
|
||||||
|
users_to_notify (QueryDict): Contains the team users which should be notified
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
@ -200,14 +215,14 @@ class Mailer:
|
|||||||
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
||||||
}
|
}
|
||||||
msg = render_to_string("email/checking/shared_data_checked_team.html", context)
|
msg = render_to_string("email/checking/shared_data_checked_team.html", context)
|
||||||
user_mail_address = team.users.values_list("email", flat=True)
|
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||||
self.send(
|
self.send(
|
||||||
user_mail_address,
|
user_mail_address,
|
||||||
_("{} - Shared data checked").format(obj_identifier),
|
_("{} - Shared data checked").format(obj_identifier),
|
||||||
msg
|
msg
|
||||||
)
|
)
|
||||||
|
|
||||||
def send_mail_deduction_changed_team(self, obj_identifier, obj_title, team, data_changes):
|
def send_mail_deduction_changed_team(self, obj_identifier, obj_title, team, data_changes, users_to_notify):
|
||||||
""" Send a mail if deduction has been changed
|
""" Send a mail if deduction has been changed
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -215,7 +230,7 @@ class Mailer:
|
|||||||
obj_title (str): Title of the main object
|
obj_title (str): Title of the main object
|
||||||
team (Team): Team to be notified
|
team (Team): Team to be notified
|
||||||
data_changes (dict): Contains the old|new changes of the deduction changes
|
data_changes (dict): Contains the old|new changes of the deduction changes
|
||||||
|
users_to_notify (QueryDict): Contains the team users which should be notified
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -227,14 +242,14 @@ class Mailer:
|
|||||||
"data_changes": data_changes,
|
"data_changes": data_changes,
|
||||||
}
|
}
|
||||||
msg = render_to_string("email/other/deduction_changed_team.html", context)
|
msg = render_to_string("email/other/deduction_changed_team.html", context)
|
||||||
user_mail_address = team.users.values_list("email", flat=True)
|
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||||
self.send(
|
self.send(
|
||||||
user_mail_address,
|
user_mail_address,
|
||||||
_("{} - Deduction changed").format(obj_identifier),
|
_("{} - Deduction changed").format(obj_identifier),
|
||||||
msg
|
msg
|
||||||
)
|
)
|
||||||
|
|
||||||
def send_mail_shared_data_deleted_team(self, obj_identifier, obj_title, team):
|
def send_mail_shared_data_deleted_team(self, obj_identifier, obj_title, team, users_to_notify):
|
||||||
""" Send a mail if data has just been deleted
|
""" Send a mail if data has just been deleted
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -250,7 +265,7 @@ class Mailer:
|
|||||||
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
|
||||||
}
|
}
|
||||||
msg = render_to_string("email/deleting/shared_data_deleted_team.html", context)
|
msg = render_to_string("email/deleting/shared_data_deleted_team.html", context)
|
||||||
user_mail_address = team.users.values_list("email", flat=True)
|
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||||
self.send(
|
self.send(
|
||||||
user_mail_address,
|
user_mail_address,
|
||||||
_("{} - Shared data deleted").format(obj_identifier),
|
_("{} - Shared data deleted").format(obj_identifier),
|
||||||
|
@ -2,6 +2,7 @@ from django.db import models
|
|||||||
|
|
||||||
from konova.models import UuidModel, DeletableObjectMixin
|
from konova.models import UuidModel, DeletableObjectMixin
|
||||||
from konova.utils.mailer import Mailer
|
from konova.utils.mailer import Mailer
|
||||||
|
from user.enums import UserNotificationEnum
|
||||||
from user.models import UserActionLogEntry
|
from user.models import UserActionLogEntry
|
||||||
|
|
||||||
|
|
||||||
@ -41,7 +42,10 @@ class Team(UuidModel, DeletableObjectMixin):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
mailer = Mailer()
|
mailer = Mailer()
|
||||||
mailer.send_mail_shared_access_given_team(obj_identifier, obj_title, self)
|
users_to_notify = self.users.filter(
|
||||||
|
notifications__in=[UserNotificationEnum.NOTIFY_ON_SHARED_ACCESS_GAINED.value]
|
||||||
|
)
|
||||||
|
mailer.send_mail_shared_access_given_team(obj_identifier, obj_title, self, users_to_notify)
|
||||||
|
|
||||||
def send_mail_shared_access_removed(self, obj_identifier, obj_title):
|
def send_mail_shared_access_removed(self, obj_identifier, obj_title):
|
||||||
""" Sends a mail to the team members in case of removed shared access
|
""" Sends a mail to the team members in case of removed shared access
|
||||||
@ -54,7 +58,10 @@ class Team(UuidModel, DeletableObjectMixin):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
mailer = Mailer()
|
mailer = Mailer()
|
||||||
mailer.send_mail_shared_access_removed_team(obj_identifier, obj_title, self)
|
users_to_notify = self.users.filter(
|
||||||
|
notifications__in=[UserNotificationEnum.NOTIFY_ON_SHARED_ACCESS_REMOVED.value]
|
||||||
|
)
|
||||||
|
mailer.send_mail_shared_access_removed_team(obj_identifier, obj_title, self, users_to_notify)
|
||||||
|
|
||||||
def send_mail_shared_data_unrecorded(self, obj_identifier, obj_title):
|
def send_mail_shared_data_unrecorded(self, obj_identifier, obj_title):
|
||||||
""" Sends a mail to the team members in case of unrecorded data
|
""" Sends a mail to the team members in case of unrecorded data
|
||||||
@ -67,7 +74,10 @@ class Team(UuidModel, DeletableObjectMixin):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
mailer = Mailer()
|
mailer = Mailer()
|
||||||
mailer.send_mail_shared_data_unrecorded_team(obj_identifier, obj_title, self)
|
users_to_notify = self.users.filter(
|
||||||
|
notifications__in=[UserNotificationEnum.NOTIFY_ON_SHARED_DATA_RECORDED.value]
|
||||||
|
)
|
||||||
|
mailer.send_mail_shared_data_unrecorded_team(obj_identifier, obj_title, self, users_to_notify)
|
||||||
|
|
||||||
def send_mail_shared_data_recorded(self, obj_identifier, obj_title):
|
def send_mail_shared_data_recorded(self, obj_identifier, obj_title):
|
||||||
""" Sends a mail to the team members in case of unrecorded data
|
""" Sends a mail to the team members in case of unrecorded data
|
||||||
@ -80,7 +90,10 @@ class Team(UuidModel, DeletableObjectMixin):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
mailer = Mailer()
|
mailer = Mailer()
|
||||||
mailer.send_mail_shared_data_recorded_team(obj_identifier, obj_title, self)
|
users_to_notify = self.users.filter(
|
||||||
|
notifications__in=[UserNotificationEnum.NOTIFY_ON_SHARED_DATA_RECORDED.value]
|
||||||
|
)
|
||||||
|
mailer.send_mail_shared_data_recorded_team(obj_identifier, obj_title, self, users_to_notify)
|
||||||
|
|
||||||
def send_mail_shared_data_checked(self, obj_identifier, obj_title):
|
def send_mail_shared_data_checked(self, obj_identifier, obj_title):
|
||||||
""" Sends a mail to the team members in case of checked data
|
""" Sends a mail to the team members in case of checked data
|
||||||
@ -93,7 +106,10 @@ class Team(UuidModel, DeletableObjectMixin):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
mailer = Mailer()
|
mailer = Mailer()
|
||||||
mailer.send_mail_shared_data_checked_team(obj_identifier, obj_title, self)
|
users_to_notify = self.users.filter(
|
||||||
|
notifications__in=[UserNotificationEnum.NOTIFY_ON_SHARED_DATA_CHECKED.value]
|
||||||
|
)
|
||||||
|
mailer.send_mail_shared_data_checked_team(obj_identifier, obj_title, self, users_to_notify)
|
||||||
|
|
||||||
def send_mail_deduction_changed(self, obj_identifier, obj_title, data_changes):
|
def send_mail_deduction_changed(self, obj_identifier, obj_title, data_changes):
|
||||||
""" Sends a mail to the team members in case of changed deduction values
|
""" Sends a mail to the team members in case of changed deduction values
|
||||||
@ -107,7 +123,10 @@ class Team(UuidModel, DeletableObjectMixin):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
mailer = Mailer()
|
mailer = Mailer()
|
||||||
mailer.send_mail_deduction_changed_team(obj_identifier, obj_title, self, data_changes)
|
users_to_notify = self.users.filter(
|
||||||
|
notifications__in=[UserNotificationEnum.NOTIFY_ON_DEDUCTION_CHANGES.value]
|
||||||
|
)
|
||||||
|
mailer.send_mail_deduction_changed_team(obj_identifier, obj_title, self, data_changes, users_to_notify)
|
||||||
|
|
||||||
def send_mail_shared_data_deleted(self, obj_identifier, obj_title):
|
def send_mail_shared_data_deleted(self, obj_identifier, obj_title):
|
||||||
""" Sends a mail to the team members in case of deleted data
|
""" Sends a mail to the team members in case of deleted data
|
||||||
@ -120,7 +139,10 @@ class Team(UuidModel, DeletableObjectMixin):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
mailer = Mailer()
|
mailer = Mailer()
|
||||||
mailer.send_mail_shared_data_deleted_team(obj_identifier, obj_title, self)
|
users_to_notify = self.users.filter(
|
||||||
|
notifications__in=[UserNotificationEnum.NOTIFY_ON_SHARED_DATA_DELETED.value]
|
||||||
|
)
|
||||||
|
mailer.send_mail_shared_data_deleted_team(obj_identifier, obj_title, self, users_to_notify)
|
||||||
|
|
||||||
def remove_user(self, user):
|
def remove_user(self, user):
|
||||||
""" Removes a user from the team
|
""" Removes a user from the team
|
||||||
|
Loading…
Reference in New Issue
Block a user