1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-26 18:37:12 +00:00

Merge branch 'fix_distinct' into 'master'

distinct on field not supported by sqlite

See merge request bde/nk20!74
This commit is contained in:
Pierre-antoine Comby 2020-04-09 22:37:05 +02:00
commit 7d121da0a5
2 changed files with 2 additions and 3 deletions

View File

@ -139,8 +139,7 @@ class ActivityEntryView(LoginRequiredMixin, TemplateView):
| Q(name__regex=pattern) | Q(name__regex=pattern)
| Q(normalized_name__regex=Alias.normalize(pattern)))) \ | Q(normalized_name__regex=Alias.normalize(pattern)))) \
.filter(PermissionBackend.filter_queryset(self.request.user, Alias, "view"))\ .filter(PermissionBackend.filter_queryset(self.request.user, Alias, "view"))\
.filter(note__noteuser__user__profile__registration_valid=True)\ .distinct()[:20]
.distinct("username")[:20]
for note in note_qs: for note in note_qs:
note.type = "Adhérent" note.type = "Adhérent"
note.activity = activity note.activity = activity

View File

@ -43,7 +43,7 @@ class PermissionBackend(ModelBackend):
rolepermissions__role__membership__date_end__gte=datetime.date.today(), rolepermissions__role__membership__date_end__gte=datetime.date.today(),
type=t, type=t,
mask__rank__lte=get_current_session().get("permission_mask", 0), mask__rank__lte=get_current_session().get("permission_mask", 0),
).distinct('club', 'pk',) ).distinct()
@staticmethod @staticmethod
def permissions(user, model, type): def permissions(user, model, type):