kopia lustrzana https://github.com/wagtail/wagtail
Merge 92a0b19805
into 196cb02d10
commit
97b163b247
|
@ -34,6 +34,7 @@ export class PageChooser extends Chooser {
|
|||
matchSubclass: this.opts.matchSubclass,
|
||||
canChooseRoot: this.opts.canChooseRoot,
|
||||
userPerms: this.opts.userPerms,
|
||||
instanceId: this.opts.instanceId,
|
||||
};
|
||||
if (this.state && this.state.parentId) {
|
||||
opts.parentId = this.state.parentId;
|
||||
|
|
|
@ -251,6 +251,9 @@ class PageChooserModal extends ChooserModal {
|
|||
if (opts.userPerms) {
|
||||
urlParams.user_perms = opts.userPerms;
|
||||
}
|
||||
if (opts.instanceId) {
|
||||
urlParams.instance_id = opts.instanceId;
|
||||
}
|
||||
return urlParams;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.forms import models
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import ngettext
|
||||
|
||||
|
@ -166,6 +167,19 @@ class WagtailAdminPageForm(WagtailAdminModelForm):
|
|||
|
||||
self.parent_page = parent_page
|
||||
|
||||
# bind the parent page of this forms page to the PageChooser widget
|
||||
for obj in self.fields.values():
|
||||
if isinstance(obj, models.ModelChoiceField):
|
||||
try:
|
||||
obj.widget.page_instance = (
|
||||
self.instance
|
||||
if self.instance.id is not None
|
||||
else self.parent_page
|
||||
)
|
||||
except AttributeError:
|
||||
# Then propably it isn't a page chooser
|
||||
pass
|
||||
|
||||
if not self.show_comments_toggle:
|
||||
del self.fields["comment_notifications"]
|
||||
|
||||
|
|
|
@ -296,9 +296,12 @@ class BrowseView(View):
|
|||
selected_locale = get_object_or_404(
|
||||
Locale, language_code=request.GET["locale"]
|
||||
)
|
||||
active_locale_id = selected_locale.pk
|
||||
elif request.GET.get("instance_id"):
|
||||
page_instance = Page.objects.get(id=request.GET["instance_id"])
|
||||
selected_locale = page_instance.locale
|
||||
else:
|
||||
active_locale_id = Locale.get_active().pk
|
||||
selected_locale = Locale.get_active()
|
||||
active_locale_id = selected_locale.pk
|
||||
|
||||
# we are at the Root level, so get the locales from the current pages
|
||||
choose_url = reverse("wagtailadmin_choose_page")
|
||||
|
|
|
@ -224,6 +224,7 @@ class AdminPageChooser(BaseChooser):
|
|||
icon = "doc-empty-inverse"
|
||||
classname = "page-chooser"
|
||||
js_constructor = "PageChooser"
|
||||
page_instance = None
|
||||
|
||||
def __init__(
|
||||
self, target_models=None, can_choose_root=False, user_perms=None, **kwargs
|
||||
|
@ -301,6 +302,9 @@ class AdminPageChooser(BaseChooser):
|
|||
parent_id = value_data.get("parent_id")
|
||||
if parent_id is not None:
|
||||
opts["parentId"] = parent_id
|
||||
|
||||
if self.page_instance is not None:
|
||||
opts["instanceId"] = self.page_instance.id
|
||||
return opts
|
||||
|
||||
@property
|
||||
|
|
Ładowanie…
Reference in New Issue