Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Set the site URL to the value set in SITE_URL in the configuration file

Roland Geiderf2bd90eaa3cf
diff --git a/extras/docker/development/entrypoint.sh b/extras/docker/development/entrypoint.sh
index c64dcb5d8..7cb54d63e 100644
--- a/extras/docker/development/entrypoint.sh
+++ b/extras/docker/development/entrypoint.sh
@@ -59,6 +59,9 @@ then
python3 manage.py download-exercise-images
fi
+# Set the site URL
+python3 manage.py set-site-url
+
# Run the server
if [[ "$WGER_USE_GUNICORN" == "True" ]];
then
diff --git a/wger/core/management/commands/set-site-url.py b/wger/core/management/commands/set-site-url.py
new file mode 100644
index 000000000..a584d9e51
--- /dev/null
+++ b/wger/core/management/commands/set-site-url.py
@@ -0,0 +1,21 @@
+# Django
+from django.contrib.sites.models import Site
+from django.conf import settings
+from django.core.management.base import BaseCommand
+
+"""
+Sets the site URL
+"""
+
+
+class Command(BaseCommand):
+
+ help = 'Sets the site URL from settings.SITE_URL, this is used e.g. for password reset emails'
+
+ def handle(self, *args, **options):
+
+ site = Site.objects.get_current()
+ site.domain = settings.SITE_URL
+ site.name = settings.SITE_URL
+ site.save()
+ self.stdout.write(self.style.SUCCESS(f"Set site URL to {settings.SITE_URL}"))