Got library sort of working

This commit is contained in:
Tris
2021-09-04 10:29:22 +10:00
parent 7aedc6bd07
commit 598ee5ad7e
37 changed files with 994 additions and 209 deletions
+39 -10
View File
@@ -1,9 +1,10 @@
# Generated by Django 3.1.1 on 2021-03-11 07:07
# Generated by Django 3.1.1 on 2021-04-28 03:53
import byostorage.cached
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import library.models
import byostorage.cached
class Migration(migrations.Migration):
@@ -11,14 +12,29 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
('interface', '0022_auto_20210303_2043'),
('interface', '0027_auto_20210322_1154'),
('byostorage', '0003_auto_20210323_1047'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Collection',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('location', models.CharField(help_text='Physical location', max_length=100)),
('notes', models.TextField(blank=True)),
('administrators', models.ManyToManyField(help_text='Administrators for this collection', related_name='collections', to=settings.AUTH_USER_MODEL)),
('ensembles', models.ManyToManyField(related_name='collections', to='interface.Ensemble')),
('storage', models.ForeignKey(blank=True, help_text='Storage for documents', null=True, on_delete=django.db.models.deletion.CASCADE, to='byostorage.userstorage')),
],
),
migrations.CreateModel(
name='Document',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('doctype', models.PositiveSmallIntegerField(choices=[(1, 'PDF'), (2, 'Audio'), (3, 'Video'), (4, 'Source')], default=1)),
('upload', models.FileField(storage=byostorage.cached.CachedStorage(), upload_to=library.models.doc_upload_filename)),
],
),
@@ -48,15 +64,19 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('slug', models.SlugField(editable=False, max_length=100)),
('name', models.CharField(max_length=255)),
('running_time', models.IntegerField(blank=True, null=True)),
('version', models.CharField(blank=True, help_text='Version or edition details', max_length=100)),
('composer', models.CharField(blank=True, help_text='Use Composer / Arranger format', max_length=255)),
('code', models.CharField(blank=True, help_text='Collection specific code or number', max_length=100)),
('licence', models.PositiveSmallIntegerField(choices=[(2, 'Public Domain'), (4, 'Copyright Expired'), (6, 'Copyrighted'), (10, 'Internal use only')], default=6, help_text='Copyright status')),
('max_loans', models.BooleanField(default=1, help_text='How many projects can this work be attached to')),
('running_time', models.IntegerField(blank=True, help_text='Running time in seconds', null=True)),
('notes', models.TextField(blank=True)),
('ensemble', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='works', to='interface.ensemble')),
('tag_list', models.CharField(blank=True, help_text='Multiple tags for the work', max_length=255)),
('collection', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='works', to='library.collection')),
('orchestration', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='works', to='library.orchestration')),
('projects', models.ManyToManyField(related_name='works', through='library.Item', to='interface.Project')),
('parent', models.ForeignKey(blank=True, help_text='Arrangement of another work or part of an anthology', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='related_works', to='library.work')),
('projects', models.ManyToManyField(help_text='Current usage', related_name='works', through='library.Item', to='interface.Project')),
],
options={
'unique_together': {('ensemble', 'slug')},
},
),
migrations.CreateModel(
name='Part',
@@ -75,7 +95,16 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='item',
name='work',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='library.work'),
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='project_items', to='library.work'),
),
migrations.CreateModel(
name='EnsembleAccess',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('access_type', models.PositiveSmallIntegerField(choices=[(1, 'Unlimited'), (2, 'Approval required')], default=2)),
('collection', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='library.collection')),
('ensemble', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='interface.ensemble')),
],
),
migrations.AddField(
model_name='document',
@@ -0,0 +1,34 @@
# Generated by Django 3.1.1 on 2021-05-04 08:30
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('library', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='item',
name='approved_by',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='auth.user'),
preserve_default=False,
),
migrations.AddField(
model_name='item',
name='checkin',
field=models.DateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='item',
name='checkout',
field=models.DateTimeField(default=django.utils.timezone.now),
preserve_default=False,
),
]
@@ -0,0 +1,24 @@
# Generated by Django 3.1.1 on 2021-05-04 08:45
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('library', '0002_auto_20210504_1830'),
]
operations = [
migrations.AlterField(
model_name='work',
name='max_loans',
field=models.IntegerField(default=1, help_text='How many projects can this work be attached to'),
),
migrations.AlterField(
model_name='work',
name='orchestration',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='works', to='library.orchestration'),
),
]
-27
View File
@@ -1,27 +0,0 @@
# Generated by Django 3.1.1 on 2021-03-11 06:26
from django.db import migrations
ORCHESTRATIONS = {
'SATB': ('S', 'A', 'T', 'B'),
'String Quartet': ('Vln1', 'Vln2', 'Vla', 'Vc'),
'Chamber Orchestra': ('Vln1', 'Vln2', 'Vla', 'Vc', 'Cb',
'Fl1', 'Fl2', 'Cl1', 'Cl2', 'Ob1', 'Ob2', 'Hn1', 'Hn2',
'Tpt1', 'Tpt2', 'Tbn1', 'Tbn2', 'Tuba',
'Timp', 'Drum', 'Perc'),
}
def add_orchestrations(apps, schema_editor):
q = apps.get_model('library', 'Orchestration').objects
for name, instruments in ORCHESTRATIONS.items():
q.create(name=name, instruments=", ".join(instruments))
class Migration(migrations.Migration):
dependencies = [
('library', '0001_initial'),
]
operations = [
migrations.RunPython(add_orchestrations, lambda apps, schema_editor: None),
]
@@ -0,0 +1,44 @@
# Generated by Django 3.1.1 on 2021-05-04 23:27
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('library', '0003_auto_20210504_1845'),
]
operations = [
migrations.RenameField(
model_name='item',
old_name='checkin',
new_name='due',
),
migrations.AddField(
model_name='item',
name='returned',
field=models.DateTimeField(blank=True, null=True),
),
migrations.AlterField(
model_name='collection',
name='location',
field=models.CharField(help_text='Physical location (institution, town...)', max_length=100),
),
migrations.AlterField(
model_name='collection',
name='name',
field=models.CharField(help_text='Often just the name of the owning ensemble', max_length=255),
),
migrations.AlterField(
model_name='collection',
name='notes',
field=models.TextField(blank=True, help_text='Publicly visible notes about collection and loans policy'),
),
migrations.AlterField(
model_name='work',
name='collection',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='works', to='library.collection'),
),
]
@@ -1,4 +1,4 @@
# Generated by Django 3.1.1 on 2021-03-22 23:47
# Generated by Django 3.1.1 on 2021-05-06 02:41
from django.db import migrations, models
@@ -6,13 +6,13 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('library', '0003_orchestrations'),
('library', '0004_auto_20210505_0927'),
]
operations = [
migrations.AddField(
model_name='work',
name='composer',
field=models.CharField(blank=True, max_length=255),
name='parts',
field=models.JSONField(blank=True, null=True),
),
]
@@ -0,0 +1,48 @@
# Generated by Django 3.2.7 on 2021-09-02 03:55
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('interface', '0028_ensemble_details'),
('library', '0005_work_parts'),
]
operations = [
migrations.AlterModelOptions(
name='ensembleaccess',
options={'verbose_name_plural': 'Ensemble access'},
),
migrations.RemoveField(
model_name='collection',
name='ensembles',
),
migrations.AddField(
model_name='document',
name='version',
field=models.CharField(blank=True, max_length=30),
),
migrations.AddField(
model_name='item',
name='version',
field=models.CharField(blank=True, help_text='Limited to specific version tag', max_length=30),
),
migrations.AlterField(
model_name='collection',
name='name',
field=models.CharField(help_text='Name of the collection', max_length=255),
),
migrations.AlterField(
model_name='ensembleaccess',
name='collection',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='allowed_ensembles', to='library.collection'),
),
migrations.AlterField(
model_name='ensembleaccess',
name='ensemble',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='allowed_collections', to='interface.ensemble'),
),
]
@@ -0,0 +1,33 @@
# Generated by Django 3.2.7 on 2021-09-02 04:07
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('library', '0006_auto_20210902_1355'),
]
operations = [
migrations.RemoveField(
model_name='work',
name='orchestration',
),
migrations.RemoveField(
model_name='work',
name='version',
),
migrations.AddField(
model_name='document',
name='created',
field=models.DateTimeField(auto_created=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='work',
name='edition',
field=models.CharField(blank=True, help_text='Edition details', max_length=100),
),
]
@@ -0,0 +1,18 @@
# Generated by Django 3.2.7 on 2021-09-02 04:11
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('library', '0007_auto_20210902_1407'),
]
operations = [
migrations.AddField(
model_name='work',
name='orchestration',
field=models.CharField(blank=True, help_text='IMDB format instrumentation', max_length=255),
),
]