-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes here and there #13
base: master
Are you sure you want to change the base?
Changes from 5 commits
e9ee397
c375854
018852c
53ca688
7656ede
6d018a6
73fdb6a
d37bed0
c0d26d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import threading | ||
from django.utils.deprecation import MiddlewareMixin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will fail on pre 1.10 Django. you should do something along these lines: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. implemented this. Thanks |
||
|
||
thread_data = threading.local() | ||
|
||
def get_request(): | ||
return getattr(thread_data, 'request', None) | ||
|
||
class RequestToThreadLocalMiddleware(object): | ||
class RequestToThreadLocalMiddleware(MiddlewareMixin): | ||
|
||
def process_request(self, request): | ||
thread_data.request = request |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from django.db import models | ||
from django.utils import datetime | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the change but shouldn't this be?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes indeed, it should. |
||
from django.contrib.auth.signals import user_logged_in | ||
import datetime | ||
|
||
|
@@ -14,14 +15,14 @@ class LoginAttemptLogger(object): | |
def reset(self, username): | ||
defaults = { | ||
'count': 0, | ||
'timestamp': datetime.datetime.now() | ||
'timestamp': timezone.now() | ||
} | ||
LoginAttempt.objects.update_or_create(username=username, defaults=defaults) | ||
|
||
def increment(self, username): | ||
obj, created = LoginAttempt.objects.get_or_create(username=username) | ||
obj.count += 1 | ||
obj.timestamp = datetime.datetime.now() | ||
obj.timestamp = timezone.now() | ||
obj.save() | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
The current version seems more flexible to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in retrospect, I can seem to remember why.