diff --git a/peachjam/admin.py b/peachjam/admin.py index cd41d818c..95f68fef6 100644 --- a/peachjam/admin.py +++ b/peachjam/admin.py @@ -179,6 +179,9 @@ class PeachJamSettingsAdmin(admin.ModelAdmin): "document_jurisdictions", ) + def has_add_permission(self, request): + return False + def changelist_view(self, request, extra_context=None): # redirect to edit the singleton return redirect("admin:peachjam_peachjamsettings_change", pj_settings().pk) @@ -844,7 +847,9 @@ def fixup(item): @admin.register(CoreDocument) class CoreDocumentAdmin(DocumentAdmin): - pass + def has_add_permission(self, request): + # this is prevented because there is no view that handles a CoreDocument + return False @admin.register(GenericDocument) diff --git a/peachjam/views/documents.py b/peachjam/views/documents.py index 4c85bfaff..343c179de 100644 --- a/peachjam/views/documents.py +++ b/peachjam/views/documents.py @@ -64,6 +64,10 @@ def dispatch(self, request, *args, **kwargs): return view.dispatch(request, *args, **kwargs) + raise Exception( + f"The document type {obj.doc_type} does not have a view registered." + ) + @method_decorator(add_slash_to_frbr_uri(), name="setup") class DocumentSourceView(DetailView):