summaryrefslogtreecommitdiff
path: root/tests/regressiontests/admin_views/models.py
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-03-23 20:22:56 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-03-23 20:22:56 +0000
commit44f3080226888eb709cc6e027321647964ebe64e (patch)
tree879d62de3f7c3ce91956a1b26d4f0f6dd41bc1a8 /tests/regressiontests/admin_views/models.py
parent4e2533436ef08ce81516e4cfd47ccbb1dddac5f8 (diff)
Fixed #10505: added support for bulk admin actions, including a globally-available "delete selected" action. See the documentation for details.
This work started life as Brian Beck's "django-batchadmin." It was rewritten for inclusion in Django by Alex Gaynor, Jannis Leidel (jezdez), and Martin Mahner (bartTC). Thanks, guys! git-svn-id: http://code.djangoproject.com/svn/django/trunk@10121 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/admin_views/models.py')
-rw-r--r--tests/regressiontests/admin_views/models.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_views/models.py b/tests/regressiontests/admin_views/models.py
index eeaf039444..e5e112fa43 100644
--- a/tests/regressiontests/admin_views/models.py
+++ b/tests/regressiontests/admin_views/models.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django.db import models
from django.contrib import admin
+from django.core.mail import EmailMessage
class Section(models.Model):
"""
@@ -199,6 +200,41 @@ class PersonaAdmin(admin.ModelAdmin):
BarAccountAdmin
)
+class Subscriber(models.Model):
+ name = models.CharField(blank=False, max_length=80)
+ email = models.EmailField(blank=False, max_length=175)
+
+ def __unicode__(self):
+ return "%s (%s)" % (self.name, self.email)
+
+class SubscriberAdmin(admin.ModelAdmin):
+ actions = ['delete_selected', 'mail_admin']
+
+ def mail_admin(self, request, selected):
+ EmailMessage(
+ 'Greetings from a ModelAdmin action',
+ 'This is the test email from a admin action',
+ 'from@example.com',
+ ['to@example.com']
+ ).send()
+
+class ExternalSubscriber(Subscriber):
+ pass
+
+def external_mail(request, selected):
+ EmailMessage(
+ 'Greetings from a function action',
+ 'This is the test email from a function action',
+ 'from@example.com',
+ ['to@example.com']
+ ).send()
+
+def redirect_to(request, selected):
+ from django.http import HttpResponseRedirect
+ return HttpResponseRedirect('/some-where-else/')
+
+class ExternalSubscriberAdmin(admin.ModelAdmin):
+ actions = [external_mail, redirect_to]
admin.site.register(Article, ArticleAdmin)
admin.site.register(CustomArticle, CustomArticleAdmin)
@@ -208,6 +244,8 @@ admin.site.register(Color)
admin.site.register(Thing, ThingAdmin)
admin.site.register(Person, PersonAdmin)
admin.site.register(Persona, PersonaAdmin)
+admin.site.register(Subscriber, SubscriberAdmin)
+admin.site.register(ExternalSubscriber, ExternalSubscriberAdmin)
# We intentionally register Promo and ChapterXtra1 but not Chapter nor ChapterXtra2.
# That way we cover all four cases: