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 redirect(".")
|
||||||
return super().response_change(request, obj)
|
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:
|
def read_time(self, instance: Article) -> str:
|
||||||
return f"{instance.get_read_time()} min"
|
return f"{instance.get_read_time()} min"
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% block submit-row %}
|
{% block submit-row %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
{% if original.status != original.PUBLISHED %}
|
<p class="deletelink-box">
|
||||||
<input type="submit" value="Save and publish" name="_publish">
|
{% if original.status != original.PUBLISHED %}
|
||||||
{% elif original.status != original.DRAFT %}
|
<input type="submit" value="Save and publish" name="_publish">
|
||||||
<input type="submit" value="Save and unpublish" name="_unpublish">
|
{% elif original.status != original.DRAFT %}
|
||||||
{% endif %}
|
<input type="submit" value="Save and unpublish" name="_unpublish">
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
<input type="submit" value="Save and view" name="_preview">
|
<input type="submit" value="Save and view" name="_preview">
|
||||||
{% if original %}
|
{% if original %}
|
||||||
<input type="submit" value="Live preview" id="_live_preview">
|
<input type="submit" value="Live preview" id="_live_preview">
|
||||||
|
|
Reference in a new issue