Skip to content

Commit

Permalink
refactor alert sending (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Jan 20, 2025
1 parent 1545565 commit 3ba8143
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions projectroles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3ba8143

Please sign in to comment.