diff --git a/tests/admin_changelist/admin.py b/tests/admin_changelist/admin.py
index b2bd578..2feb4a9 100644
a
|
b
|
|
1 | 1 | from django.contrib import admin |
2 | 2 | from django.core.paginator import Paginator |
| 3 | from django.core.urlresolvers import reverse |
3 | 4 | from django.contrib.auth.admin import UserAdmin |
4 | 5 | from django.contrib.auth.models import User |
| 6 | from django.http import HttpResponseRedirect |
5 | 7 | |
6 | | from .models import Event, Child, Parent, Swallow |
| 8 | from .models import Event, Child, Messenger, Parent, Swallow |
7 | 9 | |
8 | 10 | |
9 | 11 | site = admin.AdminSite(name="admin") |
… |
… |
class DynamicSearchFieldsChildAdmin(admin.ModelAdmin):
|
126 | 128 | search_fields = super(DynamicSearchFieldsChildAdmin, self).get_search_fields(request) |
127 | 129 | search_fields += ('age',) |
128 | 130 | return search_fields |
| 131 | |
| 132 | |
| 133 | class MessengerAdmin(admin.ModelAdmin): |
| 134 | actions = ['show_message'] |
| 135 | |
| 136 | def show_message(self, request, queryset): |
| 137 | self.message_user(request, "Hey there!") |
| 138 | return HttpResponseRedirect(reverse('admin:admin_changelist_messenger_changelist')) |
| 139 | |
| 140 | site.register(Messenger, MessengerAdmin) |
diff --git a/tests/admin_changelist/models.py b/tests/admin_changelist/models.py
index 76249b2..24ab9fa 100644
a
|
b
|
class OrderedObject(models.Model):
|
105 | 105 | |
106 | 106 | class CustomIdUser(models.Model): |
107 | 107 | uuid = models.AutoField(primary_key=True) |
| 108 | |
| 109 | |
| 110 | class Messenger(models.Model): |
| 111 | name = models.CharField(max_length=128) |
diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py
index 5ee5a51..13543bc 100644
a
|
b
|
from __future__ import unicode_literals
|
3 | 3 | import datetime |
4 | 4 | |
5 | 5 | from django.contrib import admin |
| 6 | from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME |
6 | 7 | from django.contrib.admin.options import IncorrectLookupParameters |
7 | 8 | from django.contrib.admin.templatetags.admin_list import pagination |
8 | 9 | from django.contrib.admin.views.main import ChangeList, SEARCH_VAR, ALL_VAR |
… |
… |
from .admin import (ChildAdmin, QuartetAdmin, BandAdmin, ChordsBandAdmin,
|
23 | 24 | DynamicSearchFieldsChildAdmin, NoListDisplayLinksParentAdmin) |
24 | 25 | from .models import (Event, Child, Parent, Genre, Band, Musician, Group, |
25 | 26 | Quartet, Membership, ChordsMusician, ChordsBand, Invitation, Swallow, |
26 | | UnorderedObject, OrderedObject, CustomIdUser) |
| 27 | UnorderedObject, OrderedObject, CustomIdUser, Messenger) |
27 | 28 | |
28 | 29 | |
29 | 30 | @override_settings(ROOT_URLCONF="admin_changelist.urls") |
… |
… |
class AdminLogNodeTestCase(TestCase):
|
664 | 665 | self.assertEqual(template.render(context), '') |
665 | 666 | |
666 | 667 | |
| 668 | @override_settings(ROOT_URLCONF="admin_changelist.urls") |
| 669 | class AdminShowMessageLogsUserOut(TestCase): |
| 670 | |
| 671 | def test_show_message_logs_user_out(self): |
| 672 | messenger = Messenger.objects.create(name="Hermès") |
| 673 | |
| 674 | self.user = User.objects.create_superuser('user', 'user@website', 'pass') |
| 675 | self.client.login(username='user', password='pass') |
| 676 | |
| 677 | response = self.client.get(reverse('admin:admin_changelist_messenger_changelist')) |
| 678 | self.assertEqual(response.status_code, 200) |
| 679 | |
| 680 | response = self.client.post(reverse('admin:admin_changelist_messenger_changelist'), { |
| 681 | 'action': 'show_message', |
| 682 | ACTION_CHECKBOX_NAME: [str(messenger.pk)], |
| 683 | }) |
| 684 | self.assertEqual(response.status_code, 302) |
| 685 | |
| 686 | response = self.client.get(reverse('admin:admin_changelist_messenger_changelist')) |
| 687 | self.assertEqual(response.status_code, 200) |
| 688 | |
| 689 | |
667 | 690 | @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), |
668 | 691 | ROOT_URLCONF="admin_changelist.urls") |
669 | 692 | class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase): |