Create first DB migrations and remove uuid

This commit is contained in:
Tanner Collin 2018-09-12 15:42:04 -06:00
parent 1bee4085e0
commit a432535997
2 changed files with 58 additions and 3 deletions

View File

@ -0,0 +1,55 @@
# Generated by Django 2.1.1 on 2018-09-12 21:41
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Category',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=32)),
('slug', models.CharField(max_length=32)),
('info', models.TextField(blank=True, max_length=1024)),
('photo', models.FileField(upload_to='media/')),
],
),
migrations.CreateModel(
name='Profile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('lockout_admin', models.BooleanField(default=False)),
],
),
migrations.CreateModel(
name='Tool',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=32)),
('info', models.TextField(blank=True, max_length=1024)),
('wiki_id', models.IntegerField()),
('photo', models.FileField(upload_to='media/')),
('category', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='tools', to='api.Category')),
],
),
migrations.AddField(
model_name='profile',
name='authorized_tools',
field=models.ManyToManyField(to='api.Tool'),
),
migrations.AddField(
model_name='profile',
name='user',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
]

View File

@ -1,3 +1,4 @@
from django.contrib.auth.models import User
from django.db import models from django.db import models
class Category(models.Model): class Category(models.Model):
@ -7,14 +8,13 @@ class Category(models.Model):
photo = models.FileField(upload_to='media/') photo = models.FileField(upload_to='media/')
class Tool(models.Model): class Tool(models.Model):
uuid = models.UUIDField(default=uuid.uuid4, editable=False) category = models.ForeignKey(Category, related_name='tools', on_delete=models.PROTECT)
category = models.ForeignKey(Category, related_name='tools')
name = models.CharField(max_length=32) name = models.CharField(max_length=32)
info = models.TextField(max_length=1024, blank=True) info = models.TextField(max_length=1024, blank=True)
wiki_id = models.IntegerField() wiki_id = models.IntegerField()
photo = models.FileField(upload_to='media/') photo = models.FileField(upload_to='media/')
class Profile(models.Model): class Profile(models.Model):
user = models.OneToOneField(User) user = models.OneToOneField(User, on_delete=models.CASCADE)
lockout_admin = models.BooleanField(default=False) lockout_admin = models.BooleanField(default=False)
authorized_tools = models.ManyToManyField(Tool) authorized_tools = models.ManyToManyField(Tool)