Cleanup submit row for articles
This commit is contained in:
parent
60d17f800c
commit
aa61d02eca
2 changed files with 28 additions and 5 deletions
|
@ -142,6 +142,27 @@ class ArticleAdmin(admin.ModelAdmin):
|
|||
return redirect(".")
|
||||
return super().response_change(request, obj)
|
||||
|
||||
def change_view(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
object_id: int,
|
||||
form_url: str = "",
|
||||
extra_context: dict | None = None,
|
||||
) -> HttpResponse:
|
||||
extra_context = extra_context or {}
|
||||
extra_context["show_save_and_add_another"] = False
|
||||
return super().change_view(request, object_id, form_url, extra_context)
|
||||
|
||||
def add_view(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
form_url: str = "",
|
||||
extra_context: dict | None = None,
|
||||
) -> HttpResponse:
|
||||
extra_context = extra_context or {}
|
||||
extra_context["show_save_and_add_another"] = False
|
||||
return super().add_view(request, form_url, extra_context)
|
||||
|
||||
def read_time(self, instance: Article) -> str:
|
||||
return f"{instance.get_read_time()} min"
|
||||
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
{% load static %}
|
||||
{% block submit-row %}
|
||||
{{ block.super }}
|
||||
<p class="deletelink-box">
|
||||
{% if original.status != original.PUBLISHED %}
|
||||
<input type="submit" value="Save and publish" name="_publish">
|
||||
{% elif original.status != original.DRAFT %}
|
||||
<input type="submit" value="Save and unpublish" name="_unpublish">
|
||||
{% endif %}
|
||||
</p>
|
||||
<input type="submit" value="Save and view" name="_preview">
|
||||
{% if original %}
|
||||
<input type="submit" value="Live preview" id="_live_preview">
|
||||
|
|
Reference in a new issue