diff --git a/pandora/user/managers.py b/pandora/user/managers.py index 4819990fb..5db9b4979 100644 --- a/pandora/user/managers.py +++ b/pandora/user/managers.py @@ -21,8 +21,9 @@ def parseCondition(condition, user): exclude = False if k == 'level': - if v in settings.CONFIG['userLevels']: - v = settings.CONFIG['userLevels'].index(v) + levels = ['robot'] + settings.CONFIG['userLevels'] + if v in levels: + v = levels.index(v) - 1 else: v = 0 key = '%s%s' % (k, { diff --git a/pandora/user/models.py b/pandora/user/models.py index 8b9a7d8c9..8dfa7f4ef 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -56,6 +56,8 @@ class SessionData(models.Model): self.browser = None if not self.system: self.system = None + if ua.get('robot'): + self.level = -1 if self.ip: try: g = GeoIP() @@ -82,7 +84,6 @@ class SessionData(models.Model): self.groupssort = ''.join([g.name for g in self.user.groups.all()]) self.numberoflists = self.user.lists.count() else: - self.level = 0 self.groupssort = None super(SessionData, self).save(*args, **kwargs) @@ -124,7 +125,7 @@ class SessionData(models.Model): 'ip': self.ip, 'id': self.get_id(), 'lastseen': self.lastseen, - 'level': 'guest', + 'level': ua.get('robot') and 'robot' or 'guest', 'location': self.location, 'newsletter': False, 'notes': '',