kopia lustrzana https://github.com/wagtail/wagtail
Use grid and simplify the template for documents edit view
rodzic
08fd30cb65
commit
f99a66a709
|
@ -1,46 +1,33 @@
|
||||||
{% extends "wagtailadmin/generic/edit.html" %}
|
{% extends "wagtailadmin/generic/edit.html" %}
|
||||||
{% load i18n wagtailadmin_tags %}
|
{% load i18n wagtailadmin_tags %}
|
||||||
|
|
||||||
{% block main_content %}
|
{% block fields %}
|
||||||
<div class="row row-flush">
|
<div class="w-grid w-grid-cols-1 sm:w-grid-cols-6 w-gap-8">
|
||||||
|
<div class="sm:w-col-span-5">
|
||||||
<div class="col10">
|
<input type="hidden" value="{{ next }}" name="next">
|
||||||
<form action="{% url 'wagtaildocs:edit' document.id %}" method="POST" enctype="multipart/form-data" novalidate>
|
{% for field in form %}
|
||||||
{% csrf_token %}
|
{% if field.name == 'file' %}
|
||||||
<input type="hidden" value="{{ next }}" name="next">
|
{% include "wagtaildocs/documents/_file_field.html" %}
|
||||||
<ul class="fields">
|
{% elif field.is_hidden %}
|
||||||
{% for field in form %}
|
{{ field }}
|
||||||
{% if field.name == 'file' %}
|
{% else %}
|
||||||
<li>{% include "wagtaildocs/documents/_file_field.html" %}</li>
|
{% formattedfield field %}
|
||||||
{% elif field.is_hidden %}
|
|
||||||
{{ field }}
|
|
||||||
{% else %}
|
|
||||||
<li>{% formattedfield field %}</li>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
<li>
|
|
||||||
<input type="submit" value="{% trans 'Save' %}" class="button" />
|
|
||||||
{% if can_delete %}
|
|
||||||
<a href="{{ delete_url }}{% if next %}?next={{ next|urlencode }}{% endif %}" class="button no">{% trans "Delete document" %}</a>
|
|
||||||
{% endif %}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div class="col2">
|
|
||||||
<dl>
|
|
||||||
{% if document.file %}
|
|
||||||
<dt>{% trans "Filesize" %}</dt>
|
|
||||||
<dd>{% if filesize %}{{ filesize|filesizeformat }}{% else %}{% trans "File not found" %}{% endif %}</dd>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
<dt>{% trans "Usage" %}</dt>
|
|
||||||
<dd>
|
|
||||||
{% with usage_count_val=document.get_usage.count %}
|
|
||||||
<a href="{{ document.usage_url }}">{% blocktrans trimmed with usage_count=usage_count_val|intcomma count usage_count_val=usage_count_val %}Used {{ usage_count }} time{% plural %}Used {{ usage_count }} times{% endblocktrans %}</a>
|
|
||||||
{% endwith %}
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
{% if document.file %}
|
||||||
|
<dt>{% trans "Filesize" %}</dt>
|
||||||
|
<dd>{% if filesize %}{{ filesize|filesizeformat }}{% else %}{% trans "File not found" %}{% endif %}</dd>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<dt>{% trans "Usage" %}</dt>
|
||||||
|
<dd>
|
||||||
|
{% with usage_count_val=document.get_usage.count %}
|
||||||
|
<a href="{{ document.usage_url }}">{% blocktrans trimmed with usage_count=usage_count_val|intcomma count usage_count_val=usage_count_val %}Used {{ usage_count }} time{% plural %}Used {{ usage_count }} times{% endblocktrans %}</a>
|
||||||
|
{% endwith %}
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -4,6 +4,7 @@ from django.contrib.admin.utils import quote
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.http.response import HttpResponse as HttpResponse
|
from django.http.response import HttpResponse as HttpResponse
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
from django.utils.http import urlencode
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django.utils.translation import gettext_lazy, ngettext
|
from django.utils.translation import gettext_lazy, ngettext
|
||||||
|
|
||||||
|
@ -196,6 +197,7 @@ class EditView(generic.EditView):
|
||||||
delete_url_name = "wagtaildocs:delete"
|
delete_url_name = "wagtaildocs:delete"
|
||||||
header_icon = "doc-full-inverse"
|
header_icon = "doc-full-inverse"
|
||||||
context_object_name = "document"
|
context_object_name = "document"
|
||||||
|
delete_item_label = gettext_lazy("Delete document")
|
||||||
_show_breadcrumbs = True
|
_show_breadcrumbs = True
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
|
@ -230,6 +232,12 @@ class EditView(generic.EditView):
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return self.next_url or super().get_success_url()
|
return self.next_url or super().get_success_url()
|
||||||
|
|
||||||
|
def get_delete_url(self):
|
||||||
|
delete_url = super().get_delete_url()
|
||||||
|
if self.next_url:
|
||||||
|
delete_url += "?" + urlencode({"next": self.next_url})
|
||||||
|
return delete_url
|
||||||
|
|
||||||
def render_to_response(self, context, **response_kwargs):
|
def render_to_response(self, context, **response_kwargs):
|
||||||
if self.object.is_stored_locally():
|
if self.object.is_stored_locally():
|
||||||
# Give error if document file doesn't exist
|
# Give error if document file doesn't exist
|
||||||
|
|
Ładowanie…
Reference in New Issue