diff --git a/apps/custom_email/serializers.py b/apps/custom_email/serializers.py index c0f0e56..31ec772 100644 --- a/apps/custom_email/serializers.py +++ b/apps/custom_email/serializers.py @@ -67,10 +67,5 @@ def get_brand_logo_light(self, instance): return get_theme_logo_url(instance, "light") def get_brand_name(self, instance): - organization = getattr(instance, "organization", None) - setting = ( - getattr(organization, "organization_settings", None) - if organization - else None - ) + setting = getattr(instance, "organization_setting", None) return getattr(setting, "brand_name", "") or "" diff --git a/apps/custom_email/service.py b/apps/custom_email/service.py index b2a8dac..2a8508d 100644 --- a/apps/custom_email/service.py +++ b/apps/custom_email/service.py @@ -9,11 +9,7 @@ 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) + setting = getattr(instance, "organization_setting", None) if not setting: return f"{host}/static/images/branding/{default_logo}" @@ -80,10 +76,10 @@ def get_default_organization_emails(): ] -def create_default_organization_email(organization): +def create_default_organization_email(organization_setting): return OrganizationEmail.objects.bulk_create( [ - OrganizationEmail(organization=organization, **email_data) + OrganizationEmail(organization_setting=organization_setting, **email_data) for email_data in get_default_organization_emails() ] ) diff --git a/apps/custom_page/service.py b/apps/custom_page/service.py index 74cacca..7d826e1 100644 --- a/apps/custom_page/service.py +++ b/apps/custom_page/service.py @@ -47,11 +47,11 @@ def get_default_pages(): ] -def create_default_pages(organization): +def create_default_pages(organization_setting): default_pages = get_default_pages() list_data = [ CustomPage( - organization=organization, + organization_setting=organization_setting, page_type=page.get("page_type"), title=page.get("title"), subtitle=page.get("subtitle"), diff --git a/apps/organization_setting/services.py b/apps/organization_setting/services.py index d016f4d..8733690 100644 --- a/apps/organization_setting/services.py +++ b/apps/organization_setting/services.py @@ -69,3 +69,4 @@ def create_default_organization_setting(organization: Organization): ), ] ) + return setting diff --git a/bootstrap_service/management/commands/init_organization.py b/bootstrap_service/management/commands/init_organization.py index 31a079f..3ff3b22 100644 --- a/bootstrap_service/management/commands/init_organization.py +++ b/bootstrap_service/management/commands/init_organization.py @@ -123,9 +123,9 @@ def _create_organization_with_roles(self, org_id, org_name, org_slug, result): organization_policies = create_default_policies(organization) - create_default_pages(organization) - create_default_organization_email(organization) - create_default_organization_setting(organization) + organization_setting = create_default_organization_setting(organization) + create_default_pages(organization_setting) + create_default_organization_email(organization_setting) create_default_organization_monitoring(organization) create_default_subscription(organization) self.stdout.write(self.style.SUCCESS("Created default policies"))