<commit_before>from django.contrib import admin
from django.conf.urls.defaults import patterns, url
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext as _
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse

from .models import Newsletter, NewsletterItem, NewsletterSubscriber, NewsletterList


class NewsletterAdmin(admin.ModelAdmin):
    change_form_template = 'admin/courriers/newsletter/change_form.html'

    list_display = ('name', 'headline', 'languages', 'published_at', 'status', 'newsletter_list',)
    list_filter = ('published_at', 'status',)

    def get_urls(self):
        urls = super(NewsletterAdmin, self).get_urls()
        my_urls = patterns(
            '',
            url(r'^send/(?P<newsletter_id>(\d+))/$',
                self.send_newsletter,
                name="send_newsletter")
        )
        return my_urls + urls

    def send_newsletter(self, request, newsletter_id):
        from courriers.backends import get_backend

        backend_klass = get_backend()
        backend = backend_klass()

        newsletter = get_object_or_404(Newsletter, pk=newsletter_id)
        backend.send_mails(newsletter)

        self.message_user(request, _('The newsletter %s has been sent.') % newsletter)
        return HttpResponseRedirect(reverse('admin:courriers_newsletter_change', args=(newsletter.id,)))


class NewsletterItemAdmin(admin.ModelAdmin):
    list_display = ('description', 'content_type', 'newsletter',)


class NewsletterSubscriberAdmin(admin.ModelAdmin):
    list_display = ('email', 'user', 'lang', 'is_unsubscribed',)
    list_filter = ('is_unsubscribed',)


class NewsletterListAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug', 'languages', 'created_at',)


admin.site.register(NewsletterList, NewsletterListAdmin)
admin.site.register(NewsletterItem, NewsletterItemAdmin)
admin.site.register(NewsletterSubscriber, NewsletterSubscriberAdmin)
admin.site.register(NewsletterList, NewsletterListAdmin)<commit_msg>Update admin.py<commit_after>from django.contrib import admin
from django.conf.urls.defaults import patterns, url
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext as _
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse

from .models import Newsletter, NewsletterItem, NewsletterSubscriber, NewsletterList


class NewsletterAdmin(admin.ModelAdmin):
    change_form_template = 'admin/courriers/newsletter/change_form.html'

    list_display = ('name', 'headline', 'languages', 'published_at', 'status', 'newsletter_list',)
    list_filter = ('published_at', 'status',)

    def get_urls(self):
        urls = super(NewsletterAdmin, self).get_urls()
        my_urls = patterns(
            '',
            url(r'^send/(?P<newsletter_id>(\d+))/$',
                self.send_newsletter,
                name="send_newsletter")
        )
        return my_urls + urls

    def send_newsletter(self, request, newsletter_id):
        from courriers.backends import get_backend

        backend_klass = get_backend()
        backend = backend_klass()

        newsletter = get_object_or_404(Newsletter, pk=newsletter_id)
        backend.send_mails(newsletter)

        self.message_user(request, _('The newsletter %s has been sent.') % newsletter)
        return HttpResponseRedirect(reverse('admin:courriers_newsletter_change', args=(newsletter.id,)))


class NewsletterItemAdmin(admin.ModelAdmin):
    list_display = ('description', 'content_type', 'newsletter',)


class NewsletterSubscriberAdmin(admin.ModelAdmin):
    list_display = ('email', 'user', 'lang', 'is_unsubscribed',)
    list_filter = ('is_unsubscribed',)


class NewsletterListAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug', 'languages', 'created_at',)


admin.site.register(Newsletter, Newsletter)
admin.site.register(NewsletterItem, NewsletterItemAdmin)
admin.site.register(NewsletterSubscriber, NewsletterSubscriberAdmin)
admin.site.register(NewsletterList, NewsletterListAdmin)
{'fraction_non_alphanumeric': 0.10947832476120499, 'fraction_numerical': 0.0029390154298310064, 'mean_word_length': 4.541383989145183, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5274326', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1189, 'n_words': 234}