mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-12 14:17:46 +00:00
fix: truncate site name if longer than 50 characters and show warning
Close #518
This commit is contained in:
parent
bae65ff701
commit
3890a38ca1
@ -18,6 +18,7 @@ Every user-facing change should have an entry in this changelog. Please respect
|
||||
|
||||
## Unreleased
|
||||
|
||||
- [Fix] Truncate site display name to 50 characters with a warning, fixing data too long error for long site names. (by @navinkarkera)
|
||||
- [Feature] Add patch to allow overriding final openedx docker image CMD
|
||||
- [Fix] Ignore Python plugins that cannot be loaded. (by @regisb)
|
||||
- [Improvement] Faster and more reliable builds with `npm clean-install` instead of `npm install`. (by @regisb. Thanks @ghassanmas!)
|
||||
|
@ -126,11 +126,18 @@ def set_theme(
|
||||
return
|
||||
python_code = "from django.contrib.sites.models import Site"
|
||||
for domain_name in domain_names:
|
||||
if len(domain_name) > 50:
|
||||
fmt.echo_alert(
|
||||
"Assigning a theme to a site with a long (> 50 characters) domain name."
|
||||
" The displayed site name will be truncated to 50 characters."
|
||||
)
|
||||
python_code += """
|
||||
print('Assigning theme {theme_name} to {domain_name}...')
|
||||
site, _ = Site.objects.get_or_create(domain='{domain_name}')
|
||||
if not site.name:
|
||||
site.name = '{domain_name}'
|
||||
name_max_length = Site._meta.get_field('name').max_length
|
||||
name = '{domain_name}'[:name_max_length]
|
||||
site.name = name
|
||||
site.save()
|
||||
site.themes.all().delete()
|
||||
site.themes.create(theme_dir_name='{theme_name}')
|
||||
|
Loading…
Reference in New Issue
Block a user