From 2440970c5885fc04d7448be2a1e81cbdba623c7f Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Thu, 24 Oct 2024 09:41:31 +0330 Subject: [PATCH] fix: site name limited to 50 characters (#1145) Before this, building organizations with longer URLs failed since the name field inside Site model has a max_length=50 Close #1144 --- changelog.d/20241023_155157_codewithemad_long_domain.md | 1 + tutor/templates/build/openedx/bin/site-configuration | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelog.d/20241023_155157_codewithemad_long_domain.md diff --git a/changelog.d/20241023_155157_codewithemad_long_domain.md b/changelog.d/20241023_155157_codewithemad_long_domain.md new file mode 100644 index 0000000..1299716 --- /dev/null +++ b/changelog.d/20241023_155157_codewithemad_long_domain.md @@ -0,0 +1 @@ +- [Bugfix] Fixed an issue where the site name was not limited to 50 characters when creating a new site configuration. (by @CodeWithEmad) diff --git a/tutor/templates/build/openedx/bin/site-configuration b/tutor/templates/build/openedx/bin/site-configuration index 32736d5..22e7788 100644 --- a/tutor/templates/build/openedx/bin/site-configuration +++ b/tutor/templates/build/openedx/bin/site-configuration @@ -60,7 +60,9 @@ def get_site_configuration(domain): domain = domain or settings.LMS_BASE site, site_created = Site.objects.get_or_create(domain=domain) if site_created: - site.name = domain + # Limit the site name to 50 characters + # https://github.com/django/django/blob/4.2.16/django/contrib/sites/models.py#L86 + site.name = domain[:50] site.save() configuration, configuration_created = SiteConfiguration.objects.get_or_create(site=site) if configuration_created: