diff --git a/projectroles/views.py b/projectroles/views.py index 19940627..2d87c8af 100644 --- a/projectroles/views.py +++ b/projectroles/views.py @@ -1721,22 +1721,19 @@ def handle_delete(self, project, request): self._create_timeline_event(project, request) # Create app alerts if app_alerts: - roles = project.get_roles() - for role_as in roles: - user = role_as.user - # Skip alerting if same user - if user == request.user: - continue - app_alerts.add_alert( - app_name=APP_NAME, - alert_name='project_delete', - user=role_as.user, - message=PROJECT_DELETE_MSG.format( - project_type=get_display_name(project.type, title=True), - project_title=project.title, - user_name=request.user.username, - ), - ) + users = [ + a.user for a in project.get_roles() if a.user != request.user + ] + app_alerts.add_alerts( + app_name=APP_NAME, + alert_name='project_delete', + users=users, + message=PROJECT_DELETE_MSG.format( + project_type=get_display_name(project.type, title=True), + project_title=project.title, + user_name=request.user.username, + ), + ) # Send email if SEND_EMAIL: email.send_project_delete_mail(project, request)