8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-01 09:02:26 +00:00

Clean some templates and respect pagination_number

This commit is contained in:
Alexandre Iooss 2019-03-01 11:01:43 +01:00
parent fe2a76ed96
commit e09aa70a7e
6 changed files with 110 additions and 166 deletions

View file

@ -1,5 +1,28 @@
# -*- mode: python; coding: utf-8 -*-
# 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.
from django.contrib import admin from django.contrib import admin
from preferences.models import GeneralOption
class UserAdmin(admin.sites.AdminSite): class UserAdmin(admin.sites.AdminSite):
def has_permission(self, request): def has_permission(self, request):
@ -11,6 +34,14 @@ class ModelUserAdmin(admin.ModelAdmin):
# Display actions on changelist bottom bu default # Display actions on changelist bottom bu default
actions_on_bottom = True actions_on_bottom = True
# Correct number of item per page
list_per_page = GeneralOption.get_cached_value('pagination_number')
# 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 # Defines new management site
user_admin_site = UserAdmin(name='user_admin') user_admin_site = UserAdmin(name='user_admin')

View file

@ -1,86 +0,0 @@
{# Please keep this template in sync with django/contrib/admin one #}
{% extends "admin/base_site.html" %}
{% load i18n admin_urls static admin_modify %}
{% block extrahead %}{{ block.super }}
<script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
{{ media }}
{% endblock %}
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% endblock %}
{% block coltype %}colM{% endblock %}
{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-form{% endblock %}
{% if not is_popup %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
&rsaquo; <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a>
&rsaquo; {% if has_change_permission %}<a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %}
&rsaquo; {% if add %}{% blocktrans with name=opts.verbose_name %}Add {{ name }}{% endblocktrans %}{% else %}{{ original|truncatewords:"18" }}{% endif %}
</div>
{% endblock %}
{% endif %}
{% block content %}<div id="content-main">
{% block object-tools %}
{% if change %}{% if not is_popup %}
<ul class="object-tools list-inline">
{% block object-tools-items %}
<li class="btn-group">
{% url opts|admin_urlname:'history' original.pk|admin_urlquote as history_url %}
<a href="{% add_preserved_filters history_url %}" class="historylink btn btn-default"><span class="glyphicon glyphicon-list-alt"></span> {% trans "History" %}</a>
</li>
{% if has_absolute_url %}<li class="btn-group"><a href="{{ absolute_url }}" class="viewsitelink btn btn-default"><span class="glyphicon glyphicon-new-window"></span> {% trans "View on site" %}</a></li>{% endif %}
{% endblock %}
</ul>
{% endif %}{% endif %}
{% endblock %}
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form" novalidate>{% csrf_token %}{% block form_top %}{% endblock %}
<div>
{% if is_popup %}<input type="hidden" name="{{ is_popup_var }}" value="1" />{% endif %}
{% if to_field %}<input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}" />{% endif %}
{% if save_on_top %}{% block submit_buttons_top %}{% submit_row %}{% endblock %}{% endif %}
{% if errors %}
<p class="errornote">
{% if errors|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
</p>
{{ adminform.form.non_field_errors }}
{% endif %}
{% block field_sets %}
{% for fieldset in adminform %}
{% include "admin/includes/fieldset.html" %}
{% endfor %}
{% endblock %}
{% block after_field_sets %}{% endblock %}
{% block inline_field_sets %}
{% for inline_admin_formset in inline_admin_formsets %}
{% include inline_admin_formset.opts.template %}
{% endfor %}
{% endblock %}
{% block after_related_objects %}{% endblock %}
{% block submit_buttons_bottom %}{% submit_row %}{% endblock %}
{% block admin_change_form_document_ready %}
<script type="text/javascript"
id="django-admin-form-add-constants"
src="{% static 'admin/js/change_form.js' %}"
{% if adminform and add %}
data-model-name="{{ opts.model_name }}"
{% endif %}>
</script>
{% endblock %}
{# JavaScript for prepopulated fields #}
{% prepopulated_fields_js %}
</div>
</form></div>
{% endblock %}

View file

@ -1,43 +0,0 @@
{# Please keep this template in sync with django/contrib/admin one #}
{% extends "admin/base_site.html" %}
{% load i18n admin_urls %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
&rsaquo; <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a>
&rsaquo; <a href="{% url opts|admin_urlname:'changelist' %}">{{ module_name }}</a>
&rsaquo; <a href="{% url opts|admin_urlname:'change' object.pk|admin_urlquote %}">{{ object|truncatewords:"18" }}</a>
&rsaquo; {% trans 'History' %}
</div>
{% endblock %}
{% block content %}
<div id="content-main">
<div class="module">
{% if action_list %}
<table id="change-history" class="table table-striped table-bordered">
<thead>
<tr>
<th scope="col">{% trans 'Date/time' %}</th>
<th scope="col">{% trans 'User' %}</th>
<th scope="col">{% trans 'Action' %}</th>
</tr>
</thead>
<tbody>
{% for action in action_list %}
<tr>
<th scope="row">{{ action.action_time|date:"DATETIME_FORMAT" }}</th>
<td>{{ action.user.get_username }}{% if action.user.get_full_name %} ({{ action.user.get_full_name }}){% endif %}</td>
<td>{{ action.get_change_message }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>{% trans "This object doesn't have a change history. It probably wasn't added via this admin site." %}</p>
{% endif %}
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,37 @@
{% extends "admin/change_form.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 admin_modify %}
{% block object-tools %}
{% if change %}{% if not is_popup %}
<ul class="object-tools list-inline">
{% block object-tools-items %}
<li class="btn-group">
{% url opts|admin_urlname:'history' original.pk|admin_urlquote as history_url %}
<a href="{% add_preserved_filters history_url %}" class="historylink btn btn-default"><span class="glyphicon glyphicon-list-alt"></span> {% trans "History" %}</a>
</li>
{% if has_absolute_url %}<li class="btn-group"><a href="{{ absolute_url }}" class="viewsitelink btn btn-default"><span class="glyphicon glyphicon-new-window"></span> {% trans "View on site" %}</a></li>{% endif %}
{% endblock %}
</ul>
{% endif %}{% endif %}
{% endblock %}

View file

@ -1,24 +1,26 @@
{# Please keep this template in sync with django/contrib/admin one #} {% extends "admin/delete_confirmation.html" %}
{% extends "admin/base_site.html" %} {% comment %}
{% load i18n admin_urls static %} 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.
{% block extrahead %} Copyright © 2019 Alexandre Iooss
{{ block.super }}
{{ media }}
<script type="text/javascript" src="{% static 'admin/js/cancel.js' %}"></script>
{% endblock %}
{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation{% endblock %} 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.
{% block breadcrumbs %} This program is distributed in the hope that it will be useful,
<div class="breadcrumbs"> but WITHOUT ANY WARRANTY; without even the implied warranty of
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
&rsaquo; <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a> GNU General Public License for more details.
&rsaquo; <a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst|escape }}</a>
&rsaquo; <a href="{% url opts|admin_urlname:'change' object.pk|admin_urlquote %}">{{ object|truncatewords:"18" }}</a> You should have received a copy of the GNU General Public License along
&rsaquo; {% trans 'Delete' %} with this program; if not, write to the Free Software Foundation, Inc.,
</div> 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endblock %} {% endcomment %}
{% load i18n admin_urls %}
{% block content %} {% block content %}
{% if perms_lacking %} {% if perms_lacking %}
@ -46,7 +48,7 @@
{% if is_popup %}<input type="hidden" name="{{ is_popup_var }}" value="1" />{% endif %} {% if is_popup %}<input type="hidden" name="{{ is_popup_var }}" value="1" />{% endif %}
{% if to_field %}<input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}" />{% endif %} {% if to_field %}<input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}" />{% endif %}
<input type="submit" class="btn btn-danger" value="{% trans "Yes, I'm sure" %}" /> <input type="submit" class="btn btn-danger" value="{% trans "Yes, I'm sure" %}" />
<a href="#" class="button cancel-link">{% trans "No, take me back" %}</a> <a href="#" class="button cancel-link btn btn-default">{% trans "No, take me back" %}</a>
</div> </div>
</form> </form>
{% endif %} {% endif %}

View file

@ -1,23 +1,26 @@
{# Please keep this template in sync with django/contrib/admin one #} {% extends "admin/delete_selected_confirmation.html" %}
{% extends "admin/base_site.html" %} {% comment %}
{% load i18n l10n admin_urls static %} 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.
{% block extrahead %} Copyright © 2019 Alexandre Iooss
{{ block.super }}
{{ media }}
<script type="text/javascript" src="{% static 'admin/js/cancel.js' %}"></script>
{% endblock %}
{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation delete-selected-confirmation{% endblock %} 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.
{% block breadcrumbs %} This program is distributed in the hope that it will be useful,
<div class="breadcrumbs"> but WITHOUT ANY WARRANTY; without even the implied warranty of
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
&rsaquo; <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a> GNU General Public License for more details.
&rsaquo; <a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a>
&rsaquo; {% trans 'Delete multiple objects' %} You should have received a copy of the GNU General Public License along
</div> with this program; if not, write to the Free Software Foundation, Inc.,
{% endblock %} 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %}
{% load i18n l10n admin_urls %}
{% block content %} {% block content %}
{% if perms_lacking %} {% if perms_lacking %}
@ -49,7 +52,7 @@
<input type="hidden" name="action" value="delete_selected" /> <input type="hidden" name="action" value="delete_selected" />
<input type="hidden" name="post" value="yes" /> <input type="hidden" name="post" value="yes" />
<input type="submit" class="btn btn-danger" value="{% trans "Yes, I'm sure" %}" /> <input type="submit" class="btn btn-danger" value="{% trans "Yes, I'm sure" %}" />
<a href="#" class="button cancel-link">{% trans "No, take me back" %}</a> <a href="#" class="button cancel-link btn btn-default">{% trans "No, take me back" %}</a>
</div> </div>
</form> </form>
{% endif %} {% endif %}