From 831bb299f9de37638080b1d1690ba2a643169d31 Mon Sep 17 00:00:00 2001 From: bc Wong Date: Sun, 24 Jan 2016 17:28:20 -0800 Subject: [PATCH] Always define the task to store login attempt Adding function definitions based on config values makes testing hard. The task function is always there, and we choose to call it depending on config during runtime. --- defender/tasks.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/defender/tasks.py b/defender/tasks.py index db3498a..b7d9ff9 100644 --- a/defender/tasks.py +++ b/defender/tasks.py @@ -1,15 +1,14 @@ -from . import config from .data import store_login_attempt # not sure how to get this to look better. ideally we want to dynamically # apply the celery decorator based on the USE_CELERY setting. -if config.USE_CELERY: - from celery import shared_task +from celery import shared_task - @shared_task() - def add_login_attempt_task(user_agent, ip_address, username, - http_accept, path_info, login_valid): - """ Create a record for the login attempt """ - store_login_attempt(user_agent, ip_address, username, - http_accept, path_info, login_valid) + +@shared_task() +def add_login_attempt_task(user_agent, ip_address, username, + http_accept, path_info, login_valid): + """ Create a record for the login attempt """ + store_login_attempt(user_agent, ip_address, username, + http_accept, path_info, login_valid)