mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-16 19:21:10 +00:00
Pluralise content_type/pageType parameters for clarity
This commit is contained in:
parent
2f223e6a3b
commit
1410de5c7d
2 changed files with 11 additions and 13 deletions
|
|
@ -1,4 +1,4 @@
|
|||
function createPageChooser(id, pageType, openAtParentId) {
|
||||
function createPageChooser(id, pageTypes, openAtParentId) {
|
||||
var chooserElement = $('#' + id + '-chooser');
|
||||
var pageTitle = chooserElement.find('.title');
|
||||
var input = $('#' + id);
|
||||
|
|
@ -12,7 +12,7 @@ function createPageChooser(id, pageType, openAtParentId) {
|
|||
|
||||
ModalWorkflow({
|
||||
url: initialUrl,
|
||||
urlParams: { page_type: pageType.join(',') },
|
||||
urlParams: { page_type: pageTypes.join(',') },
|
||||
responses: {
|
||||
pageChosen: function(pageData) {
|
||||
input.val(pageData.id);
|
||||
|
|
|
|||
|
|
@ -110,23 +110,21 @@ class AdminChooser(WidgetWithScript, widgets.Input):
|
|||
|
||||
|
||||
class AdminPageChooser(AdminChooser):
|
||||
target_content_type = None
|
||||
choose_one_text = _('Choose a page')
|
||||
choose_another_text = _('Choose another page')
|
||||
link_to_chosen_text = _('Edit this page')
|
||||
|
||||
def __init__(self, content_type=None, **kwargs):
|
||||
super(AdminPageChooser, self).__init__(**kwargs)
|
||||
self.target_content_type = content_type or ContentType.objects.get_for_model(Page)
|
||||
|
||||
# Make sure target_content_type is a list or typle
|
||||
if self.target_content_type is not None:
|
||||
if not isinstance(self.target_content_type, (list, tuple)):
|
||||
self.target_content_type = [self.target_content_type]
|
||||
self.target_content_types = content_type or ContentType.objects.get_for_model(Page)
|
||||
# Make sure target_content_types is a list or tuple
|
||||
if not isinstance(self.target_content_types, (list, tuple)):
|
||||
self.target_content_types = [self.target_content_types]
|
||||
|
||||
def render_html(self, name, value, attrs):
|
||||
if len(self.target_content_type) == 1:
|
||||
model_class = self.target_content_type[0].model_class()
|
||||
if len(self.target_content_types) == 1:
|
||||
model_class = self.target_content_types[0].model_class()
|
||||
else:
|
||||
model_class = Page
|
||||
|
||||
|
|
@ -147,8 +145,8 @@ class AdminPageChooser(AdminChooser):
|
|||
page = value
|
||||
else:
|
||||
# Value is an ID look up object
|
||||
if len(self.target_content_type) == 1:
|
||||
model_class = self.target_content_type[0].model_class()
|
||||
if len(self.target_content_types) == 1:
|
||||
model_class = self.target_content_types[0].model_class()
|
||||
else:
|
||||
model_class = Page
|
||||
|
||||
|
|
@ -162,6 +160,6 @@ class AdminPageChooser(AdminChooser):
|
|||
'{app}.{model}'.format(
|
||||
app=content_type.app_label,
|
||||
model=content_type.model)
|
||||
for content_type in self.target_content_type
|
||||
for content_type in self.target_content_types
|
||||
]),
|
||||
parent=json.dumps(parent.id if parent else None))
|
||||
|
|
|
|||
Loading…
Reference in a new issue