mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-15 02:33:13 +00:00
Allow AdminPageChooser edit link to be hidden, and hide it on the page permissions interface
This commit is contained in:
parent
7c26217ea0
commit
7785beecc6
3 changed files with 8 additions and 2 deletions
|
|
@ -17,7 +17,9 @@
|
|||
<li><button type="button" class="action-clear button-small button-secondary">{{ widget.clear_choice_text }}</button></li>
|
||||
{% endif %}
|
||||
<li><button type="button" class="action-choose button-small button-secondary">{{ widget.choose_another_text }}</button></li>
|
||||
<li><a href="{% block edit_chosen_item_url %}#{% endblock %}" class="edit-link button button-small button-secondary" target="_blank">{{ widget.link_to_chosen_text }}</a></li>
|
||||
{% if widget.show_edit_link %}
|
||||
<li><a href="{% block edit_chosen_item_url %}#{% endblock %}" class="edit-link button button-small button-secondary" target="_blank">{{ widget.link_to_chosen_text }}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ class AdminChooser(WidgetWithScript, widgets.Input):
|
|||
choose_another_text = _("Choose another item")
|
||||
clear_choice_text = _("Clear choice")
|
||||
link_to_chosen_text = _("Edit this item")
|
||||
show_edit_link = True
|
||||
|
||||
def get_instance(self, model_class, value):
|
||||
# helper method for cleanly turning 'value' into an instance object
|
||||
|
|
@ -106,6 +107,8 @@ class AdminChooser(WidgetWithScript, widgets.Input):
|
|||
self.clear_choice_text = kwargs.pop('clear_choice_text')
|
||||
if 'link_to_chosen_text' in kwargs:
|
||||
self.link_to_chosen_text = kwargs.pop('link_to_chosen_text')
|
||||
if 'show_edit_link' in kwargs:
|
||||
self.show_edit_link = kwargs.pop('show_edit_link')
|
||||
super(AdminChooser, self).__init__(**kwargs)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -229,7 +229,8 @@ class GroupForm(forms.ModelForm):
|
|||
|
||||
|
||||
class GroupPagePermissionForm(forms.ModelForm):
|
||||
page = forms.ModelChoiceField(queryset=Page.objects.all(), widget=AdminPageChooser())
|
||||
page = forms.ModelChoiceField(queryset=Page.objects.all(),
|
||||
widget=AdminPageChooser(show_edit_link=False))
|
||||
|
||||
class Meta:
|
||||
model = GroupPagePermission
|
||||
|
|
|
|||
Loading…
Reference in a new issue