Skip to content

2604 preparation reminder for internal users - #2688

Open
ybrnr wants to merge 6 commits into
e-valuation:mainfrom
ybrnr:2604-preparation-reminder-for-internal-users
Open

2604 preparation reminder for internal users#2688
ybrnr wants to merge 6 commits into
e-valuation:mainfrom
ybrnr:2604-preparation-reminder-for-internal-users

Conversation

@ybrnr

@ybrnr ybrnr commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator

closes #2604: On staff:preparation_reminder, next to "Remind all", adds a "Remind all internal" button.

Comment thread evap/staff/views.py
Comment on lines +970 to +971
if internal_only:
responsibles = responsibles.exclude(pk__in=[r.pk for r in responsibles if r.is_external])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_external is implemented in python logic, so django cannot convert it into a SQL query. That means we don't "win" anything by adding this filter to the query early. Note that the code here currently fetches responsibles, computes is_external for each of them, and then amends the original query with "where id is not in [list of external IDs]" -- this is just one extra database round trip without real benefit.

Above, you access request.POST, but outside the if request.method == 'POST' block below.

I think for maintainability, it makes sense to put this check inside this block. That way, we keep the queries simple, save one database roundtrip, don't build large SQL, and the world is greener.

The code change would then just be

if request.POST.get("internal_only") == "true" and responsible.is_external:
    continue

Comment on lines +1079 to +1086
email_template_mock.objects.get.return_value = email_template_mock
email_template_mock.EDITOR_REVIEW_REMINDER = EmailTemplate.EDITOR_REVIEW_REMINDER

self.app.post(self.url, params={"internal_only": "true"}, user=self.manager, status=200)

recipients = [call[0][0] for call in email_template_mock.send_to_user.call_args_list]
self.assertIn(self.user, recipients)
self.assertNotIn(external_responsible, recipients)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be less code to not patch the email templates and just check mail.outbox afterwards? If so, let's do that (otherwise, ignore).

<span slot="action-text">{% translate 'Remind all internal users' %}</span>
<span slot="question">{% translate 'Do you really want to remind all internal users?' %}</span>

<button slot="show-button" type="button" id="remindAllInternalUsersButton" class="btn btn-sm btn-light">{% translate 'Remind all internal users' %}</button>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The id here, remindAllInternalUsersButton, is never used. Let's remove it.

While you're at it, the same is true for remindAllButton above.

Comment thread evap/staff/views.py
Comment on lines -984 to +987
messages.success(request, _("Successfully sent reminders to everyone."))
messages.success(request, _("Successfully sent reminders."))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two different success messages for the two cases would be nice

@richardebeling richardebeling left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking as "changes requested" to clean-up our "to review" lists

@github-actions github-actions Bot added the Stale label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

Preparation reminder for internal users

3 participants