Repository: saleor/saleor

Issue:
Can't query permission group details
### Steps to reproduce the problem
1. https://github.com/mirumee/saleor-dashboard/pull/406
2. Build current master, run API, run migrations and populatedb
3. Run query:

```
fragment PermissionGroupFragment on Group {
  id
  name
  users {
    id
    firstName
    lastName
    __typename
  }
  __typename
}

fragment PermissionFragment on PermissionDisplay {
  code
  name
  __typename
}

fragment StaffMemberFragment on User {
  id
  email
  firstName
  isActive
  lastName
  avatar {
    url
    __typename
  }
  __typename
}

fragment PermissionGroupDetailsFragment on Group {
  ...PermissionGroupFragment
  permissions {
    ...PermissionFragment
    __typename
  }
  users {
    ...StaffMemberFragment
    __typename
  }
  __typename
}

query PermissionGroupDetails($id: ID!) {
  permissionGroup(id: $id) {
    ...PermissionGroupDetailsFragment
    __typename
  }
}

```
Variables:
```
{
  "id": "R3JvdXA6MQ=="
}
```
Get response:
```
{
  "errors": [
    {
      "message": "'account.add_address' is not a valid PermissionEnum",
      "locations": [
        {
          "line": 34,
          "column": 3
        }
      ],
      "path": [
        "permissionGroup",
        "permissions"
      ],
      "extensions": {
        "exception": {
          "code": "ValueError",
          "stacktrace": [
            "ValueError: 'account.add_address' is not a valid PermissionEnum",
            "",
            "During handling of the above exception, another exception occurred:",
            "Traceback (most recent call last):",
            "  File \"/usr/local/lib/python3.8/site-packages/promise/promise.py\", line 489, in _resolve_from_executor",
            "    executor(resolve, reject)",
            "  File \"/usr/local/lib/python3.8/site-packages/promise/promise.py\", line 756, in executor",
            "    return resolve(f(*args, **kwargs))",
            "  File \"/usr/local/lib/python3.8/site-packages/graphql/execution/middleware.py\", line 75, in make_it_promise",
            "    return next(*args, **kwargs)",
            "  File \"/app/saleor/graphql/account/types.py\", line 474, in resolve_permissions",
            "    return format_permissions_for_display(permissions)",
            "  File \"/app/saleor/graphql/utils.py\", line 175, in format_permissions_for_display",
            "    PermissionDisplay(code=PermissionEnum.get(codename), name=permission.name)",
            "  File \"/usr/local/lib/python3.8/site-packages/graphene/types/enum.py\", line 38, in get",
            "    return cls._meta.enum(value)",
            "  File \"/usr/local/lib/python3.8/enum.py\", line 304, in __call__",
            "    return cls.__new__(cls, value)",
            "  File \"/usr/local/lib/python3.8/enum.py\", line 595, in __new__",
            "    raise exc",
            "  File \"/usr/local/lib/python3.8/enum.py\", line 579, in __new__",
            "    result = cls._missing_(value)",
            "  File \"/usr/local/lib/python3.8/enum.py\", line 608, in _missing_",
            "    raise ValueError(\"%r is not a valid %s\" % (value, cls.__name__))",
            "ValueError: 'account.add_address' is not a valid PermissionEnum"
          ]
        }
      }
    }
  ],
  "data": {
    "permissionGroup": {
      "id": "R3JvdXA6MQ==",
      "name": "Full Access",
      "users": [
        {
          "id": "VXNlcjoyMQ==",
          "firstName": "",
          "lastName": "",
          "__typename": "User",
          "email": "admin@example.com",
          "isActive": true,
          "avatar": {
            "url": "http://localhost:8000/media/user-avatars/avatar8.png",
            "__typename": "Image"
          }
        }
      ],
      "__typename": "Group",
      "permissions": null
    }
  }
}
```


Discussion:

Resolving patch:
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.py
--- a/saleor/core/utils/random_data.py
+++ b/saleor/core/utils/random_data.py
@@ -29,6 +29,7 @@
     CheckoutPermissions,
     GiftcardPermissions,
     OrderPermissions,
+    get_permissions,
 )
 from ...core.utils import build_absolute_uri
 from ...core.weight import zero_weight
@@ -569,7 +570,7 @@ def create_permission_groups():
     super_users = User.objects.filter(is_superuser=True)
     if not super_users:
         super_users = create_staff_users(1, True)
-    group = create_group("Full Access", Permission.objects.all(), super_users)
+    group = create_group("Full Access", get_permissions(), super_users)
     yield f"Group: {group}"
 
     staff_users = create_staff_users()


Test patch: