bcb789761abf89ca6f310cd85fb19826eb5df398
[wolnelektury.git] / src / newsletter / admin.py
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
6 from newsletter.models import Subscription
7
8
9 class SubscriptionAdmin(admin.ModelAdmin):
10     def get_urls(self):
11         urls = super(SubscriptionAdmin, self).get_urls()
12         my_urls = [
13             url(r'^extract/$', self.extract_subscribers, name='extract_subscribers'),
14         ]
15         return my_urls + urls
16
17     def extract_subscribers(self, request):
18         return HttpResponse(',\n'.join(Subscription.objects.values_list('email', flat=True)), content_type='text/plain')
19
20
21 admin.site.register(Subscription, SubscriptionAdmin)