diff --git a/africanlii/views/home.py b/africanlii/views/home.py index 225a4a2ea..c221352d0 100644 --- a/africanlii/views/home.py +++ b/africanlii/views/home.py @@ -22,15 +22,21 @@ def get_context_data(self, **kwargs): ) context["recent_articles"] = recent_articles - context["recent_soft_law"] = GenericDocument.objects.exclude( - frbr_uri_doctype="doc" - ).order_by("-date")[:5] - context["recent_reports_guides"] = GenericDocument.objects.filter( - frbr_uri_doctype="doc" - ).order_by("-date")[:5] - context["recent_legal_instruments"] = CoreDocument.objects.filter( - frbr_uri_doctype="act" - ).order_by("-date")[:5] + context["recent_soft_law"] = ( + GenericDocument.objects.exclude(published=False) + .exclude(frbr_uri_doctype="doc") + .order_by("-date")[:5] + ) + context["recent_reports_guides"] = ( + GenericDocument.objects.exclude(published=False) + .filter(frbr_uri_doctype="doc") + .order_by("-date")[:5] + ) + context["recent_legal_instruments"] = ( + CoreDocument.objects.exclude(published=False) + .filter(frbr_uri_doctype="act") + .order_by("-date")[:5] + ) context["au_organs"] = AfricanUnionOrgan.objects.prefetch_related("author") context["au_institutions"] = AfricanUnionInstitution.objects.prefetch_related( "author" diff --git a/liiweb/views/general.py b/liiweb/views/general.py index 3120211be..eaaf89e1a 100644 --- a/liiweb/views/general.py +++ b/liiweb/views/general.py @@ -10,8 +10,12 @@ def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["court_classes"] = CourtClass.objects.prefetch_related("courts") - context["recent_judgments"] = Judgment.objects.order_by("-date")[:5] - context["recent_legislation"] = Legislation.objects.order_by("-date")[:10] + context["recent_judgments"] = Judgment.objects.exclude( + published=False + ).order_by("-date")[:5] + context["recent_legislation"] = Legislation.objects.exclude( + published=False + ).order_by("-date")[:10] context["taxonomies"] = Taxonomy.dump_bulk() context["taxonomy_url"] = "taxonomy_detail" context["recent_articles"] = ( diff --git a/peachjam/views/home.py b/peachjam/views/home.py index 004a161b3..cfe3b27ed 100644 --- a/peachjam/views/home.py +++ b/peachjam/views/home.py @@ -16,11 +16,19 @@ class HomePageView(TemplateView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - recent_judgments = Judgment.objects.order_by("-date")[:5] - recent_documents = GenericDocument.objects.order_by("-date")[:5] - recent_instruments = LegalInstrument.objects.order_by("-date")[:5] - recent_legislation = Legislation.objects.order_by("-date")[:5] - documents_count = CoreDocument.objects.count() + recent_judgments = Judgment.objects.exclude(published=False).order_by("-date")[ + :5 + ] + recent_documents = GenericDocument.objects.exclude(published=False).order_by( + "-date" + )[:5] + recent_instruments = LegalInstrument.objects.exclude(published=False).order_by( + "-date" + )[:5] + recent_legislation = Legislation.objects.exclude(published=False).order_by( + "-date" + )[:5] + documents_count = CoreDocument.objects.exclude(published=False).count() authors = Author.objects.exclude( Q(genericdocument__isnull=True), diff --git a/peachjam_search/documents.py b/peachjam_search/documents.py index ae4013854..ec349d885 100644 --- a/peachjam_search/documents.py +++ b/peachjam_search/documents.py @@ -116,7 +116,7 @@ class SearchableDocument(Document): ] def should_index_object(self, obj): - if isinstance(obj, ExternalDocument): + if isinstance(obj, ExternalDocument) or not obj.published: return False return True