From ad48d601165e765f471383356a7f873f2233d381 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Mon, 8 Jun 2015 17:32:00 +0200 Subject: [PATCH] do not override variable. --- modoboa/core/models.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modoboa/core/models.py b/modoboa/core/models.py index eb9eb9be3..0095c0fcc 100644 --- a/modoboa/core/models.py +++ b/modoboa/core/models.py @@ -340,14 +340,15 @@ class User(PermissionsMixin): if len(row) < 7: raise BadRequest(_("Invalid line")) - role = row[6].strip() + desired_role = row[6].strip() if not user.is_superuser: allowed_roles = get_account_roles(user) allowed_roles = [role[0] for role in allowed_roles] - if role not in allowed_roles: - raise PermDeniedException( - _("You can't import an account with a role greater than yours") - ) + if desired_role not in allowed_roles: + raise PermDeniedException(_( + "You can't import an account with a role greater than " + "yours" + )) self.username = row[1].strip() try: @@ -357,7 +358,7 @@ class User(PermissionsMixin): else: raise Conflict - if role == "SimpleUsers": + if desired_role == "SimpleUsers": if len(row) < 8 or not row[7].strip(): raise BadRequest( _("The simple user '%s' must have a valid email address" @@ -377,7 +378,7 @@ class User(PermissionsMixin): self.last_name = row[4].strip() self.is_active = (row[5].strip() in ["True", "1", "yes", "y"]) self.save(creator=user) - self.set_role(role) + self.set_role(desired_role) if len(row) < 8: return events.raiseEvent("AccountImported", user, self, row[7:])