1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 01:48:21 +02:00
This commit is contained in:
Yohann D'ANELLO
2020-05-29 21:43:24 +02:00
parent f567b1a343
commit a9ccf46010
3 changed files with 7 additions and 6 deletions

View File

@ -3,6 +3,7 @@
import datetime
from django.conf import settings
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.models import User, AnonymousUser
from django.contrib.contenttypes.models import ContentType
@ -52,9 +53,9 @@ class PermissionBackend(ModelBackend):
& Q(mask__rank__lte=get_current_session().get("permission_mask", 0))
)
try:
if settings.DATABASES[qs.db]["ENGINE"] == 'django.db.backends.postgresql_psycopg2':
qs = qs.distinct('pk', 'club')
except: # SQLite doesn't support distinct fields.
else: # SQLite doesn't support distinct fields.
qs = qs.distinct()
return qs