From 231497d16b6a88d5e40e9a9cb1b802a3623cb97e Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 25 Feb 2019 16:18:50 +0100 Subject: [PATCH] Overwrite admin templates (4) --- static/admin/css/changelists.css | 27 +++++++ templates/admin/change_list.html | 89 ++++++++++++++++++++++++ templates/admin/change_list_results.html | 39 +++++++++++ 3 files changed, 155 insertions(+) create mode 100644 static/admin/css/changelists.css create mode 100644 templates/admin/change_list.html create mode 100644 templates/admin/change_list_results.html diff --git a/static/admin/css/changelists.css b/static/admin/css/changelists.css new file mode 100644 index 00000000..056e806c --- /dev/null +++ b/static/admin/css/changelists.css @@ -0,0 +1,27 @@ +/* Keep hidden fields hidden, can be removed with Bootstrap 4 */ +.hiddenfields { + display: none; +} + +/* Checkbox column should be small */ +#result_list .action-checkbox-column, +#result_list .action-checkbox { + width: 40px; + text-align: center; +} + +/* For sortable columns */ +.sortable .text { + float: left; +} + +.sortoptions { + float: right; + font-size: 12px; + position: relative; + top: 2px; +} + +.sortoptions .sortpriority { + display: none; +} diff --git a/templates/admin/change_list.html b/templates/admin/change_list.html new file mode 100644 index 00000000..4bd1ab50 --- /dev/null +++ b/templates/admin/change_list.html @@ -0,0 +1,89 @@ +{# Please keep this template in sync with django/contrib/admin one #} +{% extends "admin/base_site.html" %} +{% load i18n admin_urls static admin_list %} + +{% block extrastyle %} + {{ block.super }} + + {% if cl.formset %} + + {% endif %} + {% if cl.formset or action_form %} + + {% endif %} + {{ media.css }} + {% if not actions_on_top and not actions_on_bottom %} + + {% endif %} +{% endblock %} + +{% block extrahead %} +{{ block.super }} +{{ media.js }} +{% endblock %} + +{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-list{% endblock %} + +{% if not is_popup %} +{% block breadcrumbs %} + +{% endblock %} +{% endif %} + +{% block coltype %}flex{% endblock %} + +{% block content %} +
+ {% block object-tools %} + + {% endblock %} + {% if cl.formset.errors %} +
+ {% if cl.formset.total_error_count == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %} + {{ cl.formset.non_form_errors }} +
+ {% endif %} +
+ {% block search %}{% search_form cl %}{% endblock %} + {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %} + + {% block filters %} + {% if cl.has_filters %} +
+

{% trans 'Filter' %}

+ {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %} +
+ {% endif %} + {% endblock %} + +
{% csrf_token %} + {% if cl.formset %} +
{{ cl.formset.management_form }}
+ {% endif %} + + {% block result_list %} + {% result_list cl %} + {% if action_form and cl.show_admin_actions %}{% admin_actions %}{% endif %} + {% endblock %} + {% block pagination %}{% pagination cl %}{% endblock %} +
+
+
+{% endblock %} diff --git a/templates/admin/change_list_results.html b/templates/admin/change_list_results.html new file mode 100644 index 00000000..4ac2883c --- /dev/null +++ b/templates/admin/change_list_results.html @@ -0,0 +1,39 @@ +{# Please keep this template in sync with django/contrib/admin one #} +{% load i18n static %} +{% if result_hidden_fields %} +
{# DIV for HTML validation #} +{% for item in result_hidden_fields %}{{ item }}{% endfor %} +
+{% endif %} +{% if results %} +
+ + + +{% for header in result_headers %} +{% endfor %} + + + +{% for result in results %} +{% if result.form.non_field_errors %} + +{% endif %} +{% for item in result %}{{ item }}{% endfor %} +{% endfor %} + +
+ {% if header.sortable %} + {% if header.sort_priority > 0 %} +
+ + {% if num_sorted_fields > 1 %}{{ header.sort_priority }}{% endif %} + +
+ {% endif %} + {% endif %} +
{% if header.sortable %}{{ header.text|capfirst }}{% else %}{{ header.text|capfirst }}{% endif %}
+
+
{{ result.form.non_field_errors }}
+
+{% endif %}