feat: update the email ui in the template folder#27
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for custom email branding, allowing organizations to include their dark/light logos and brand names in emails. It refactors email context rendering, adds filtering by email type to the custom email list view, and updates the organization settings update view to return a fully serialized configuration. The review feedback highlights a duplicate field definition in OrganizationEmailSerializer and points out opportunities to eliminate N+1 query issues in get_theme_logo_url and ListCustomEmailView by utilizing Django's prefetching capabilities.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if not setting: | ||
| return f"{host}/static/images/branding/{default_logo}" | ||
|
|
||
| theme = setting.themes.filter(theme_key=theme_key).first() |
There was a problem hiding this comment.
Using .filter() on the themes related manager triggers a database query every time it is called. When serializing a list of custom emails, this leads to an N+1 query problem (specifically, multiple queries per email item to fetch dark and light themes).
By changing this to use Python's next() with setting.themes.all(), we can leverage Django's prefetch_related cache. Even if prefetching is not used, fetching all themes (typically only 2: light and dark) in a single query is more efficient than executing multiple filtered queries.
| theme = setting.themes.filter(theme_key=theme_key).first() | |
| theme = next((t for t in setting.themes.all() if t.theme_key == theme_key), None) |
| queryset = OrganizationEmail.objects.all() | ||
| organization_field = "organization" |
There was a problem hiding this comment.
To completely eliminate the N+1 query problem when listing custom emails, we should optimize the queryset in ListCustomEmailView by pre-fetching the related organization, organization_settings, and themes using select_related and prefetch_related.
| queryset = OrganizationEmail.objects.all() | |
| organization_field = "organization" | |
| queryset = OrganizationEmail.objects.select_related( | |
| "organization__organization_settings" | |
| ).prefetch_related( | |
| "organization__organization_settings__themes" | |
| ) | |
| organization_field = "organization" |
| "brand_name", | ||
| "email_type", | ||
| "email_type", | ||
| "sender_name", |
There was a problem hiding this comment.
What?
Update the email UI in the template folder
Why?
How?
Testing?
Anything Else?