Repository: evennia/evennia

Issue:
Giving multiple permissions to an account at once results in extra output lines
#### Brief summary of issue / Description of requested feature:
Giving multiple permissions to an account at once results in extra output lines

#### Steps to reproduce the issue / Reasons for adding feature:

1. Login to the superuser
2. Use @perm to give another account multiple permissions at the same time

#### Error output / Expected result of feature

**Expected result:**
A single output line showing that all the permissions have been given.

**Actual result:**
Multiple identical output lines all showing that all the permissions have been given.

**Example command:**
`@perm *Lumos=Immortals, Wizards, Builders`

**Example result:**
```
Permission 'Immortals, Wizards, Builders' given to Lumos (the Account).
Permission 'Immortals, Wizards, Builders' given to Lumos (the Account).
Permission 'Immortals, Wizards, Builders' given to Lumos (the Account).
```

#### Extra information, such as Evennia revision/repo/branch, operating system and ideas for how to solve / implement:

The number of duplicated lines seems to correspond to the number of permissions trying to be given. For example, if in the example above I'd only tried to provide two permissions, I would have received only two output lines.

**Environment:**
Master branch (pulled 2017-10-02 ~0200 GMT), server running on Windows 7. The client is connecting to the server via Telnet (MUSHclient)
Giving multiple permissions to an account at once results in extra output lines
#### Brief summary of issue / Description of requested feature:
Giving multiple permissions to an account at once results in extra output lines

#### Steps to reproduce the issue / Reasons for adding feature:

1. Login to the superuser
2. Use @perm to give another account multiple permissions at the same time

#### Error output / Expected result of feature

**Expected result:**
A single output line showing that all the permissions have been given.

**Actual result:**
Multiple identical output lines all showing that all the permissions have been given.

**Example command:**
`@perm *Lumos=Immortals, Wizards, Builders`

**Example result:**
```
Permission 'Immortals, Wizards, Builders' given to Lumos (the Account).
Permission 'Immortals, Wizards, Builders' given to Lumos (the Account).
Permission 'Immortals, Wizards, Builders' given to Lumos (the Account).
```

#### Extra information, such as Evennia revision/repo/branch, operating system and ideas for how to solve / implement:

The number of duplicated lines seems to correspond to the number of permissions trying to be given. For example, if in the example above I'd only tried to provide two permissions, I would have received only two output lines.

**Environment:**
Master branch (pulled 2017-10-02 ~0200 GMT), server running on Windows 7. The client is connecting to the server via Telnet (MUSHclient)


Discussion:
Found the issue. In admin.py, lines 532 and 533 are within the `for perm in self.rhslist:` block, but they reference `rhs` instead of `perm`.

I simple solution would be to just change `rhs` to `perm`. That way, each line will only show the specific permission being granted.

A more elegant solution would be to refactor the latter part of that function to properly group the result messages. 
@marco262 Thanks for the report and the diagnostic! Should be easy enough to fix. :) Also a good beginner-level fix for people interested in claiming a T-shirt in the [Hacktoberfest](https://hacktoberfest.digitalocean.com/)!
@Griatch May I take up this issue?
@dhruvhacks Sure, go ahead.
Found the issue. In admin.py, lines 532 and 533 are within the `for perm in self.rhslist:` block, but they reference `rhs` instead of `perm`.

I simple solution would be to just change `rhs` to `perm`. That way, each line will only show the specific permission being granted.

A more elegant solution would be to refactor the latter part of that function to properly group the result messages. 
@marco262 Thanks for the report and the diagnostic! Should be easy enough to fix. :) Also a good beginner-level fix for people interested in claiming a T-shirt in the [Hacktoberfest](https://hacktoberfest.digitalocean.com/)!
@Griatch May I take up this issue?
@dhruvhacks Sure, go ahead.

Resolving patch:
diff --git a/evennia/commands/default/admin.py b/evennia/commands/default/admin.py
--- a/evennia/commands/default/admin.py
+++ b/evennia/commands/default/admin.py
@@ -525,13 +525,13 @@ def func(self):
                     return
 
                 if perm in permissions:
-                    caller_result.append("\nPermission '%s' is already defined on %s." % (rhs, obj.name))
+                    caller_result.append("\nPermission '%s' is already defined on %s." % (perm, obj.name))
                 else:
                     obj.permissions.add(perm)
                     plystring = "the Account" if accountmode else "the Object/Character"
-                    caller_result.append("\nPermission '%s' given to %s (%s)." % (rhs, obj.name, plystring))
+                    caller_result.append("\nPermission '%s' given to %s (%s)." % (perm, obj.name, plystring))
                     target_result.append("\n%s gives you (%s, %s) the permission '%s'."
-                                         % (caller.name, obj.name, plystring, rhs))
+                                         % (caller.name, obj.name, plystring, perm))
         caller.msg("".join(caller_result).strip())
         if target_result:
             obj.msg("".join(target_result).strip())


Test patch: