Porównaj commity

...

7 Commity

Autor SHA1 Wiadomość Data
Abdelrahman Hamada bf8236f780
Merge 92a0b19805 into 7c6187f06c 2024-04-27 12:39:19 +00:00
Abdelrahman 92a0b19805 styling 2024-03-06 04:09:16 +02:00
Abdelrahman 5c40147547 another approach 2024-03-06 04:01:32 +02:00
Abdelrahman 62c597b786 Added selected locale if page not root 2024-02-15 04:49:06 +02:00
Abdelrahman 8027cad6f0 The page instance is now binded to the widget instead of the form itself 2024-02-15 04:22:26 +02:00
Abdelrahman 65a97af3d7 Tests passed 2024-02-13 07:20:08 +02:00
Abdelrahman 589b49d6bf form instance is binded to the widget to retrieve page instance 2024-02-13 04:02:57 +02:00
5 zmienionych plików z 27 dodań i 2 usunięć

Wyświetl plik

@ -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;

Wyświetl plik

@ -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;
}
}

Wyświetl plik

@ -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"]

Wyświetl plik

@ -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")

Wyświetl plik

@ -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