diff --git a/media/admin.py b/media/admin.py index bbc06d2..47d19d2 100644 --- a/media/admin.py +++ b/media/admin.py @@ -18,9 +18,10 @@ class AuteurAdmin(VersionAdmin): class MediaAdmin(VersionAdmin): - list_display = ('title', 'authors_list', 'side_title', 'isbn', + list_display = ('title', 'authors_list', 'side_identifier', 'isbn', 'external_link') - search_fields = ('title', 'authors__nom', 'side_title', 'subtitle', 'isbn') + search_fields = ('title', 'authors__nom', 'side_identifier', 'subtitle', + 'isbn') autocomplete_fields = ('authors',) date_hierarchy = 'publish_date' form = MediaAdminForm @@ -31,8 +32,11 @@ class MediaAdmin(VersionAdmin): authors_list.short_description = _('authors') def external_link(self, obj): - return format_html('{}', - obj.external_url, obj.external_url) + if obj.external_url: + return format_html('{}', + obj.external_url, obj.external_url) + else: + return "-" external_link.allow_tags = True external_link.short_description = _('external url') @@ -59,8 +63,8 @@ class MediaAdmin(VersionAdmin): class EmpruntAdmin(VersionAdmin): list_display = ('media', 'user', 'date_emprunt', 'date_rendu', 'permanencier_emprunt', 'permanencier_rendu_custom') - search_fields = ('media__title', 'media__side_title', 'user__username', - 'date_emprunt', 'date_rendu') + search_fields = ('media__title', 'media__side_identifier', + 'user__username', 'date_emprunt', 'date_rendu') date_hierarchy = 'date_emprunt' autocomplete_fields = ('media', 'user', 'permanencier_emprunt', 'permanencier_rendu') diff --git a/media/forms.py b/media/forms.py index 7f0b089..2fb16e6 100644 --- a/media/forms.py +++ b/media/forms.py @@ -33,10 +33,9 @@ class MediaAdminForm(ModelForm): data = data['ISBN:' + isbn] # Fill the data - # TODO implement authors + # TODO implement authors, side_identifier if data['title']: self.cleaned_data['title'] = data['title'] - self.cleaned_data['side_title'] = data['title'] if data['subtitle']: self.cleaned_data['subtitle'] = data['subtitle'] if data['url']: diff --git a/media/locale/fr/LC_MESSAGES/django.po b/media/locale/fr/LC_MESSAGES/django.po index 5b7b3ef..6eebe05 100644 --- a/media/locale/fr/LC_MESSAGES/django.po +++ b/media/locale/fr/LC_MESSAGES/django.po @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-08-11 10:39+0200\n" +"POT-Creation-Date: 2019-08-11 10:46+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -13,19 +13,19 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: admin.py:31 models.py:20 models.py:51 +#: admin.py:32 models.py:20 models.py:51 msgid "authors" msgstr "auteurs" -#: admin.py:38 +#: admin.py:39 msgid "external url" msgstr "URL externe" -#: admin.py:78 +#: admin.py:79 msgid "Turn back" msgstr "Rendre" -#: admin.py:81 +#: admin.py:82 msgid "permanencier rendu" msgstr "" @@ -58,7 +58,7 @@ msgid "external URL" msgstr "URL externe" #: models.py:46 -msgid "side title" +msgid "side identifier" msgstr "côte" #: models.py:54 diff --git a/media/migrations/0020_auto_20190811_1047.py b/media/migrations/0020_auto_20190811_1047.py new file mode 100644 index 0000000..3f85a69 --- /dev/null +++ b/media/migrations/0020_auto_20190811_1047.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.4 on 2019-08-11 08:47 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('media', '0019_auto_20190811_0919'), + ] + + operations = [ + migrations.RenameField( + model_name='media', + old_name='side_title', + new_name='side_identifier', + ), + ] diff --git a/media/migrations/0021_auto_20190811_1047.py b/media/migrations/0021_auto_20190811_1047.py new file mode 100644 index 0000000..ecdb34d --- /dev/null +++ b/media/migrations/0021_auto_20190811_1047.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.4 on 2019-08-11 08:47 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('media', '0020_auto_20190811_1047'), + ] + + operations = [ + migrations.AlterField( + model_name='media', + name='side_identifier', + field=models.CharField(max_length=255, verbose_name='side identifier'), + ), + ] diff --git a/media/models.py b/media/models.py index a4a8776..5c86ce8 100644 --- a/media/models.py +++ b/media/models.py @@ -42,8 +42,8 @@ class Media(models.Model): blank=True, null=True, ) - side_title = models.CharField( - verbose_name=_('side title'), + side_identifier = models.CharField( + verbose_name=_('side identifier'), max_length=255, ) authors = models.ManyToManyField(