Skip to content

feat: update the email ui in the template folder#27

Merged
ngovinh2k2 merged 1 commit into
devfrom
feat/update-the-email-ui-in-the-template-folder
Jul 3, 2026
Merged

feat: update the email ui in the template folder#27
ngovinh2k2 merged 1 commit into
devfrom
feat/update-the-email-ui-in-the-template-folder

Conversation

@ngovinh2k2

Copy link
Copy Markdown
Member

What?

Update the email UI in the template folder

Why?

How?

Testing?

  • Functional Testing
  • Security
  • Performance
  • Error Handling
  • Code Quality
  • Documentation
  • Database
  • Deployment
  • Final Review

Anything Else?

@ngovinh2k2 ngovinh2k2 merged commit 6c6a103 into dev Jul 3, 2026
1 check passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

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.

Suggested change
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)

Comment on lines 12 to 13
queryset = OrganizationEmail.objects.all()
organization_field = "organization"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

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.

Suggested change
queryset = OrganizationEmail.objects.all()
organization_field = "organization"
queryset = OrganizationEmail.objects.select_related(
"organization__organization_settings"
).prefetch_related(
"organization__organization_settings__themes"
)
organization_field = "organization"

Comment on lines +21 to 24
"brand_name",
"email_type",
"email_type",
"sender_name",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The field "email_type" is duplicated in the fields list of OrganizationEmailSerializer. One of them should be removed to avoid redundancy and keep the code clean.

Suggested change
"brand_name",
"email_type",
"email_type",
"sender_name",
"brand_name",
"email_type",
"sender_name",

@ngovinh2k2 ngovinh2k2 deleted the feat/update-the-email-ui-in-the-template-folder branch July 3, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant