1 # -*- coding: utf-8 -*-
2 from django.conf.urls import url
3 from django.contrib import admin
4 from django.http.response import HttpResponse
5 from django.views.decorators.cache import never_cache
7 from newsletter.models import Subscription
10 class SubscriptionAdmin(admin.ModelAdmin):
11 list_display = ('email', 'active')
12 list_filter = ('active',)
15 urls = super(SubscriptionAdmin, self).get_urls()
17 url(r'^extract/$', self.extract_subscribers, name='extract_subscribers'),
22 def extract_subscribers(self, request):
23 active_subscriptions = Subscription.objects.filter(active=True)
24 return HttpResponse('\n'.join(active_subscriptions.values_list('email', flat=True)),
25 content_type='text/plain')
28 admin.site.register(Subscription, SubscriptionAdmin)