mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-17 05:21:00 +00:00
Move get_site_for_user to wagtail.admin.navigation
This commit is contained in:
parent
eabe8ae47a
commit
3a44de4d2b
2 changed files with 20 additions and 19 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from django.conf import settings
|
||||
|
||||
from wagtail.core.models import Page
|
||||
|
||||
|
||||
|
|
@ -26,3 +28,19 @@ def get_explorable_root_page(user):
|
|||
root_page = None
|
||||
|
||||
return root_page
|
||||
|
||||
|
||||
def get_site_for_user(user):
|
||||
root_page = get_explorable_root_page(user)
|
||||
if root_page:
|
||||
root_site = root_page.get_site()
|
||||
else:
|
||||
root_site = None
|
||||
real_site_name = None
|
||||
if root_site:
|
||||
real_site_name = root_site.site_name if root_site.site_name else root_site.hostname
|
||||
return {
|
||||
'root_page': root_page,
|
||||
'root_site': root_site,
|
||||
'site_name': real_site_name if real_site_name else settings.WAGTAIL_SITE_NAME,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,8 @@
|
|||
import sys
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from wagtail.admin.navigation import get_explorable_root_page
|
||||
from wagtail.utils.deprecation import MovedDefinitionHandler, RemovedInWagtail29Warning
|
||||
|
||||
|
||||
def get_site_for_user(user):
|
||||
root_page = get_explorable_root_page(user)
|
||||
if root_page:
|
||||
root_site = root_page.get_site()
|
||||
else:
|
||||
root_site = None
|
||||
real_site_name = None
|
||||
if root_site:
|
||||
real_site_name = root_site.site_name if root_site.site_name else root_site.hostname
|
||||
return {
|
||||
'root_page': root_page,
|
||||
'root_site': root_site,
|
||||
'site_name': real_site_name if real_site_name else settings.WAGTAIL_SITE_NAME,
|
||||
}
|
||||
|
||||
|
||||
MOVED_DEFINITIONS = {
|
||||
'WAGTAILADMIN_PROVIDED_LANGUAGES': 'wagtail.admin.locale',
|
||||
'get_js_translation_strings': 'wagtail.admin.locale',
|
||||
|
|
@ -41,6 +22,8 @@ MOVED_DEFINITIONS = {
|
|||
|
||||
'send_mail': 'wagtail.admin.mail',
|
||||
'send_notification': 'wagtail.admin.mail',
|
||||
|
||||
'get_site_for_user': 'wagtail.admin.navigation',
|
||||
}
|
||||
|
||||
sys.modules[__name__] = MovedDefinitionHandler(sys.modules[__name__], MOVED_DEFINITIONS, RemovedInWagtail29Warning)
|
||||
|
|
|
|||
Loading…
Reference in a new issue