filter attributs does not necessary exists

This commit is contained in:
Valentin Samir 2015-06-05 00:14:56 +02:00
parent 02fd557216
commit 1695cd24ea

View File

@ -175,8 +175,8 @@ class ServicePattern(models.Model):
if self.restrict_users and not self.usernames.filter(value=user.username): if self.restrict_users and not self.usernames.filter(value=user.username):
raise BadUsername() raise BadUsername()
for filtre in self.filters.all(): for filtre in self.filters.all():
if isinstance(user.attributs[filtre.attribut], list): if isinstance(user.attributs.get(filtre.attribut, []), list):
attrs = user.attributs[filtre.attribut] attrs = user.attributs.get(filtre.attribut, [])
else: else:
attrs = [user.attributs[filtre.attribut]] attrs = [user.attributs[filtre.attribut]]
for value in attrs: for value in attrs: