Added AmiiboCard model
This commit is contained in:
parent
cddab5d3d9
commit
13eece1e95
|
@ -35,7 +35,7 @@ class AmiiboShopResource(resources.ModelResource):
|
|||
class CollectionAdmin(ImportExportModelAdmin, reversion.VersionAdmin):
|
||||
resource_class = ColectionResource
|
||||
|
||||
list_display = ('name_eu', 'amiibo_number', )
|
||||
list_display = ('name_eu', 'amiibo_number', 'have_cards', )
|
||||
|
||||
def amiibo_number(self, obj):
|
||||
return obj.amiibos.count()
|
||||
|
@ -62,6 +62,21 @@ class AmiiboAdmin(ImportExportModelAdmin, reversion.VersionAdmin):
|
|||
box_image.allow_tags = True
|
||||
|
||||
|
||||
class AmiiboCardAdmin(ImportExportModelAdmin, reversion.VersionAdmin):
|
||||
resource_class = AmiiboResource
|
||||
|
||||
list_display_links = ('name_eu', )
|
||||
list_display = ('image_image', 'name_eu', 'collection', 'dice', 'rps', )
|
||||
search_fields = ('collection__name_eu', 'name_eu', 'name_us',)
|
||||
|
||||
def image_image(self, obj):
|
||||
if obj.image:
|
||||
return '<img src="{}" width="80" />'.format(obj.image.url)
|
||||
else:
|
||||
return ''
|
||||
image_image.allow_tags = True
|
||||
|
||||
|
||||
class AmiiboShopAdmin(ImportExportModelAdmin, reversion.VersionAdmin):
|
||||
resource_class = AmiiboShopResource
|
||||
list_display = ('amiibo', 'shop', 'check_price')
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import amiibofindr.apps.amiibo.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('amiibo', '0018_amiiboshop_check_price'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='AmiiboCard',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('number', models.IntegerField(default=1)),
|
||||
('name', models.CharField(max_length=60)),
|
||||
('name_en', models.CharField(max_length=64, null=True, blank=True)),
|
||||
('name_es', models.CharField(max_length=64, null=True, blank=True)),
|
||||
('name_fr', models.CharField(max_length=64, null=True, blank=True)),
|
||||
('name_it', models.CharField(max_length=64, null=True, blank=True)),
|
||||
('name_de', models.CharField(max_length=64, null=True, blank=True)),
|
||||
('name_eu', models.CharField(max_length=64, null=True, blank=True)),
|
||||
('name_jp', models.CharField(max_length=64, null=True, blank=True)),
|
||||
('name_us', models.CharField(max_length=64, null=True, blank=True)),
|
||||
('slug', models.SlugField(max_length=60)),
|
||||
('image', models.ImageField(upload_to=amiibofindr.apps.amiibo.models.image_card_upload)),
|
||||
('dice', models.IntegerField(default=1)),
|
||||
('rps', models.CharField(default=1, max_length=1, choices=[(1, b'Rock'), (2, b'Paper'), (3, b'Scissors')])),
|
||||
],
|
||||
options={
|
||||
'ordering': ('collection', 'number', 'name'),
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='collection',
|
||||
name='have_cards',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='amiibocard',
|
||||
name='collection',
|
||||
field=models.ForeignKey(related_name='cards_qs', to='amiibo.Collection'),
|
||||
),
|
||||
]
|
|
@ -39,6 +39,7 @@ class Collection(models.Model):
|
|||
name_eu = models.CharField(max_length=128)
|
||||
name_jp = models.CharField(max_length=128, blank=True, null=True)
|
||||
name_us = models.CharField(max_length=128, blank=True, null=True)
|
||||
have_cards = models.BooleanField(default=False)
|
||||
|
||||
@property
|
||||
def amiibos(self):
|
||||
|
@ -58,7 +59,7 @@ class Collection(models.Model):
|
|||
|
||||
class Amiibo(models.Model):
|
||||
collection = models.ForeignKey(Collection, related_name='amiibos_qs')
|
||||
Collection_number = models.IntegerField(blank=True, null=True)
|
||||
collection_number = models.IntegerField(blank=True, null=True)
|
||||
|
||||
model_number = models.CharField(max_length=20, blank=True, null=True)
|
||||
|
||||
|
@ -114,13 +115,24 @@ class AmiiboCard(models.Model):
|
|||
(SCISSORS, 'Scissors'),
|
||||
)
|
||||
|
||||
collection = models.ForeignKey(Collection, related_name='amiibos_qs')
|
||||
collection = models.ForeignKey(Collection, related_name='cards_qs')
|
||||
number = models.IntegerField(default=1)
|
||||
name = models.CharField(max_length=60)
|
||||
|
||||
name_en = models.CharField(max_length=64, blank=True, null=True)
|
||||
name_es = models.CharField(max_length=64, blank=True, null=True)
|
||||
name_fr = models.CharField(max_length=64, blank=True, null=True)
|
||||
name_it = models.CharField(max_length=64, blank=True, null=True)
|
||||
name_de = models.CharField(max_length=64, blank=True, null=True)
|
||||
|
||||
name_eu = models.CharField(max_length=64, blank=True, null=True)
|
||||
name_jp = models.CharField(max_length=64, blank=True, null=True)
|
||||
name_us = models.CharField(max_length=64, blank=True, null=True)
|
||||
|
||||
slug = models.SlugField(max_length=60)
|
||||
image = models.ImageField(upload_to=image_card_upload)
|
||||
dice = models.IntegerField(default=1)
|
||||
rps = models.CharField(choices=RPS_CHOICES, default=ROCK)
|
||||
rps = models.CharField(choices=RPS_CHOICES, default=ROCK, max_length=1)
|
||||
|
||||
class Meta:
|
||||
ordering = ('collection', 'number', 'name', )
|
||||
|
|
Loading…
Reference in New Issue