~widelands-dev/widelands-website/django_staticfiles

« back to all changes in this revision

Viewing changes to tracking/listeners.py

  • Committer: franku
  • Date: 2016-12-13 18:28:51 UTC
  • mto: This revision was merged to the branch mainline in revision 443.
  • Revision ID: somal@arcor.de-20161213182851-bo5ebf8pdvw5beua
run the script

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
else:
13
13
 
14
14
    def refresh_untracked_user_agents(sender, instance, created=False, **kwargs):
15
 
        """Updates the cache of user agents that we don't track"""
 
15
        """Updates the cache of user agents that we don't track."""
16
16
 
17
17
        log.debug('Updating untracked user agents cache')
18
18
        cache.set('_tracking_untracked_uas',
19
 
            UntrackedUserAgent.objects.all(),
20
 
            3600)
 
19
                  UntrackedUserAgent.objects.all(),
 
20
                  3600)
21
21
 
22
22
    def refresh_banned_ips(sender, instance, created=False, **kwargs):
23
 
        """Updates the cache of banned IP addresses"""
 
23
        """Updates the cache of banned IP addresses."""
24
24
 
25
25
        log.debug('Updating banned IP cache')
26
26
        cache.set('_tracking_banned_ips',
27
 
            [b.ip_address for b in BannedIP.objects.all()],
28
 
            3600)
 
27
                  [b.ip_address for b in BannedIP.objects.all()],
 
28
                  3600)
29
29
 
30
30
    post_save.connect(refresh_untracked_user_agents, sender=UntrackedUserAgent)
31
 
    post_delete.connect(refresh_untracked_user_agents, sender=UntrackedUserAgent)
 
31
    post_delete.connect(refresh_untracked_user_agents,
 
32
                        sender=UntrackedUserAgent)
32
33
 
33
34
    post_save.connect(refresh_banned_ips, sender=BannedIP)
34
35
    post_delete.connect(refresh_banned_ips, sender=BannedIP)