kopia lustrzana https://github.com/wagtail/wagtail
fix modeladmin delete view message
rodzic
cd0f8381cd
commit
3ba4064d89
|
@ -72,6 +72,7 @@ Changelog
|
|||
* Fix: Fixed UnicodeEncodeError in wagtailforms when downloading a CSV for a form containing non-ASCII field labels on Python 2 (Mikalai Radchuk)
|
||||
* Fix: Server errors during search indexing on creating / updating / deleting a model are now logged, rather than causing the overall operation to fail (Karl Hobley)
|
||||
* Fix: Objects are now correctly removed from search indexes on deletion (Karl Hobley)
|
||||
* Fix: Confirmation message on the ModelAdmin delete view no longer errors if the model's string representation depends on the primary key (Yannick Chabbert)
|
||||
|
||||
|
||||
1.4.5 (19.05.2016)
|
||||
|
|
|
@ -22,3 +22,4 @@ Bug fixes
|
|||
* Now page chooser (in a rich text editor) opens up at the link's parent page, rather than at the page itself (Matt Westcott)
|
||||
* Reverted fix for explorer menu scrolling with page content, as it blocked access to menus that exceed screen height
|
||||
* Image listing in the image chooser no longer becomes unpaginated after an invalid upload form submission (Stephen Rice)
|
||||
* Confirmation message on the ModelAdmin delete view no longer errors if the model's string representation depends on the primary key (Yannick Chabbert)
|
||||
|
|
|
@ -316,6 +316,17 @@ class TestDeleteViewWithProtectedRelation(TestCase, WagtailTestUtils):
|
|||
self.assertFalse(Author.objects.filter(id=4).exists())
|
||||
|
||||
|
||||
class TestDeleteViewModelReprPrimary(TestCase, WagtailTestUtils):
|
||||
fixtures = ['modeladmintest_test.json']
|
||||
|
||||
def setUp(self):
|
||||
self.login()
|
||||
|
||||
def test_delete(self):
|
||||
response = self.client.post('/admin/modeladmintest/token/delete/boom/')
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
|
||||
class TestEditorAccess(TestCase):
|
||||
fixtures = ['modeladmintest_test.json']
|
||||
expected_status_code = 403
|
||||
|
|
|
@ -778,11 +778,10 @@ class DeleteView(InstanceSpecificView):
|
|||
|
||||
def post(self, request, *args, **kwargs):
|
||||
try:
|
||||
msg = _("{model} '{instance}' deleted.").format(
|
||||
model=self.verbose_name, instance=self.instance)
|
||||
self.delete_instance()
|
||||
messages.success(
|
||||
request,
|
||||
_("{model} '{instance}' deleted.").format(
|
||||
model=self.verbose_name, instance=self.instance))
|
||||
messages.success(request, msg)
|
||||
return redirect(self.index_url)
|
||||
except models.ProtectedError:
|
||||
linked_objects = []
|
||||
|
|
|
@ -62,5 +62,12 @@
|
|||
"title": "The Chronicles of Narnia",
|
||||
"author_id": 3
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": "boom",
|
||||
"model": "modeladmintest.token",
|
||||
"fields": {
|
||||
"key": "boom"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.7 on 2016-06-07 11:22
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('modeladmintest', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Token',
|
||||
fields=[
|
||||
('key', models.CharField(max_length=40, primary_key=True, serialize=False)),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -22,3 +22,11 @@ class Book(models.Model, index.Indexed):
|
|||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Token(models.Model):
|
||||
key = models.CharField(max_length=40, primary_key=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.key
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import absolute_import, unicode_literals
|
|||
from wagtail.contrib.modeladmin.options import ModelAdmin, ModelAdminGroup, modeladmin_register
|
||||
from wagtail.tests.testapp.models import BusinessChild, EventPage, SingleEventPage
|
||||
|
||||
from .models import Author, Book
|
||||
from .models import Author, Book, Token
|
||||
|
||||
|
||||
class AuthorModelAdmin(ModelAdmin):
|
||||
|
@ -26,6 +26,11 @@ class BookModelAdmin(ModelAdmin):
|
|||
inspect_view_fields_exclude = ('title', )
|
||||
|
||||
|
||||
class TokenModelAdmin(ModelAdmin):
|
||||
model = Token
|
||||
list_display = ('key',)
|
||||
|
||||
|
||||
class EventPageAdmin(ModelAdmin):
|
||||
model = EventPage
|
||||
list_display = ('title', 'date_from', 'audience')
|
||||
|
@ -53,5 +58,6 @@ class BusinessChildAdmin(ModelAdmin):
|
|||
|
||||
modeladmin_register(AuthorModelAdmin)
|
||||
modeladmin_register(BookModelAdmin)
|
||||
modeladmin_register(TokenModelAdmin)
|
||||
modeladmin_register(EventsAdminGroup)
|
||||
modeladmin_register(BusinessChildAdmin)
|
||||
|
|
Ładowanie…
Reference in New Issue