1 # -*- coding: utf-8 -*-
2 from django.conf.urls import url
3 from django.contrib import admin
4 from django.http.response import HttpResponse
6 from newsletter.models import Subscription
9 class SubscriptionAdmin(admin.ModelAdmin):
11 urls = super(SubscriptionAdmin, self).get_urls()
13 url(r'^extract/$', self.extract_subscribers, name='extract_subscribers'),
17 def extract_subscribers(self, request):
18 active_subscriptions = Subscription.objects.filter(active=True)
19 return HttpResponse(',\n'.join(active_subscriptions.values_list('email', flat=True)),
20 content_type='text/plain')
23 admin.site.register(Subscription, SubscriptionAdmin)