From f48d8c08658003518a46f07566bbadcca2d5a77b Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sat, 2 Mar 2019 10:01:35 +0100 Subject: [PATCH] Simplify deletion admin templates --- useradmin/admin.py | 2 - useradmin/static/useradmin/css/base.css | 49 +++++++++++++++ useradmin/templates/admin/base_site.html | 6 ++ .../templates/useradmin/change_form.html | 21 +++---- .../useradmin/delete_confirmation.html | 55 ----------------- .../delete_selected_confirmation.html | 59 ------------------- 6 files changed, 63 insertions(+), 129 deletions(-) create mode 100644 useradmin/static/useradmin/css/base.css delete mode 100644 useradmin/templates/useradmin/delete_confirmation.html delete mode 100644 useradmin/templates/useradmin/delete_selected_confirmation.html diff --git a/useradmin/admin.py b/useradmin/admin.py index 4b3def48..0728fe14 100644 --- a/useradmin/admin.py +++ b/useradmin/admin.py @@ -39,8 +39,6 @@ class ModelUserAdmin(admin.ModelAdmin): # Custom templates change_form_template = 'useradmin/change_form.html' - delete_confirmation_template = 'useradmin/delete_confirmation.html' - delete_selected_confirmation_template = 'useradmin/delete_selected_confirmation.html' # Defines new management site diff --git a/useradmin/static/useradmin/css/base.css b/useradmin/static/useradmin/css/base.css new file mode 100644 index 00000000..a044d22e --- /dev/null +++ b/useradmin/static/useradmin/css/base.css @@ -0,0 +1,49 @@ +/* Make admin buttons look like Bootstrap */ + +.button, input[type=submit] { + display: inline-block; + padding: 6px 12px; + margin-bottom: 0; + font-size: 14px; + font-weight: 400; + line-height: 1.42857143; + text-align: center; + white-space: nowrap; + vertical-align: middle; + -ms-touch-action: manipulation; + touch-action: manipulation; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + border: 1px solid #ccc; + border-radius: 4px; + color: #333; + background: #fff none; +} + +.button:hover, .button:active, .button:focus, +input[type=submit]:hover, input[type=submit]:active, input[type=submit]:focus { + text-decoration: none; + color: #333; + background-color: #e6e6e6; + border-color: #adadad; +} + +.button:focus, input[type=submit]:focus { + border-color: #8c8c8c; +} + +.button:active:focus, .button:active:hover, +input[type=submit]:active:focus, input[type=submit]:active:hover { + background-color: #d4d4d4; +} + +/* Object tools should be inline */ + +.object-tools { + padding-left: 0; + margin-left: -5px; + list-style: none; +} diff --git a/useradmin/templates/admin/base_site.html b/useradmin/templates/admin/base_site.html index 2399756c..713285ab 100644 --- a/useradmin/templates/admin/base_site.html +++ b/useradmin/templates/admin/base_site.html @@ -1,5 +1,11 @@ {# Please keep this template in sync with django/contrib/admin one #} {% extends "users/sidebar.html" %} +{% load static %} + +{% block extrastyle %} + {{ block.super }} + +{% endblock %} {% block title %}{{ title }}{% endblock %} diff --git a/useradmin/templates/useradmin/change_form.html b/useradmin/templates/useradmin/change_form.html index efae2d0d..b9b218de 100644 --- a/useradmin/templates/useradmin/change_form.html +++ b/useradmin/templates/useradmin/change_form.html @@ -20,18 +20,13 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. {% endcomment %} -{% load i18n admin_urls admin_modify %} +{% load i18n admin_urls %} -{% block object-tools %} -{% if change %}{% if not is_popup %} - -{% endif %}{% endif %} +{# Add buttons style and icons #} +{% block object-tools-items %} +
  • + {% url opts|admin_urlname:'history' original.pk|admin_urlquote as history_url %} + {% trans "History" %} +
  • +{% if has_absolute_url %}
  • {% trans "View on site" %}
  • {% endif %} {% endblock %} diff --git a/useradmin/templates/useradmin/delete_confirmation.html b/useradmin/templates/useradmin/delete_confirmation.html deleted file mode 100644 index eca368a5..00000000 --- a/useradmin/templates/useradmin/delete_confirmation.html +++ /dev/null @@ -1,55 +0,0 @@ -{% extends "admin/delete_confirmation.html" %} -{% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2019 Alexandre Iooss - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -{% endcomment %} -{% load i18n admin_urls %} - -{% block content %} -{% if perms_lacking %} -

    {% blocktrans with escaped_object=object %}Deleting the {{ object_name }} '{{ escaped_object }}' would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktrans %}

    - -{% elif protected %} -

    {% blocktrans with escaped_object=object %}Deleting the {{ object_name }} '{{ escaped_object }}' would require deleting the following protected related objects:{% endblocktrans %}

    - -{% else %} -

    {% blocktrans with escaped_object=object %}Are you sure you want to delete the {{ object_name }} "{{ escaped_object }}"? All of the following related items will be deleted:{% endblocktrans %}

    - {% include "admin/includes/object_delete_summary.html" %} -

    {% trans "Objects" %}

    - -
    {% csrf_token %} -
    - - {% if is_popup %}{% endif %} - {% if to_field %}{% endif %} - - {% trans "No, take me back" %} -
    -
    -{% endif %} -{% endblock %} diff --git a/useradmin/templates/useradmin/delete_selected_confirmation.html b/useradmin/templates/useradmin/delete_selected_confirmation.html deleted file mode 100644 index 50444bdd..00000000 --- a/useradmin/templates/useradmin/delete_selected_confirmation.html +++ /dev/null @@ -1,59 +0,0 @@ -{% extends "admin/delete_selected_confirmation.html" %} -{% comment %} -Re2o est un logiciel d'administration développé initiallement au rezometz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2019 Alexandre Iooss - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -{% endcomment %} -{% load i18n l10n admin_urls %} - -{% block content %} -{% if perms_lacking %} -

    {% blocktrans %}Deleting the selected {{ objects_name }} would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktrans %}

    - -{% elif protected %} -

    {% blocktrans %}Deleting the selected {{ objects_name }} would require deleting the following protected related objects:{% endblocktrans %}

    - -{% else %} -

    {% blocktrans %}Are you sure you want to delete the selected {{ objects_name }}? All of the following objects and their related items will be deleted:{% endblocktrans %}

    - {% include "admin/includes/object_delete_summary.html" %} -

    {% trans "Objects" %}

    - {% for deletable_object in deletable_objects %} - - {% endfor %} -
    {% csrf_token %} -
    - {% for obj in queryset %} - - {% endfor %} - - - - {% trans "No, take me back" %} -
    -
    -{% endif %} -{% endblock %}