From 9629e7111b6b04c602db7ec77807e15b87eec96e Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Thu, 25 Oct 2012 00:09:49 -0400 Subject: [PATCH] already_sent_mirrored_message: Reduce code duplication and eliminate extremely long lines. (imported from commit 29a08b1757c1bb3af1f82222fd7150db05f86034) --- zephyr/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zephyr/views.py b/zephyr/views.py index f7a1bcf798..099d35793c 100644 --- a/zephyr/views.py +++ b/zephyr/views.py @@ -483,11 +483,13 @@ def is_super_user_api(request): return request.POST.get("api-key") == "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" def already_sent_mirrored_message(request): + utc_from_ts = datetime.datetime.utcfromtimestamp + req_time = float(request.POST['time']) email = request.POST['sender'].lower() if Message.objects.filter(sender__user__email=email, content=request.POST['content'], - pub_date__gt=datetime.datetime.utcfromtimestamp(float(request.POST['time']) - 10).replace(tzinfo=utc), - pub_date__lt=datetime.datetime.utcfromtimestamp(float(request.POST['time']) + 10).replace(tzinfo=utc)): + pub_date__gt=utc_from_ts(req_time - 10).replace(tzinfo=utc), + pub_date__lt=utc_from_ts(req_time + 10).replace(tzinfo=utc)): return True return False