Migrate some models in a new app

This commit is contained in:
2021-12-20 22:47:45 +01:00
parent 9879a8ae62
commit c5bc00d925
13 changed files with 155 additions and 36 deletions

0
dcc/metadata/__init__.py Normal file
View File

6
dcc/metadata/admin.py Normal file
View File

@@ -0,0 +1,6 @@
from django.contrib import admin
from metadata.models import Decoder, Manufacturer, Company
admin.site.register(Decoder)
admin.site.register(Company)
admin.site.register(Manufacturer)

6
dcc/metadata/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class MetadataConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'metadata'

View File

@@ -0,0 +1,42 @@
# Generated by Django 4.0 on 2021-12-20 21:37
from django.db import migrations, models
import django.db.models.deletion
import django_countries.fields
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Company',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=128, unique=True)),
('country', django_countries.fields.CountryField(max_length=2)),
],
options={
'verbose_name_plural': 'Companies',
},
),
migrations.CreateModel(
name='Manufacturer',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=128, unique=True)),
],
),
migrations.CreateModel(
name='Decoder',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=128, unique=True)),
('manufacturer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='metadata.manufacturer')),
],
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 4.0 on 2021-12-20 21:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('metadata', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='decoder',
name='version',
field=models.CharField(blank=True, max_length=64),
),
]

View File

31
dcc/metadata/models.py Normal file
View File

@@ -0,0 +1,31 @@
from django.db import models
from django_countries.fields import CountryField
class Manufacturer(models.Model):
name = models.CharField(max_length=128, unique=True)
def __str__(self):
return self.name
class Company(models.Model):
name = models.CharField(max_length=128, unique=True)
country = CountryField()
class Meta:
verbose_name_plural = "Companies"
def __str__(self):
return self.name
class Decoder(models.Model):
name = models.CharField(max_length=128, unique=True)
manufacturer = models.ForeignKey(
Manufacturer,
on_delete=models.CASCADE)
version = models.CharField(max_length=64, blank=True)
def __str__(self):
return "{0} - {1}".format(self.manufacturer, self.name)

3
dcc/metadata/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
dcc/metadata/views.py Normal file
View File

@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.