@@ -67,7 +67,14 @@ class OrganisationList(ListView): # type: ignore[type-arg]
6767 template_name = "sales_dashboard/home.html"
6868
6969 def get_queryset (self ): # type: ignore[no-untyped-def]
70- queryset = Organisation .objects .annotate (
70+ if self .request .GET .get ("include_deleted" ) == "on" or self .request .GET .get (
71+ "search"
72+ ):
73+ queryset = Organisation .objects .all_with_deleted ()
74+ else :
75+ queryset = Organisation .objects .all ()
76+
77+ queryset = queryset .annotate (
7178 num_projects = Count ("projects" , distinct = True ),
7279 num_users = Count ("users" , distinct = True ),
7380 num_features = Count ("projects__features" , distinct = True ),
@@ -105,6 +112,7 @@ def get_context_data(self, **kwargs): # type: ignore[no-untyped-def]
105112 data ["filter_plan" ] = self .request .GET .get ("filter_plan" )
106113 data ["sort_field" ] = self .request .GET .get ("sort_field" )
107114 data ["sort_direction" ] = self .request .GET .get ("sort_direction" )
115+ data ["include_deleted" ] = self .request .GET .get ("include_deleted" , "off" ) == "on"
108116
109117 # Use the most recent "influx_updated_at" in
110118 # OrganisationSubscriptionInformationCache object to determine
@@ -155,7 +163,8 @@ def _build_search_query(self, search_term: str) -> Q:
155163@staff_member_required
156164def organisation_info (request : HttpRequest , organisation_id : int ) -> HttpResponse :
157165 organisation = get_object_or_404 (
158- Organisation .objects .select_related ("subscription" ), pk = organisation_id
166+ Organisation .objects .all_with_deleted ().select_related ("subscription" ),
167+ pk = organisation_id ,
159168 )
160169 template = loader .get_template ("sales_dashboard/organisation.html" )
161170 subscription_metadata = organisation .subscription .get_subscription_metadata ()
0 commit comments