mirror of https://gitlab.crans.org/bde/nk20
Update permissions to see buses
This commit is contained in:
parent
12ebf9d12a
commit
7c6bab88f4
|
@ -1743,7 +1743,7 @@
|
||||||
"wei",
|
"wei",
|
||||||
"bus"
|
"bus"
|
||||||
],
|
],
|
||||||
"query": "[\"AND\", {\"wei\": [\"club\"]}, [\"OR\", [\"NOT\", [\"membership\", \"registration\", \"first_year\"]], {\"wei__date_end__lte\": [\"today\"]}]]",
|
"query": "[\"AND\", {\"wei\": [\"club\"]}, [\"OR\", [\"NOT\", [\"membership\", \"weimembership\", \"registration\", \"first_year\"]], {\"wei__date_end__lte\": [\"today\"]}]]",
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"mask": 1,
|
"mask": 1,
|
||||||
"field": "",
|
"field": "",
|
||||||
|
@ -1759,7 +1759,7 @@
|
||||||
"wei",
|
"wei",
|
||||||
"busteam"
|
"busteam"
|
||||||
],
|
],
|
||||||
"query": "[\"AND\", {\"bus__wei\": [\"club\"]}, [\"OR\", [\"NOT\", [\"membership\", \"registration\", \"first_year\"]], {\"bus__wei__date_end__lte\": [\"today\"]}]]",
|
"query": "[\"AND\", {\"bus__wei\": [\"club\"]}, [\"OR\", [\"NOT\", [\"membership\", \"weimembership\", \"registration\", \"first_year\"]], {\"bus__wei__date_end__lte\": [\"today\"]}]]",
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"mask": 1,
|
"mask": 1,
|
||||||
"field": "",
|
"field": "",
|
||||||
|
|
|
@ -238,6 +238,9 @@ class Permission(models.Model):
|
||||||
field = Permission.compute_param(value[i], **kwargs)
|
field = Permission.compute_param(value[i], **kwargs)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if not hasattr(field, value[i][0]):
|
||||||
|
return False
|
||||||
|
|
||||||
field = getattr(field, value[i][0])
|
field = getattr(field, value[i][0])
|
||||||
params = []
|
params = []
|
||||||
call_kwargs = {}
|
call_kwargs = {}
|
||||||
|
@ -251,6 +254,9 @@ class Permission(models.Model):
|
||||||
params.append(param)
|
params.append(param)
|
||||||
field = field(*params, **call_kwargs)
|
field = field(*params, **call_kwargs)
|
||||||
else:
|
else:
|
||||||
|
if not hasattr(field, value[i]):
|
||||||
|
return False
|
||||||
|
|
||||||
field = getattr(field, value[i])
|
field = getattr(field, value[i])
|
||||||
return field
|
return field
|
||||||
|
|
||||||
|
@ -275,7 +281,7 @@ class Permission(models.Model):
|
||||||
elif query[0] == 'NOT':
|
elif query[0] == 'NOT':
|
||||||
return ~Permission._about(query[1], **kwargs)
|
return ~Permission._about(query[1], **kwargs)
|
||||||
else:
|
else:
|
||||||
return Q(pk=F("pk"))
|
return Q(pk=F("pk")) if Permission.compute_param(query, **kwargs) else ~Q(pk=F("pk"))
|
||||||
elif isinstance(query, dict):
|
elif isinstance(query, dict):
|
||||||
q_kwargs = {}
|
q_kwargs = {}
|
||||||
for key in query:
|
for key in query:
|
||||||
|
|
|
@ -76,7 +76,7 @@ class PermissionQueryTestCase(TestCase):
|
||||||
model = perm.model.model_class()
|
model = perm.model.model_class()
|
||||||
model.objects.filter(query).all()
|
model.objects.filter(query).all()
|
||||||
# print("Good query for permission", perm)
|
# print("Good query for permission", perm)
|
||||||
except (FieldError, AttributeError, ValueError):
|
except (FieldError, AttributeError, ValueError, TypeError):
|
||||||
print("Query error for permission", perm)
|
print("Query error for permission", perm)
|
||||||
print("Query:", perm.query)
|
print("Query:", perm.query)
|
||||||
if instanced.query:
|
if instanced.query:
|
||||||
|
|
Loading…
Reference in New Issue