changeset 918:886234943aed

Antispam app refactor. For Django 1.7.7 upgrade.
author Brian Neal <bgneal@gmail.com>
date Mon, 06 Apr 2015 20:14:10 -0500
parents 0365fdbb4d78
children 0b6bf9c5a982
files antispam/__init__.py antispam/apps.py
diffstat 2 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/antispam/__init__.py	Mon Apr 06 20:02:25 2015 -0500
+++ b/antispam/__init__.py	Mon Apr 06 20:14:10 2015 -0500
@@ -1,12 +1,6 @@
-from django.contrib.auth import views as auth_views
-
-from antispam.decorators import log_auth_failures
-import antispam.receivers
+default_app_config = 'antispam.apps.AntiSpamConfig'
 
 SPAM_PHRASE_KEY = "antispam.spam_phrases"
 BUSTED_MESSAGE = ("Your post has tripped our spam filter. Your account has "
         "been suspended pending a review of your post. If this was a mistake "
         "then we apologize; your account will be restored shortly.")
-
-# Install rate limiting on auth login
-auth_views.login = log_auth_failures('Login')(auth_views.login)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/antispam/apps.py	Mon Apr 06 20:14:10 2015 -0500
@@ -0,0 +1,16 @@
+from django.apps import AppConfig
+import django.contrib.auth.views
+
+from antispam.decorators import log_auth_failures
+
+
+class AntiSpamConfig(AppConfig):
+    name = 'antispam'
+    verbose_name = 'Anti-Spam'
+
+    def ready(self):
+        import antispam.receivers
+
+        # Install rate limiting on auth login
+        django.contrib.auth.views.login = log_auth_failures('Login')(
+                django.contrib.auth.views.login)