mirror of
				https://gitlab.crans.org/bde/nk20
				synced 2025-10-31 15:50:03 +01:00 
			
		
		
		
	Fix JSON
This commit is contained in:
		| @@ -50,10 +50,7 @@ def save_object(sender, instance, **kwargs): | |||||||
|     in order to store each modification made |     in order to store each modification made | ||||||
|     """ |     """ | ||||||
|     # noinspection PyProtectedMember |     # noinspection PyProtectedMember | ||||||
|     if instance._meta.label_lower in EXCLUDED: |     if instance._meta.label_lower in EXCLUDED or hasattr(instance, "_no_log"): | ||||||
|         return |  | ||||||
|  |  | ||||||
|     if hasattr(instance, "_no_log"): |  | ||||||
|         return |         return | ||||||
|  |  | ||||||
|     # noinspection PyProtectedMember |     # noinspection PyProtectedMember | ||||||
|   | |||||||
| @@ -2607,7 +2607,7 @@ | |||||||
| 				"note", | 				"note", | ||||||
| 				"transaction" | 				"transaction" | ||||||
| 			], | 			], | ||||||
| 			"query": "[\"OR\", {\"source\": [\"club\", \"note\"]}, {\"destination\": [\"club\", \"note\"]}], [\"OR\", {\"source__balance__gte\": {\"F\": [\"SUB\", [\"MUL\", [\"F\", \"amount\"], [\"F\", \"quantity\"]], 5000]}, \"valid\": true}, {\"destination__balance__gte\": {\"F\": [\"SUB\", [\"MUL\", [\"F\", \"amount\"], [\"F\", \"quantity\"]], 5000]}, \"valid\": false}]", | 			"query": "[\"OR\", {\"source__balance__gte\": {\"F\": [\"SUB\", [\"MUL\", [\"F\", \"amount\"], [\"F\", \"quantity\"]], 5000]}, \"valid\": true}, {\"destination__balance__gte\": {\"F\": [\"SUB\", [\"MUL\", [\"F\", \"amount\"], [\"F\", \"quantity\"]], 5000]}, \"valid\": false}]", | ||||||
| 			"type": "change", | 			"type": "change", | ||||||
| 			"mask": 2, | 			"mask": 2, | ||||||
| 			"field": "valid", | 			"field": "valid", | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ | |||||||
| # SPDX-License-Identifier: GPL-3.0-or-later | # SPDX-License-Identifier: GPL-3.0-or-later | ||||||
|  |  | ||||||
| from datetime import date | from datetime import date | ||||||
|  | from json.decoder import JSONDecodeError | ||||||
|  |  | ||||||
| from django.contrib.auth.models import User | from django.contrib.auth.models import User | ||||||
| from django.core.exceptions import FieldError | from django.core.exceptions import FieldError | ||||||
| @@ -56,29 +57,29 @@ class PermissionQueryTestCase(TestCase): | |||||||
|         We use a random user with a random WEIClub (to use permissions for the WEI) in a random team in a random bus. |         We use a random user with a random WEIClub (to use permissions for the WEI) in a random team in a random bus. | ||||||
|         """ |         """ | ||||||
|         for perm in Permission.objects.all(): |         for perm in Permission.objects.all(): | ||||||
|             instanced = perm.about( |  | ||||||
|                 user=User.objects.get(), |  | ||||||
|                 club=WEIClub.objects.get(), |  | ||||||
|                 membership=Membership.objects.get(), |  | ||||||
|                 User=User, |  | ||||||
|                 Club=Club, |  | ||||||
|                 Membership=Membership, |  | ||||||
|                 Note=Note, |  | ||||||
|                 NoteUser=NoteUser, |  | ||||||
|                 NoteClub=NoteClub, |  | ||||||
|                 NoteSpecial=NoteSpecial, |  | ||||||
|                 F=F, |  | ||||||
|                 Q=Q, |  | ||||||
|                 now=timezone.now(), |  | ||||||
|                 today=date.today(), |  | ||||||
|             ) |  | ||||||
|             try: |             try: | ||||||
|  |                 instanced = perm.about( | ||||||
|  |                     user=User.objects.get(), | ||||||
|  |                     club=WEIClub.objects.get(), | ||||||
|  |                     membership=Membership.objects.get(), | ||||||
|  |                     User=User, | ||||||
|  |                     Club=Club, | ||||||
|  |                     Membership=Membership, | ||||||
|  |                     Note=Note, | ||||||
|  |                     NoteUser=NoteUser, | ||||||
|  |                     NoteClub=NoteClub, | ||||||
|  |                     NoteSpecial=NoteSpecial, | ||||||
|  |                     F=F, | ||||||
|  |                     Q=Q, | ||||||
|  |                     now=timezone.now(), | ||||||
|  |                     today=date.today(), | ||||||
|  |                 ) | ||||||
|                 instanced.update_query() |                 instanced.update_query() | ||||||
|                 query = instanced.query |                 query = instanced.query | ||||||
|                 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, TypeError): |             except (FieldError, AttributeError, ValueError, TypeError, JSONDecodeError): | ||||||
|                 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: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user