File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 88from django .contrib .auth .models import AnonymousUser
99from django .core .cache import cache
1010from django .core .urlresolvers import reverse , NoReverseMatch
11- from django .db .utils import DatabaseError
11+ from django .db .utils import DatabaseError , IntegrityError
1212from django .http import Http404
13- from django .utils import timezone
13+ from django .db import transaction
1414
1515from tracking import utils
1616from tracking .models import Visitor , UntrackedUserAgent , BannedIP
@@ -143,7 +143,11 @@ def process_request(self, request):
143143 visitor .page_views += 1
144144 visitor .last_update = now
145145 try :
146+ sid = transaction .savepoint ()
146147 visitor .save ()
148+ transaction .savepoint_commit (sid )
149+ except IntegrityError :
150+ transaction .savepoint_rollback (sid )
147151 except DatabaseError :
148152 log .error ('There was a problem saving visitor information:\n %s\n \n %s' % (traceback .format_exc (), locals ()))
149153
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ def active(self, timeout=None):
3131 now = timezone .now ()
3232 cutoff = now - timedelta (minutes = timeout )
3333
34- return self .get_query_set ().filter (last_update__gte = cutoff )
34+ return self .get_queryset ().filter (last_update__gte = cutoff )
3535
3636class Visitor (models .Model ):
3737 session_key = models .CharField (max_length = 40 )
@@ -128,7 +128,7 @@ class Meta:
128128 verbose_name_plural = _ ('Untracked User-Agents' )
129129
130130class BannedIP (models .Model ):
131- ip_address = models .IPAddressField ('IP Address' , help_text = _ ('The IP address that should be banned' ))
131+ ip_address = models .GenericIPAddressField ('IP Address' , help_text = _ ('The IP address that should be banned' ))
132132
133133 def __unicode__ (self ):
134134 return self .ip_address
You can’t perform that action at this time.
0 commit comments