1
0
mirror of https://github.com/Damillora/Altessimo synced 2024-12-22 09:53:45 +00:00

Complete backend

This commit is contained in:
Damillora 2020-12-16 15:51:48 +07:00
parent d91e794eec
commit 2af9f5e639
12 changed files with 230 additions and 8 deletions

View File

@ -0,0 +1,17 @@
# Generated by Django 3.1.4 on 2020-12-16 08:51
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('artists', '0004_auto_20201216_0724'),
]
operations = [
migrations.AlterModelOptions(
name='artist',
options={'ordering': ['romanized_name', 'name']},
),
]

View File

@ -13,7 +13,7 @@ class ArtistManager(models.Manager):
def comma_to_qs(self, artists_str):
final_ids = []
for artist in artists_str.split(','):
obj, created = self.create_or_new(artist)
obj, created = self.create_or_new(strip(artist))
final_ids.append(obj.id)
qs = self.get_queryset().filter(id__in=final_ids).distinct()
return qs
@ -27,6 +27,9 @@ class Artist(models.Model):
about_music = models.TextField(blank=True)
objects = ArtistManager()
class Meta:
ordering = [ 'romanized_name','name' ]
def __str__(self):
return self.romanized_name

View File

@ -0,0 +1,17 @@
# Generated by Django 3.1.4 on 2020-12-16 08:51
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('categories', '0004_auto_20201216_0724'),
]
operations = [
migrations.AlterModelOptions(
name='category',
options={'ordering': ['name'], 'verbose_name_plural': 'Categories'},
),
]

View File

@ -24,6 +24,7 @@ class Category(models.Model):
objects = CategoryManager()
class Meta:
ordering = [ 'name' ]
verbose_name_plural = "Categories"
def __str__(self):

View File

@ -0,0 +1,37 @@
# Generated by Django 3.1.4 on 2020-12-16 07:30
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('songs', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='outsidesong',
name='romanized_title',
),
migrations.AddField(
model_name='outsidesong',
name='artist',
field=models.CharField(blank=True, max_length=255),
),
migrations.AlterField(
model_name='outsidesong',
name='origin',
field=models.CharField(blank=True, max_length=255),
),
migrations.AlterField(
model_name='outsidesong',
name='title',
field=models.CharField(blank=True, max_length=255),
),
migrations.AlterField(
model_name='outsidesong',
name='url',
field=models.URLField(blank=True, max_length=255),
),
]

View File

@ -0,0 +1,27 @@
# Generated by Django 3.1.4 on 2020-12-16 07:36
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('songs', '0002_auto_20201216_0730'),
]
operations = [
migrations.CreateModel(
name='Branch',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(blank=True, max_length=255)),
('acronym', models.CharField(blank=True, max_length=20)),
],
),
migrations.AddField(
model_name='song',
name='branch',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='songs.branch'),
),
]

View File

@ -0,0 +1,17 @@
# Generated by Django 3.1.4 on 2020-12-16 08:00
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('songs', '0003_auto_20201216_0736'),
]
operations = [
migrations.RemoveField(
model_name='song',
name='lyricist',
),
]

View File

@ -0,0 +1,20 @@
# Generated by Django 3.1.4 on 2020-12-16 08:38
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('songs', '0004_remove_song_lyricist'),
]
operations = [
migrations.AlterField(
model_name='song',
name='branch',
field=models.ForeignKey(blank=True, default=1, on_delete=django.db.models.deletion.PROTECT, to='songs.branch'),
preserve_default=False,
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 3.1.4 on 2020-12-16 08:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('songs', '0005_auto_20201216_0838'),
]
operations = [
migrations.AlterField(
model_name='song',
name='romanized_title',
field=models.CharField(blank=True, max_length=255),
),
migrations.AlterField(
model_name='song',
name='title',
field=models.CharField(blank=True, max_length=255),
),
]

View File

@ -0,0 +1,19 @@
# Generated by Django 3.1.4 on 2020-12-16 08:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('artists', '0004_auto_20201216_0724'),
('songs', '0006_auto_20201216_0840'),
]
operations = [
migrations.AddField(
model_name='song',
name='lyricist',
field=models.ManyToManyField(blank=True, related_name='written_songs', to='artists.Artist'),
),
]

View File

@ -0,0 +1,21 @@
# Generated by Django 3.1.4 on 2020-12-16 08:51
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('songs', '0007_song_lyricist'),
]
operations = [
migrations.AlterModelOptions(
name='outsidesong',
options={'ordering': ['composer', 'title']},
),
migrations.AlterModelOptions(
name='song',
options={'ordering': ['romanized_title', 'title']},
),
]

View File

@ -1,17 +1,37 @@
from django.db import models
class Branch(models.Model):
name = models.CharField(max_length=255,blank=True)
acronym = models.CharField(max_length=20,blank=True)
def __str__(self):
return self.name+" ["+self.acronym+"]"
# Create your models here.
class Song(models.Model):
title = models.CharField(max_length=255)
romanized_title = models.CharField(max_length=255)
branch = models.ForeignKey("Branch", blank=True, on_delete=models.PROTECT)
title = models.CharField(max_length=255,blank=True)
romanized_title = models.CharField(max_length=255,blank=True)
lyricist = models.ManyToManyField("artists.Artist", blank=True, related_name="written_songs")
composer = models.ManyToManyField("artists.Artist", blank=True, related_name="composed_songs")
arranger = models.ManyToManyField("artists.Artist", blank=True, related_name="arranged_songs")
impression = models.TextField(blank=True)
class Meta:
ordering = [ 'romanized_title','title' ]
def __str__(self):
return "["+self.branch.acronym+"] "+self.title
class OutsideSong(models.Model):
title = models.CharField(max_length=255)
romanized_title = models.CharField(max_length=255)
origin = models.CharField(max_length=255)
url = models.URLField(max_length=255)
title = models.CharField(max_length=255,blank=True)
artist = models.CharField(max_length=255,blank=True)
origin = models.CharField(max_length=255,blank=True)
url = models.URLField(max_length=255,blank=True)
composer = models.ForeignKey("artists.Artist", blank=True, on_delete=models.CASCADE)
class Meta:
ordering = [ 'composer','title' ]
def __str__(self):
return "["+self.composer.romanized_name+"] "+self.title