-
Notifications
You must be signed in to change notification settings - Fork 0
feat: update the email ui in the template folder #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,31 @@ | ||||||
| from common.apps.upload_file.service import get_presigned_url | ||||||
| from django.conf import settings | ||||||
|
|
||||||
| from apps.custom_email.constants import EmailTypes | ||||||
| from apps.custom_email.models import OrganizationEmail | ||||||
| from apps.organization_setting.constants import ThemeType | ||||||
|
|
||||||
|
|
||||||
| def get_theme_logo_url(instance, theme_key): | ||||||
| host = settings.HOST.rstrip("/") | ||||||
| default_logo = "logo_white.png" if theme_key == ThemeType.DARK else "logo_black.png" | ||||||
| organization = getattr(instance, "organization", None) | ||||||
| if not organization: | ||||||
| return f"{host}/static/images/branding/{default_logo}" | ||||||
|
|
||||||
| setting = getattr(organization, "organization_settings", None) | ||||||
| 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using By changing this to use Python's
Suggested change
|
||||||
|
|
||||||
| if not theme or not theme.logo: | ||||||
| return f"{host}/static/images/branding/{default_logo}" | ||||||
|
|
||||||
| return get_presigned_url( | ||||||
| settings.AWS_S3.get("AWS_STORAGE_BUCKET_NAME"), | ||||||
| f"uploads/{theme.logo}", | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
| def get_default_organization_emails(): | ||||||
|
|
@@ -57,3 +83,20 @@ def create_default_organization_email(organization): | |||||
| for email_data in get_default_organization_emails() | ||||||
| ] | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
| def get_custom_email_item(email_type): | ||||||
| from apps.custom_email.serializers import OrganizationEmailSerializer | ||||||
|
|
||||||
| custom_email = next( | ||||||
| ( | ||||||
| item | ||||||
| for item in get_default_organization_emails() | ||||||
| if item.get("email_type") == email_type | ||||||
| ), | ||||||
| None, | ||||||
| ) | ||||||
| if not custom_email: | ||||||
| return {} | ||||||
|
|
||||||
| return OrganizationEmailSerializer(OrganizationEmail(**custom_email)).data | ||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,5 +12,6 @@ class ListCustomEmailView(OrganizationListAPIView): | |||||||||||||||||
| queryset = OrganizationEmail.objects.all() | ||||||||||||||||||
| organization_field = "organization" | ||||||||||||||||||
|
Comment on lines
12
to
13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To completely eliminate the N+1 query problem when listing custom emails, we should optimize the queryset in
Suggested change
|
||||||||||||||||||
| pagination_class = BasePagination | ||||||||||||||||||
| filterset_fields = ["email_type"] | ||||||||||||||||||
| filter_backends = [DjangoFilterBackend, OrderingFilter] | ||||||||||||||||||
| ordering = ["-created_at"] | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The field
"email_type"is duplicated in thefieldslist ofOrganizationEmailSerializer. One of them should be removed to avoid redundancy and keep the code clean.