...
 
Commits (2)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('newsletter', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='subscriber',
name='email',
field=models.EmailField(unique=True, max_length=254),
),
]
from django.conf.urls import *
from django.conf.urls import url
from django.conf import settings
from .views import unsubscription
from .views import (subscribe, thanks, confirmation, stats, unsubscription,
newsletter_list, newsletter_create, newsletter_view, newsletter_update,
newsletter_send)
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'),
urlpatterns = [
url(r'^$', subscribe, name='newsletter-subscribe'),
url(r'^thanks/$', thanks, name='newsletter-thanks'),
url(r'^(?P<token>[0-9a-f]{40})$', confirmation, name='newsletter-confirmation'),
url(r'^stats/$', stats),
url(r'^unsubscription/$', unsubscription),
)
]
management_patterns = patterns('newsletter.views',
url(r'^$', 'newsletter_list', name='newsletter-list'),
url(r'^add$', 'newsletter_create', name='newsletter-create'),
url(r'^(?P<pk>\d+)/$', 'newsletter_view', name='newsletter-view'),
url(r'^(?P<pk>\d+)/edit$', 'newsletter_update', name='newsletter-edit'),
url(r'^(?P<pk>\d+)/send$', 'newsletter_send', name='newsletter-send'),
)
management_patterns = [
url(r'^$', newsletter_list, name='newsletter-list'),
url(r'^add$', newsletter_create, name='newsletter-create'),
url(r'^(?P<pk>\d+)/$', newsletter_view, name='newsletter-view'),
url(r'^(?P<pk>\d+)/edit$', newsletter_update, name='newsletter-edit'),
url(r'^(?P<pk>\d+)/send$', newsletter_send, name='newsletter-send'),
]
......@@ -13,6 +13,7 @@ from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse_lazy
from django.db import models, IntegrityError
from django.http import JsonResponse
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext as _
......@@ -22,8 +23,6 @@ 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
......@@ -143,6 +142,5 @@ class NewsletterSendView(RedirectView):
newsletter_send = NewsletterSendView.as_view()
@csrf_exempt
@to_json('api')
def stats(request) :
return {'registered': Subscriber.objects.filter(is_registered=True).count()}
return JsonResponse({'registered': Subscriber.objects.filter(is_registered=True).count()})