Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As an editor fixing mistakes, it would be useful to be able to temporarily unpublish a document rather than deleting it #1702

Merged
merged 4 commits into from
Jan 30, 2024

Conversation

Sandravaphilips
Copy link
Collaborator

@longhotsummer
Copy link
Contributor

This is a good start.

Most (all, I think) of our Listing views and our Detail views extend base classes within peachjam.views.generic_views. You should be able to add filter(published=True) there, rather than in every other type of view.

Check BaseDocumentDetailView.get_object and DocumentListView.get_base_queryset.

For DocumentListView, I think it's safer to add the filter in get_base_queryset (rather than changing queryset) because that method tries .queryset and .model.objects.

peachjam/admin.py Outdated Show resolved Hide resolved
@Sandravaphilips
Copy link
Collaborator Author

@longhotsummer thanks for the feedback.
However, not all ListViews extend the base class, so I retained the ones that don't.
For the DetailView, I stuck with raising a 404 error in the DetailViewResolver instead. Implementing it in BaseDetailView raises a cannot find matching query error even when I say to raise the 404 error if the object is empty.

@@ -14,7 +14,9 @@ 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")[:30]
context["recent_judgments"] = Judgment.objects.exclude(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we need to do the same in all the HomePageView classes -- also search for recent_* and ensure those are corrected (mostly in homepage views I think).

Copy link
Contributor

@longhotsummer longhotsummer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, much cleaner.

Just the homepage views, pls.

@longhotsummer
Copy link
Contributor

Please also update peachjam_search.documents.SearchableDocument.should_index_object to skip unpublished documents.

I don't yet have a good recommendation for removing an unpublished doc from search, but we can leave that for now.

@Sandravaphilips Sandravaphilips merged commit 1f00bf2 into main Jan 30, 2024
9 checks passed
@Sandravaphilips Sandravaphilips deleted the sandrava-1688 branch January 30, 2024 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants