Add properties

This commit is contained in:
2022-04-07 11:11:52 +02:00
parent 9a1740f7c1
commit 2b9e604b21
7 changed files with 118 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
from django.contrib import admin
from metadata.models import (
Property,
Decoder,
Scale,
Manufacturer,
@@ -9,6 +10,11 @@ from metadata.models import (
)
@admin.register(Property)
class PropertyAdmin(admin.ModelAdmin):
search_fields = ("name",)
@admin.register(Decoder)
class DecoderAdmin(admin.ModelAdmin):
readonly_fields = ("image_thumbnail",)

View File

@@ -0,0 +1,33 @@
# Generated by Django 4.0.3 on 2022-04-07 09:03
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('metadata', '0007_alter_manufacturer_category'),
]
operations = [
migrations.CreateModel(
name='Property',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=128, unique=True)),
],
options={
'verbose_name_plural': 'Properties',
'ordering': ['name'],
},
),
migrations.AlterModelOptions(
name='manufacturer',
options={'ordering': ['category', 'name']},
),
migrations.AlterField(
model_name='manufacturer',
name='category',
field=models.CharField(choices=[('model', 'Model'), ('real', 'Real')], max_length=64),
),
]

View File

@@ -6,6 +6,17 @@ from django_countries.fields import CountryField
from dcc.utils import get_image_preview, slugify
class Property(models.Model):
name = models.CharField(max_length=128, unique=True)
class Meta:
verbose_name_plural = "Properties"
ordering = ["name"]
def __str__(self):
return self.name
class Manufacturer(models.Model):
name = models.CharField(max_length=128, unique=True)
category = models.CharField(