Romans were missing
This commit is contained in:
parent
4ab2e9df57
commit
20cb710af5
|
@ -9,7 +9,7 @@ from reversion.admin import VersionAdmin
|
|||
|
||||
from med.admin import admin_site
|
||||
from .forms import MediaAdminForm
|
||||
from .models import Auteur, BD, CD, Emprunt, FutureMedia, Jeu, Manga, Vinyle
|
||||
from .models import Auteur, BD, CD, Emprunt, FutureMedia, Jeu, Manga, Roman, Vinyle
|
||||
|
||||
|
||||
class AuteurAdmin(VersionAdmin):
|
||||
|
@ -133,6 +133,7 @@ class JeuAdmin(VersionAdmin):
|
|||
admin_site.register(Auteur, AuteurAdmin)
|
||||
admin_site.register(BD, MediaAdmin)
|
||||
admin_site.register(Manga, MediaAdmin)
|
||||
admin_site.register(Roman, MediaAdmin)
|
||||
admin_site.register(CD, CDAdmin)
|
||||
admin_site.register(Vinyle, CDAdmin)
|
||||
admin_site.register(FutureMedia, FutureMediaAdmin)
|
||||
|
|
|
@ -166,6 +166,7 @@ class MediaAdminForm(ModelForm):
|
|||
if "_isbn_addanother" in self.data:
|
||||
self.data = self.data.copy()
|
||||
self.data['_addanother'] = 42
|
||||
self.request.POST = self.data
|
||||
if isbn:
|
||||
# ISBN is present, try with bedeteque
|
||||
scrap_result = self.download_data_bedeteque(isbn)
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
# Generated by Django 2.2.10 on 2020-05-22 19:07
|
||||
|
||||
from django.db import migrations, models
|
||||
import media.fields
|
||||
import media.validators
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('media', '0031_auto_20200522_1758'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='manga',
|
||||
options={'ordering': ['title'], 'verbose_name': 'manga', 'verbose_name_plural': 'mangas'},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Roman',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('isbn', media.fields.ISBNField(blank=True, help_text='You may be able to scan it from a bar code.', max_length=28, null=True, unique=True, validators=[media.validators.isbn_validator], verbose_name='ISBN')),
|
||||
('title', models.CharField(max_length=255, verbose_name='title')),
|
||||
('subtitle', models.CharField(blank=True, max_length=255, null=True, verbose_name='subtitle')),
|
||||
('external_url', models.URLField(blank=True, null=True, verbose_name='external URL')),
|
||||
('side_identifier', models.CharField(max_length=255, verbose_name='side identifier')),
|
||||
('number_of_pages', models.PositiveIntegerField(blank=True, null=True, verbose_name='number of pages')),
|
||||
('publish_date', models.DateField(blank=True, null=True, verbose_name='publish date')),
|
||||
('authors', models.ManyToManyField(to='media.Auteur', verbose_name='authors')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'roman',
|
||||
'verbose_name_plural': 'romans',
|
||||
'ordering': ['title', 'subtitle'],
|
||||
},
|
||||
),
|
||||
]
|
|
@ -140,6 +140,72 @@ class Manga(models.Model):
|
|||
null=True,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("manga")
|
||||
verbose_name_plural = _("mangas")
|
||||
ordering = ['title']
|
||||
|
||||
|
||||
class Roman(models.Model):
|
||||
isbn = ISBNField(
|
||||
_('ISBN'),
|
||||
help_text=_('You may be able to scan it from a bar code.'),
|
||||
unique=True,
|
||||
blank=True,
|
||||
null=True,
|
||||
)
|
||||
|
||||
title = models.CharField(
|
||||
verbose_name=_('title'),
|
||||
max_length=255,
|
||||
)
|
||||
|
||||
subtitle = models.CharField(
|
||||
verbose_name=_('subtitle'),
|
||||
max_length=255,
|
||||
blank=True,
|
||||
null=True,
|
||||
)
|
||||
|
||||
external_url = models.URLField(
|
||||
verbose_name=_('external URL'),
|
||||
blank=True,
|
||||
null=True,
|
||||
)
|
||||
|
||||
side_identifier = models.CharField(
|
||||
verbose_name=_('side identifier'),
|
||||
max_length=255,
|
||||
)
|
||||
|
||||
authors = models.ManyToManyField(
|
||||
'Auteur',
|
||||
verbose_name=_('authors'),
|
||||
)
|
||||
|
||||
number_of_pages = models.PositiveIntegerField(
|
||||
verbose_name=_('number of pages'),
|
||||
blank=True,
|
||||
null=True,
|
||||
)
|
||||
|
||||
publish_date = models.DateField(
|
||||
verbose_name=_('publish date'),
|
||||
blank=True,
|
||||
null=True,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("roman")
|
||||
verbose_name_plural = _("romans")
|
||||
ordering = ['title', 'subtitle']
|
||||
|
||||
|
||||
class Vinyle(models.Model):
|
||||
title = models.CharField(
|
||||
|
|
|
@ -25,41 +25,41 @@ class TemplateTests(TestCase):
|
|||
self.dummy_author = Auteur.objects.create(name="Test author")
|
||||
|
||||
# Create media
|
||||
self.dummy_media1 = BD.objects.create(
|
||||
self.dummy_bd1 = BD.objects.create(
|
||||
title="Test media",
|
||||
side_identifier="T M",
|
||||
)
|
||||
self.dummy_media1.authors.add(self.dummy_author)
|
||||
self.dummy_media2 = BD.objects.create(
|
||||
self.dummy_bd1.authors.add(self.dummy_author)
|
||||
self.dummy_bd2 = BD.objects.create(
|
||||
title="Test media bis",
|
||||
side_identifier="T M 2",
|
||||
external_url="https://example.com/",
|
||||
)
|
||||
self.dummy_media2.authors.add(self.dummy_author)
|
||||
self.dummy_bd2.authors.add(self.dummy_author)
|
||||
|
||||
def test_media_media_changelist(self):
|
||||
response = self.client.get(reverse('admin:media_media_changelist'))
|
||||
def test_bd_bd_changelist(self):
|
||||
response = self.client.get(reverse('admin:media_bd_changelist'))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_media_media_add(self):
|
||||
response = self.client.get(reverse('admin:media_media_add'))
|
||||
def test_bd_bd_add(self):
|
||||
response = self.client.get(reverse('admin:media_bd_add'))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_media_isbn_download(self):
|
||||
def test_bd_isbn_download(self):
|
||||
data = {
|
||||
'_isbn': True,
|
||||
'isbn': "0316358525",
|
||||
}
|
||||
response = self.client.post(reverse(
|
||||
'admin:media_media_change',
|
||||
args=[self.dummy_media1.id],
|
||||
'admin:media_bd_change',
|
||||
args=[self.dummy_bd1.id],
|
||||
), data=data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
def test_media_emprunt_changelist(self):
|
||||
def test_bd_emprunt_changelist(self):
|
||||
response = self.client.get(reverse('admin:media_emprunt_changelist'))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_media_emprunt_add(self):
|
||||
def test_bd_emprunt_add(self):
|
||||
response = self.client.get(reverse('admin:media_emprunt_add'))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
|
Loading…
Reference in New Issue