Commit fc90b421 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

DeletableAdhesionFilter

parent a34cd3e7
from django.contrib import admin
from django.contrib.auth.models import User as AuthUser
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin
from django.db.models import Q
from django.utils.html import format_html
from django.utils import timezone
from django.conf.urls import url
......@@ -115,7 +114,7 @@ class AdhesionImportedFilter(admin.SimpleListFilter):
return queryset.filter(notes="")
class AdhesionDeletableFilter(admin.SimpleListFilter):
class DeletableAdhesionFilter(admin.SimpleListFilter):
title = "supprimable"
parameter_name = "deletable"
......@@ -126,16 +125,10 @@ class AdhesionDeletableFilter(admin.SimpleListFilter):
)
def queryset(self, request, queryset):
one_year_ago = timezone.now() - timedelta(days=366)
q = Q(
active=False,
payment_method=PaymentUpdate.STOP,
last_echeance__lte=one_year_ago,
)
if self.value() == "0":
return queryset.exclude(q)
return queryset.filter(long_stopped=False)
if self.value() == "1":
return queryset.filter(q)
return queryset.filter(qlong_stopped=True)
# ## Mixins
......@@ -337,7 +330,7 @@ class AdhesionAdmin(AdtSearchMixin, admin.ModelAdmin):
AdherentTypeFilter,
ActiveFilter,
AdhesionImportedFilter,
AdhesionDeletableFilter,
DeletableAdhesionFilter,
)
list_select_related = (
"user",
......
......@@ -92,7 +92,7 @@ class DeletableServiceFilter(admin.SimpleListFilter):
def queryset(self, request, queryset):
if self.value() == "0":
return queryset.exclude(long_stopped=False)
return queryset.filter(long_stopped=False)
if self.value() == "1":
return queryset.filter(long_stopped=True)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment