Merge branch 'tirage-au-sort' into 'beta'

Boutons

See merge request bde/nk20!189
This commit is contained in:
ynerant 2021-12-13 17:37:13 +01:00
commit 41289857b2
3 changed files with 8 additions and 4 deletions

View File

@ -256,7 +256,8 @@ class ProfileAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
note = context['object'].note note = context['object'].note
context["aliases"] = AliasTable( context["aliases"] = AliasTable(
note.alias.filter(PermissionBackend.filter_queryset(self.request, Alias, "view")).distinct().all()) note.alias.filter(PermissionBackend.filter_queryset(self.request, Alias, "view")).distinct()
.order_by('normalized_name').all())
context["can_create"] = PermissionBackend.check_perm(self.request, "note.add_alias", Alias( context["can_create"] = PermissionBackend.check_perm(self.request, "note.add_alias", Alias(
note=context["object"].note, note=context["object"].note,
name="", name="",

View File

@ -215,6 +215,9 @@ class ButtonTable(tables.Table):
def render_amount(self, value): def render_amount(self, value):
return pretty_money(value) return pretty_money(value)
def order_category(self, queryset, is_descending):
return queryset.order_by(f"{'-' if is_descending else ''}category__name"), True
def render_hideshow(self, record): def render_hideshow(self, record):
val = '<button id="' val = '<button id="'
val += str(record.pk) val += str(record.pk)

View File

@ -90,9 +90,9 @@ class TransactionTemplateListView(ProtectQuerysetMixin, LoginRequiredMixin, Sing
if "search" in self.request.GET: if "search" in self.request.GET:
pattern = self.request.GET["search"] pattern = self.request.GET["search"]
qs = qs.filter( qs = qs.filter(
Q(name__iregex="^" + pattern) Q(name__iregex=pattern)
| Q(destination__club__name__iregex="^" + pattern) | Q(destination__club__name__iregex=pattern)
| Q(category__name__iregex="^" + pattern) | Q(category__name__iregex=pattern)
| Q(description__iregex=pattern) | Q(description__iregex=pattern)
) )