Minor upgrades and test fixes.
[wolnelektury.git] / src / api / migrations / 0005_consumer_nonce_resource_token.py
1 # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
3 #
4 from django.conf import settings
5 from django.db import migrations, models
6 import django.db.models.deletion
7
8
9 class Migration(migrations.Migration):
10
11     dependencies = [
12         migrations.swappable_dependency(settings.AUTH_USER_MODEL),
13         ('api', '0004_bookuserdata_last_changed'),
14     ]
15
16     operations = [
17         migrations.CreateModel(
18             name='Consumer',
19             fields=[
20                 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21                 ('name', models.CharField(max_length=255)),
22                 ('description', models.TextField()),
23                 ('key', models.CharField(max_length=18)),
24                 ('secret', models.CharField(max_length=32)),
25                 ('status', models.CharField(choices=[('pending', 'Pending approval'), ('accepted', 'Accepted'), ('canceled', 'Canceled')], default='pending', max_length=16)),
26                 ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='consumers', to=settings.AUTH_USER_MODEL)),
27             ],
28         ),
29         migrations.CreateModel(
30             name='Nonce',
31             fields=[
32                 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
33                 ('token_key', models.CharField(max_length=18)),
34                 ('consumer_key', models.CharField(max_length=18)),
35                 ('key', models.CharField(max_length=255)),
36             ],
37         ),
38         migrations.CreateModel(
39             name='Token',
40             fields=[
41                 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
42                 ('key', models.CharField(max_length=18)),
43                 ('secret', models.CharField(max_length=32)),
44                 ('token_type', models.IntegerField(choices=[(1, 'Request'), (2, 'Access')])),
45                 ('timestamp', models.IntegerField()),
46                 ('is_approved', models.BooleanField(default=False)),
47                 ('consumer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Consumer')),
48                 ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tokens', to=settings.AUTH_USER_MODEL)),
49             ],
50         ),
51     ]