diefenbach / django-permissions

BSD 3-Clause "New" or "Revised" License
13 stars 12 forks source link

Other fix needed in caching of roles #1

Open gtoffoli opened 9 years ago

gtoffoli commented 9 years ago

In version 1.1, module utils.py, function get_roles, I had to change the construction of the queries, in order to make get_roles itself and has_permission work. Here is my code:

groups_ids = [g.id for g in groups]
groups_ids_str = ", ".join([str(id) for id in groups_ids]) # to be used for caching ?
if groups_ids:
    query = Q(user_id=user.id) | Q(group_id__in=groups_ids)
    prrs = PrincipalRoleRelation.objects.filter(
        query, content_id=None
    ).values("role_id")

(around line 217; made similar change around line 231; I imagine that the variable groups_ids_str should be used for caching, but don't know how.)

It seems that the current version, in Github, needs the same fix. By, Giovanni