remove is_default_site from default Wagtail Site and set it to the first Site created by Aircox
This commit is contained in:
parent
48f740502b
commit
b24da810b5
|
@ -21,6 +21,7 @@ def station_post_saved(sender, instance, created, *args, **kwargs):
|
||||||
if not created:
|
if not created:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# root pages
|
||||||
root_page = Page.objects.get(id=1)
|
root_page = Page.objects.get(id=1)
|
||||||
|
|
||||||
homepage = models.Publication(
|
homepage = models.Publication(
|
||||||
|
@ -33,6 +34,16 @@ def station_post_saved(sender, instance, created, *args, **kwargs):
|
||||||
)
|
)
|
||||||
root_page.add_child(instance=homepage)
|
root_page.add_child(instance=homepage)
|
||||||
|
|
||||||
|
# Site
|
||||||
|
default_site = Site.objects.filter(is_default_site = True).first()
|
||||||
|
is_default_site = False
|
||||||
|
if default_site and default_site.pk == 1:
|
||||||
|
# default website generated by wagtail: disable is_default_site so
|
||||||
|
# we can use it for us
|
||||||
|
default_site.is_default_site = False
|
||||||
|
default_site.save()
|
||||||
|
is_default_site = True
|
||||||
|
|
||||||
site = Site(
|
site = Site(
|
||||||
# /doc/ when a Station is created, a wagtail Site is generated with
|
# /doc/ when a Station is created, a wagtail Site is generated with
|
||||||
# default options. User must set the correct localhost afterwards
|
# default options. User must set the correct localhost afterwards
|
||||||
|
@ -40,6 +51,7 @@ def station_post_saved(sender, instance, created, *args, **kwargs):
|
||||||
port = 80,
|
port = 80,
|
||||||
site_name = instance.name.capitalize(),
|
site_name = instance.name.capitalize(),
|
||||||
root_page = homepage,
|
root_page = homepage,
|
||||||
|
is_default_site = is_default_site,
|
||||||
)
|
)
|
||||||
site.save()
|
site.save()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user