mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-12-22 23:42:25 +00:00
Update permissions to see buses
This commit is contained in:
parent
12ebf9d12a
commit
7c6bab88f4
@ -1743,7 +1743,7 @@
|
||||
"wei",
|
||||
"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",
|
||||
"mask": 1,
|
||||
"field": "",
|
||||
@ -1759,7 +1759,7 @@
|
||||
"wei",
|
||||
"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",
|
||||
"mask": 1,
|
||||
"field": "",
|
||||
|
@ -238,6 +238,9 @@ class Permission(models.Model):
|
||||
field = Permission.compute_param(value[i], **kwargs)
|
||||
continue
|
||||
|
||||
if not hasattr(field, value[i][0]):
|
||||
return False
|
||||
|
||||
field = getattr(field, value[i][0])
|
||||
params = []
|
||||
call_kwargs = {}
|
||||
@ -251,6 +254,9 @@ class Permission(models.Model):
|
||||
params.append(param)
|
||||
field = field(*params, **call_kwargs)
|
||||
else:
|
||||
if not hasattr(field, value[i]):
|
||||
return False
|
||||
|
||||
field = getattr(field, value[i])
|
||||
return field
|
||||
|
||||
@ -275,7 +281,7 @@ class Permission(models.Model):
|
||||
elif query[0] == 'NOT':
|
||||
return ~Permission._about(query[1], **kwargs)
|
||||
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):
|
||||
q_kwargs = {}
|
||||
for key in query:
|
||||
|
@ -76,7 +76,7 @@ class PermissionQueryTestCase(TestCase):
|
||||
model = perm.model.model_class()
|
||||
model.objects.filter(query).all()
|
||||
# print("Good query for permission", perm)
|
||||
except (FieldError, AttributeError, ValueError):
|
||||
except (FieldError, AttributeError, ValueError, TypeError):
|
||||
print("Query error for permission", perm)
|
||||
print("Query:", perm.query)
|
||||
if instanced.query:
|
||||
|
Loading…
Reference in New Issue
Block a user