support robots in findUsers api

This commit is contained in:
j 2012-03-26 13:58:33 +02:00
parent 7db8135b61
commit a562ec428a
2 changed files with 6 additions and 4 deletions

View file

@ -21,8 +21,9 @@ def parseCondition(condition, user):
exclude = False exclude = False
if k == 'level': if k == 'level':
if v in settings.CONFIG['userLevels']: levels = ['robot'] + settings.CONFIG['userLevels']
v = settings.CONFIG['userLevels'].index(v) if v in levels:
v = levels.index(v) - 1
else: else:
v = 0 v = 0
key = '%s%s' % (k, { key = '%s%s' % (k, {

View file

@ -56,6 +56,8 @@ class SessionData(models.Model):
self.browser = None self.browser = None
if not self.system: if not self.system:
self.system = None self.system = None
if ua.get('robot'):
self.level = -1
if self.ip: if self.ip:
try: try:
g = GeoIP() g = GeoIP()
@ -82,7 +84,6 @@ class SessionData(models.Model):
self.groupssort = ''.join([g.name for g in self.user.groups.all()]) self.groupssort = ''.join([g.name for g in self.user.groups.all()])
self.numberoflists = self.user.lists.count() self.numberoflists = self.user.lists.count()
else: else:
self.level = 0
self.groupssort = None self.groupssort = None
super(SessionData, self).save(*args, **kwargs) super(SessionData, self).save(*args, **kwargs)
@ -124,7 +125,7 @@ class SessionData(models.Model):
'ip': self.ip, 'ip': self.ip,
'id': self.get_id(), 'id': self.get_id(),
'lastseen': self.lastseen, 'lastseen': self.lastseen,
'level': 'guest', 'level': ua.get('robot') and 'robot' or 'guest',
'location': self.location, 'location': self.location,
'newsletter': False, 'newsletter': False,
'notes': '', 'notes': '',