794db4820bc16e63c32aff132bdb4a0db1a9737b
[redakcja.git] / src / catalogue / migrations / 0001_initial.py
1 from django.db import models, migrations
2 import datetime
3 import django.db.models.deletion
4 from django.conf import settings
5 import dvcs.models
6 import dvcs.storage
7
8
9 class Migration(migrations.Migration):
10
11     dependencies = [
12         ('auth', '0001_initial'),
13         ('cover', '0001_initial'),
14         migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15     ]
16
17     operations = [
18         migrations.CreateModel(
19             name='Book',
20             fields=[
21                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
22                 ('title', models.CharField(max_length=255, verbose_name='title', db_index=True)),
23                 ('slug', models.SlugField(unique=True, max_length=128, verbose_name='slug')),
24                 ('public', models.BooleanField(default=True, db_index=True, verbose_name='public')),
25                 ('gallery', models.CharField(max_length=255, verbose_name='scan gallery name', blank=True)),
26                 ('parent_number', models.IntegerField(db_index=True, verbose_name='parent number', null=True, editable=False, blank=True)),
27                 ('_short_html', models.TextField(null=True, editable=False, blank=True)),
28                 ('_single', models.NullBooleanField(db_index=True, editable=False)),
29                 ('_new_publishable', models.NullBooleanField(editable=False)),
30                 ('_published', models.NullBooleanField(editable=False)),
31                 ('_on_track', models.IntegerField(db_index=True, null=True, editable=False, blank=True)),
32                 ('dc_slug', models.CharField(db_index=True, max_length=128, null=True, editable=False, blank=True)),
33             ],
34             options={
35                 'ordering': ['title', 'slug'],
36                 'verbose_name': 'book',
37                 'verbose_name_plural': 'books',
38             },
39             bases=(models.Model,),
40         ),
41         migrations.CreateModel(
42             name='BookPublishRecord',
43             fields=[
44                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
45                 ('timestamp', models.DateTimeField(auto_now_add=True, verbose_name='time')),
46                 ('book', models.ForeignKey(related_name='publish_log', verbose_name='book', to='catalogue.Book', on_delete=models.CASCADE)),
47                 ('user', models.ForeignKey(verbose_name='user', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
48             ],
49             options={
50                 'ordering': ['-timestamp'],
51                 'verbose_name': 'book publish record',
52                 'verbose_name_plural': 'book publish records',
53             },
54             bases=(models.Model,),
55         ),
56         migrations.CreateModel(
57             name='Chunk',
58             fields=[
59                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
60                 ('number', models.IntegerField(verbose_name='number')),
61                 ('title', models.CharField(max_length=255, verbose_name='title', blank=True)),
62                 ('slug', models.SlugField(verbose_name='slug')),
63                 ('gallery_start', models.IntegerField(default=1, null=True, verbose_name='gallery start', blank=True)),
64                 ('_short_html', models.TextField(null=True, editable=False, blank=True)),
65                 ('_hidden', models.NullBooleanField(editable=False)),
66                 ('_changed', models.NullBooleanField(editable=False)),
67                 ('book', models.ForeignKey(editable=False, to='catalogue.Book', verbose_name='book', on_delete=models.CASCADE)),
68                 ('creator', models.ForeignKey(related_name='created_chunk', blank=True, editable=False, to=settings.AUTH_USER_MODEL, null=True, verbose_name='creator', on_delete=models.CASCADE)),
69             ],
70             options={
71                 'ordering': ['number'],
72                 'verbose_name': 'chunk',
73                 'verbose_name_plural': 'chunks',
74                 'permissions': [('can_pubmark', 'Can mark for publishing')],
75             },
76             bases=(models.Model,),
77         ),
78         migrations.CreateModel(
79             name='ChunkChange',
80             fields=[
81                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
82                 ('author_name', models.CharField(help_text='Used if author is not set.', max_length=128, null=True, verbose_name='author name', blank=True)),
83                 ('author_email', models.CharField(help_text='Used if author is not set.', max_length=128, null=True, verbose_name='author email', blank=True)),
84                 ('revision', models.IntegerField(verbose_name='revision', db_index=True)),
85                 ('description', models.TextField(default=b'', verbose_name='description', blank=True)),
86                 ('created_at', models.DateTimeField(default=datetime.datetime.now, editable=False, db_index=True)),
87                 ('publishable', models.BooleanField(default=False, verbose_name='publishable')),
88                 ('data', models.FileField(upload_to=dvcs.models.data_upload_to, storage=dvcs.storage.GzipFileSystemStorage(location=settings.CATALOGUE_REPO_PATH), verbose_name='data')),
89                 ('author', models.ForeignKey(verbose_name='author', blank=True, to=settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE)),
90                 ('merge_parent', models.ForeignKey(related_name='merge_children', default=None, blank=True, to='catalogue.ChunkChange', null=True, verbose_name='merge parent', on_delete=models.CASCADE)),
91                 ('parent', models.ForeignKey(related_name='children', default=None, blank=True, to='catalogue.ChunkChange', null=True, verbose_name='parent', on_delete=models.CASCADE)),
92             ],
93             options={
94                 'ordering': ('created_at',),
95                 'abstract': False,
96                 'verbose_name': 'change for: chunk',
97                 'verbose_name_plural': 'changes for: chunk',
98             },
99             bases=(models.Model,),
100         ),
101         migrations.CreateModel(
102             name='ChunkPublishRecord',
103             fields=[
104                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
105                 ('book_record', models.ForeignKey(verbose_name='book publish record', to='catalogue.BookPublishRecord', on_delete=models.CASCADE)),
106                 ('change', models.ForeignKey(related_name='publish_log', verbose_name='change', to='catalogue.ChunkChange', on_delete=models.CASCADE)),
107             ],
108             options={
109                 'verbose_name': 'chunk publish record',
110                 'verbose_name_plural': 'chunk publish records',
111             },
112             bases=(models.Model,),
113         ),
114         migrations.CreateModel(
115             name='ChunkTag',
116             fields=[
117                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
118                 ('name', models.CharField(max_length=64, verbose_name='name')),
119                 ('slug', models.SlugField(null=True, max_length=64, blank=True, unique=True, verbose_name='slug')),
120                 ('ordering', models.IntegerField(verbose_name='ordering')),
121             ],
122             options={
123                 'ordering': ['ordering'],
124                 'abstract': False,
125                 'verbose_name': 'tag for: chunk',
126                 'verbose_name_plural': 'tags for: chunk',
127             },
128             bases=(models.Model,),
129         ),
130         migrations.CreateModel(
131             name='Image',
132             fields=[
133                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
134                 ('image', models.FileField(upload_to=b'catalogue/images', verbose_name='image')),
135                 ('title', models.CharField(max_length=255, verbose_name='title', blank=True)),
136                 ('slug', models.SlugField(unique=True, verbose_name='slug')),
137                 ('public', models.BooleanField(default=True, db_index=True, verbose_name='public')),
138                 ('_short_html', models.TextField(null=True, editable=False, blank=True)),
139                 ('_new_publishable', models.NullBooleanField(editable=False)),
140                 ('_published', models.NullBooleanField(editable=False)),
141                 ('_changed', models.NullBooleanField(editable=False)),
142                 ('creator', models.ForeignKey(related_name='created_image', blank=True, editable=False, to=settings.AUTH_USER_MODEL, null=True, verbose_name='creator', on_delete=models.CASCADE)),
143             ],
144             options={
145                 'ordering': ['title'],
146                 'verbose_name': 'image',
147                 'verbose_name_plural': 'images',
148                 'permissions': [('can_pubmark_image', 'Can mark images for publishing')],
149             },
150             bases=(models.Model,),
151         ),
152         migrations.CreateModel(
153             name='ImageChange',
154             fields=[
155                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
156                 ('author_name', models.CharField(help_text='Used if author is not set.', max_length=128, null=True, verbose_name='author name', blank=True)),
157                 ('author_email', models.CharField(help_text='Used if author is not set.', max_length=128, null=True, verbose_name='author email', blank=True)),
158                 ('revision', models.IntegerField(verbose_name='revision', db_index=True)),
159                 ('description', models.TextField(default=b'', verbose_name='description', blank=True)),
160                 ('created_at', models.DateTimeField(default=datetime.datetime.now, editable=False, db_index=True)),
161                 ('publishable', models.BooleanField(default=False, verbose_name='publishable')),
162                 ('data', models.FileField(upload_to=dvcs.models.data_upload_to, storage=dvcs.storage.GzipFileSystemStorage(location=settings.CATALOGUE_IMAGE_REPO_PATH), verbose_name='data')),
163                 ('author', models.ForeignKey(verbose_name='author', blank=True, to=settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE)),
164                 ('merge_parent', models.ForeignKey(related_name='merge_children', default=None, blank=True, to='catalogue.ImageChange', null=True, verbose_name='merge parent', on_delete=models.CASCADE)),
165                 ('parent', models.ForeignKey(related_name='children', default=None, blank=True, to='catalogue.ImageChange', null=True, verbose_name='parent', on_delete=models.CASCADE)),
166             ],
167             options={
168                 'ordering': ('created_at',),
169                 'abstract': False,
170                 'verbose_name': 'change for: image',
171                 'verbose_name_plural': 'changes for: image',
172             },
173             bases=(models.Model,),
174         ),
175         migrations.CreateModel(
176             name='ImagePublishRecord',
177             fields=[
178                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
179                 ('timestamp', models.DateTimeField(auto_now_add=True, verbose_name='time')),
180                 ('change', models.ForeignKey(related_name='publish_log', verbose_name='change', to='catalogue.ImageChange', on_delete=models.CASCADE)),
181                 ('image', models.ForeignKey(related_name='publish_log', verbose_name='image', to='catalogue.Image', on_delete=models.CASCADE)),
182                 ('user', models.ForeignKey(verbose_name='user', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
183             ],
184             options={
185                 'ordering': ['-timestamp'],
186                 'verbose_name': 'image publish record',
187                 'verbose_name_plural': 'image publish records',
188             },
189             bases=(models.Model,),
190         ),
191         migrations.CreateModel(
192             name='ImageTag',
193             fields=[
194                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
195                 ('name', models.CharField(max_length=64, verbose_name='name')),
196                 ('slug', models.SlugField(null=True, max_length=64, blank=True, unique=True, verbose_name='slug')),
197                 ('ordering', models.IntegerField(verbose_name='ordering')),
198             ],
199             options={
200                 'ordering': ['ordering'],
201                 'abstract': False,
202                 'verbose_name': 'tag for: image',
203                 'verbose_name_plural': 'tags for: image',
204             },
205             bases=(models.Model,),
206         ),
207         migrations.CreateModel(
208             name='Project',
209             fields=[
210                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
211                 ('name', models.CharField(unique=True, max_length=255, verbose_name='name')),
212                 ('notes', models.TextField(null=True, verbose_name='notes', blank=True)),
213             ],
214             options={
215                 'ordering': ['name'],
216                 'verbose_name': 'project',
217                 'verbose_name_plural': 'projects',
218             },
219             bases=(models.Model,),
220         ),
221         migrations.AddField(
222             model_name='imagechange',
223             name='tags',
224             field=models.ManyToManyField(related_name='change_set', verbose_name='tags', to='catalogue.ImageTag'),
225             preserve_default=True,
226         ),
227         migrations.AddField(
228             model_name='imagechange',
229             name='tree',
230             field=models.ForeignKey(related_name='change_set', verbose_name='document', to='catalogue.Image', on_delete=models.CASCADE),
231             preserve_default=True,
232         ),
233         migrations.AlterUniqueTogether(
234             name='imagechange',
235             unique_together=set([('tree', 'revision')]),
236         ),
237         migrations.AddField(
238             model_name='image',
239             name='head',
240             field=models.ForeignKey(default=None, editable=False, to='catalogue.ImageChange', blank=True, help_text="This document's current head.", null=True, verbose_name='head', on_delete=models.CASCADE),
241             preserve_default=True,
242         ),
243         migrations.AddField(
244             model_name='image',
245             name='project',
246             field=models.ForeignKey(blank=True, to='catalogue.Project', null=True, on_delete=models.CASCADE),
247             preserve_default=True,
248         ),
249         migrations.AddField(
250             model_name='image',
251             name='stage',
252             field=models.ForeignKey(verbose_name='stage', blank=True, to='catalogue.ImageTag', null=True, on_delete=models.CASCADE),
253             preserve_default=True,
254         ),
255         migrations.AddField(
256             model_name='image',
257             name='user',
258             field=models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, help_text='Work assignment.', null=True, verbose_name='user', on_delete=models.CASCADE),
259             preserve_default=True,
260         ),
261         migrations.AddField(
262             model_name='chunkchange',
263             name='tags',
264             field=models.ManyToManyField(related_name='change_set', verbose_name='tags', to='catalogue.ChunkTag'),
265             preserve_default=True,
266         ),
267         migrations.AddField(
268             model_name='chunkchange',
269             name='tree',
270             field=models.ForeignKey(related_name='change_set', verbose_name='document', to='catalogue.Chunk', on_delete=models.CASCADE),
271             preserve_default=True,
272         ),
273         migrations.AlterUniqueTogether(
274             name='chunkchange',
275             unique_together=set([('tree', 'revision')]),
276         ),
277         migrations.AddField(
278             model_name='chunk',
279             name='head',
280             field=models.ForeignKey(default=None, editable=False, to='catalogue.ChunkChange', blank=True, help_text="This document's current head.", null=True, verbose_name='head', on_delete=models.CASCADE),
281             preserve_default=True,
282         ),
283         migrations.AddField(
284             model_name='chunk',
285             name='stage',
286             field=models.ForeignKey(verbose_name='stage', blank=True, to='catalogue.ChunkTag', null=True, on_delete=models.CASCADE),
287             preserve_default=True,
288         ),
289         migrations.AddField(
290             model_name='chunk',
291             name='user',
292             field=models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, help_text='Work assignment.', null=True, verbose_name='user', on_delete=models.CASCADE),
293             preserve_default=True,
294         ),
295         migrations.AlterUniqueTogether(
296             name='chunk',
297             unique_together=set([('book', 'number'), ('book', 'slug')]),
298         ),
299         migrations.AddField(
300             model_name='book',
301             name='dc_cover_image',
302             field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, blank=True, editable=False, to='cover.Image', null=True),
303             preserve_default=True,
304         ),
305         migrations.AddField(
306             model_name='book',
307             name='parent',
308             field=models.ForeignKey(related_name='children', blank=True, editable=False, to='catalogue.Book', null=True, verbose_name='parent', on_delete=models.CASCADE),
309             preserve_default=True,
310         ),
311         migrations.AddField(
312             model_name='book',
313             name='project',
314             field=models.ForeignKey(blank=True, to='catalogue.Project', null=True, on_delete=models.CASCADE),
315             preserve_default=True,
316         ),
317         migrations.CreateModel(
318             name='User',
319             fields=[
320             ],
321             options={
322                 'proxy': True,
323             },
324             bases=('auth.user',),
325         ),
326     ]