Skip to content

Commit

Permalink
Merge pull request #474 from commonknowledge/download-expired-members…
Browse files Browse the repository at this point in the history
…-in-batches

Download expired members in batches
  • Loading branch information
Moggach authored Jul 17, 2024
2 parents f53be55 + dad8b2c commit 64aafb7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"mathfilters",
"djmoney",
"anymail",
'wagtail_rangefilter',
'rangefilter',
"rest_framework",
"groundwork.core",
"groundwork.geo",
Expand Down
8 changes: 7 additions & 1 deletion app/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from app.models.stripe import LBCCustomer, LBCProduct, LBCSubscription, ShippingZone
from app.models.wagtail import MembershipPlanPage, MembershipPlanPrice, ReadingOption
from app.utils import ensure_list
from wagtail_rangefilter.filters import DateTimeRangeFilter


@hooks.register("insert_global_admin_css")
Expand Down Expand Up @@ -117,6 +118,7 @@ class CustomerAdmin(ModelAdmin):
exclude_from_explorer = (
False # or True to exclude pages of this type from Wagtail's explorer view
)

list_display = (
"recipient_name",
"primary_product_name",
Expand Down Expand Up @@ -145,6 +147,11 @@ class CustomerAdmin(ModelAdmin):
)
export_filename = "lbc_members"

def get_list_filter(self, request):
if request.GET.get('status') == 'expired':
return (("ended_at", DateTimeRangeFilter),)
return ()

def get_queryset(self, request):
qs = super().get_queryset(request)
return (
Expand All @@ -155,7 +162,6 @@ def get_queryset(self, request):
.select_related("plan__product", "customer__subscriber")
)


# Now you just need to register your customised ModelAdmin class with Wagtail
modeladmin_register(CustomerAdmin)

Expand Down
35 changes: 33 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ orjson = "^3.9.2"
slippers = "^0.6.2"
django-vite = { git = "https://github.com/Niicck/django-vite", rev = "fix-isDynamicEntry" }
whitenoise = { extras = ["brotli"], version = "*" }
wagtail-rangefilter = "^0.2.1"

[tool.poetry.dev-dependencies]
bandit = "^1.7.0"
Expand Down

0 comments on commit 64aafb7

Please sign in to comment.