forked from rc/aircox
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:
|
||||
return
|
||||
|
||||
# root pages
|
||||
root_page = Page.objects.get(id=1)
|
||||
|
||||
homepage = models.Publication(
|
||||
|
@ -33,6 +34,16 @@ def station_post_saved(sender, instance, created, *args, **kwargs):
|
|||
)
|
||||
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(
|
||||
# /doc/ when a Station is created, a wagtail Site is generated with
|
||||
# default options. User must set the correct localhost afterwards
|
||||
|
@ -40,6 +51,7 @@ def station_post_saved(sender, instance, created, *args, **kwargs):
|
|||
port = 80,
|
||||
site_name = instance.name.capitalize(),
|
||||
root_page = homepage,
|
||||
is_default_site = is_default_site,
|
||||
)
|
||||
site.save()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user