Commit 7d94609f authored by erdnaxe's avatar erdnaxe 🎇

Add shortcut and order

parent d08ac181
Pipeline #1426 failed with stage
in 3 minutes and 26 seconds
......@@ -20,6 +20,7 @@ class MediaAdminForm(ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['isbn'].widget.template_name = "media/isbn_button.html"
self.fields['isbn'].widget.attrs.update({'autofocus': 'autofocus'})
def download_data(self, isbn):
"""
......
# Generated by Django 2.2.4 on 2019-08-11 16:04
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('media', '0021_auto_20190811_1047'),
]
operations = [
migrations.AlterModelOptions(
name='auteur',
options={'ordering': ['nom'], 'verbose_name': 'author', 'verbose_name_plural': 'authors'},
),
migrations.AlterModelOptions(
name='emprunt',
options={'ordering': ['-date_emprunt'], 'verbose_name': 'borrowed item', 'verbose_name_plural': 'borrowed items'},
),
migrations.AlterModelOptions(
name='jeu',
options={'ordering': ['nom'], 'verbose_name': 'game', 'verbose_name_plural': 'games'},
),
migrations.AlterModelOptions(
name='media',
options={'ordering': ['title', 'subtitle'], 'verbose_name': 'medium', 'verbose_name_plural': 'media'},
),
]
......@@ -18,6 +18,7 @@ class Auteur(models.Model):
class Meta:
verbose_name = _("author")
verbose_name_plural = _("authors")
ordering = ['nom']
class Media(models.Model):
......@@ -62,11 +63,13 @@ class Media(models.Model):
)
def __str__(self):
return str(self.title) + ' - ' + str(self.authors.all().first())
return str(self.title) + ' - ' + str(self.subtitle) \
+ ' - ' + str(self.authors.all().first())
class Meta:
verbose_name = _("medium")
verbose_name_plural = _("media")
ordering = ['title', 'subtitle']
class Emprunt(models.Model):
......@@ -97,6 +100,7 @@ class Emprunt(models.Model):
class Meta:
verbose_name = _("borrowed item")
verbose_name_plural = _("borrowed items")
ordering = ['-date_emprunt']
class Jeu(models.Model):
......@@ -122,3 +126,4 @@ class Jeu(models.Model):
class Meta:
verbose_name = _("game")
verbose_name_plural = _("games")
ordering = ['nom']
{% 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_view_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">
{% block object-tools-items %}
{% change_form_object_tools %}
{% 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>
{# Bind CTRL+S to Save button #}
<script type="text/javascript">
django.jQuery(window).bind('keydown', function (event) {
if (event.ctrlKey || event.metaKey) {
if (String.fromCharCode(event.which).toLowerCase() === 's') {
event.preventDefault();
django.jQuery("#content-main form input[name=_save]").click();
}
}
});
</script>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment