Commit fa73a602 authored by fred's avatar fred

add new json stat view

parent 44e717f3
......@@ -6,6 +6,7 @@ urlpatterns = patterns('',
url(r'^$', 'newsletter.views.subscribe', name='newsletter-subscribe'),
url(r'^thanks/$', 'newsletter.views.thanks', name='newsletter-thanks'),
url(r'^(?P<token>[0-9a-f]{40})$', 'newsletter.views.confirmation', name='newsletter-confirmation'),
url(r'^stats/$', 'newsletter.views.stats'),
url(r'^unsubscription/$', unsubscription),
)
......
......@@ -21,6 +21,9 @@ from django.views.generic.base import TemplateView
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from django.views.generic.edit import CreateView, UpdateView
from django.views.decorators.csrf import csrf_exempt
from jsonresponse import to_json
from .forms import SubscribeForm, NewsletterForm
from .models import Subscriber, Newsletter
......@@ -126,3 +129,9 @@ class NewsletterUpdateView(UpdateView):
return super(NewsletterUpdateView, self).get_form(*args, **kwargs)
newsletter_update = NewsletterUpdateView.as_view()
@csrf_exempt
@to_json('api')
def stats(request) :
return {'registered': Subscriber.objects.filter(is_registered=True).count()}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment