e6e2b513e61fd05a49c0fafc34f6ebaad8339d31
[redakcja.git] / src / dvcs / tests / migrations / 0001_initial.py
1 # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
3 #
4 import datetime
5 import os.path
6 from django.conf import settings
7 from django.db import migrations, models
8 import django.db.models.deletion
9 import dvcs.models
10 import dvcs.storage
11
12
13 class Migration(migrations.Migration):
14
15     initial = True
16
17     dependencies = [
18         migrations.swappable_dependency(settings.AUTH_USER_MODEL),
19     ]
20
21     operations = [
22         migrations.CreateModel(
23             name='ADocument',
24             fields=[
25                 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
26                 ('creator', models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_adocument', to=settings.AUTH_USER_MODEL, verbose_name='creator')),
27             ],
28             options={
29                 'abstract': False,
30             },
31         ),
32         migrations.CreateModel(
33             name='ADocumentChange',
34             fields=[
35                 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
36                 ('author_name', models.CharField(blank=True, help_text='Used if author is not set.', max_length=128, null=True, verbose_name='author name')),
37                 ('author_email', models.CharField(blank=True, help_text='Used if author is not set.', max_length=128, null=True, verbose_name='author email')),
38                 ('revision', models.IntegerField(db_index=True, verbose_name='revision')),
39                 ('description', models.TextField(blank=True, default=b'', verbose_name='description')),
40                 ('created_at', models.DateTimeField(db_index=True, default=datetime.datetime.now, editable=False)),
41                 ('publishable', models.BooleanField(default=False, verbose_name='publishable')),
42                 ('data', models.FileField(storage=dvcs.storage.GzipFileSystemStorage(location=os.path.join(settings.MEDIA_ROOT, 'dvcs')), upload_to=dvcs.models.data_upload_to, verbose_name='data')),
43                 ('author', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='author')),
44                 ('merge_parent', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='merge_children', to='tests.ADocumentChange', verbose_name='merge parent')),
45                 ('parent', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='tests.ADocumentChange', verbose_name='parent')),
46             ],
47             options={
48                 'ordering': ('created_at',),
49                 'abstract': False,
50                 'verbose_name': 'change for: a document',
51                 'verbose_name_plural': 'changes for: a document',
52             },
53         ),
54         migrations.CreateModel(
55             name='ADocumentTag',
56             fields=[
57                 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
58                 ('name', models.CharField(max_length=64, verbose_name='name')),
59                 ('slug', models.SlugField(blank=True, max_length=64, null=True, unique=True, verbose_name='slug')),
60                 ('ordering', models.IntegerField(verbose_name='ordering')),
61             ],
62             options={
63                 'ordering': ['ordering'],
64                 'abstract': False,
65                 'verbose_name': 'tag for: a document',
66                 'verbose_name_plural': 'tags for: a document',
67             },
68         ),
69         migrations.AddField(
70             model_name='adocumentchange',
71             name='tags',
72             field=models.ManyToManyField(related_name='change_set', to='tests.ADocumentTag', verbose_name='tags'),
73         ),
74         migrations.AddField(
75             model_name='adocumentchange',
76             name='tree',
77             field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='change_set', to='tests.ADocument', verbose_name='document'),
78         ),
79         migrations.AddField(
80             model_name='adocument',
81             name='head',
82             field=models.ForeignKey(blank=True, default=None, editable=False, help_text="This document's current head.", null=True, on_delete=django.db.models.deletion.CASCADE, to='tests.ADocumentChange', verbose_name='head'),
83         ),
84         migrations.AddField(
85             model_name='adocument',
86             name='stage',
87             field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='tests.ADocumentTag', verbose_name='stage'),
88         ),
89         migrations.AddField(
90             model_name='adocument',
91             name='user',
92             field=models.ForeignKey(blank=True, help_text='Work assignment.', null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='user'),
93         ),
94         migrations.AlterUniqueTogether(
95             name='adocumentchange',
96             unique_together=set([('tree', 'revision')]),
97         ),
98     ]