Create first DB migrations and remove uuid
This commit is contained in:
parent
1bee4085e0
commit
a432535997
55
authserver/authserver/api/migrations/0001_initial.py
Normal file
55
authserver/authserver/api/migrations/0001_initial.py
Normal 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),
|
||||
),
|
||||
]
|
|
@ -1,3 +1,4 @@
|
|||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
|
||||
class Category(models.Model):
|
||||
|
@ -7,14 +8,13 @@ class Category(models.Model):
|
|||
photo = models.FileField(upload_to='media/')
|
||||
|
||||
class Tool(models.Model):
|
||||
uuid = models.UUIDField(default=uuid.uuid4, editable=False)
|
||||
category = models.ForeignKey(Category, related_name='tools')
|
||||
category = models.ForeignKey(Category, related_name='tools', on_delete=models.PROTECT)
|
||||
name = models.CharField(max_length=32)
|
||||
info = models.TextField(max_length=1024, blank=True)
|
||||
wiki_id = models.IntegerField()
|
||||
photo = models.FileField(upload_to='media/')
|
||||
|
||||
class Profile(models.Model):
|
||||
user = models.OneToOneField(User)
|
||||
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
||||
lockout_admin = models.BooleanField(default=False)
|
||||
authorized_tools = models.ManyToManyField(Tool)
|
||||
|
|
Loading…
Reference in New Issue
Block a user