mirror of
https://github.com/Damillora/Altessimo
synced 2024-10-31 21:17:32 +00:00
Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
6474253b09 | |||
01d2c14e27 | |||
4119eb63de | |||
caf7886567 | |||
4c618458c3 | |||
f02f7b826a | |||
b48045956c | |||
661d57ab56 | |||
c086f10b3c | |||
c75f64766a | |||
ed4c2065b6 | |||
0ed9d7b1d5 | |||
986d0ee869 | |||
2cc9a7bd31 | |||
c184dc3534 | |||
56a3460160 | |||
5205dab431 | |||
6b9b0d1458 | |||
6577d008b9 | |||
b1f9605fab | |||
ee8f443e5d | |||
e4958148b1 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -128,5 +128,4 @@ dmypy.json
|
|||||||
# Pyre type checker
|
# Pyre type checker
|
||||||
.pyre/
|
.pyre/
|
||||||
|
|
||||||
altessimo/production.py
|
/static/
|
||||||
static/
|
|
||||||
|
18
Dockerfile
Normal file
18
Dockerfile
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
FROM python:alpine
|
||||||
|
|
||||||
|
ADD requirements.txt /app/requirements.txt
|
||||||
|
RUN apk update \
|
||||||
|
&& apk add --virtual build-deps gcc python3-dev musl-dev \
|
||||||
|
&& apk add --no-cache mariadb-dev jpeg-dev zlib-dev libpng-dev \
|
||||||
|
&& pip install --no-cache-dir -r /app/requirements.txt \
|
||||||
|
&& apk del build-deps
|
||||||
|
ADD . /app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN python manage.py collectstatic
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
ENV DJANGO_SETTINGS_MODULE=altessimo.production
|
||||||
|
|
||||||
|
CMD ["gunicorn", "--bind", ":8000", "altessimo.wsgi"]
|
16
altessimo/production.py
Normal file
16
altessimo/production.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from altessimo.settings import *
|
||||||
|
import os
|
||||||
|
|
||||||
|
DEBUG = False
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
|
'NAME': os.getenv('ALTESSIMO_DB_NAME'),
|
||||||
|
'USER': os.getenv('ALTESSIMO_DB_USER'),
|
||||||
|
'PASSWORD': os.getenv('ALTESSIMO_DB_PASS'),
|
||||||
|
'HOST': os.getenv('ALTESSIMO_DB_HOST'),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = [ os.getenv('ALTESSIMO_WEB_URL') ]
|
@ -39,12 +39,14 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'categories',
|
'categories',
|
||||||
'artists',
|
'artists',
|
||||||
|
'idols',
|
||||||
'songs',
|
'songs',
|
||||||
'home',
|
'home',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
@ -21,5 +21,6 @@ urlpatterns = [
|
|||||||
path('taxonomy/', include('categories.urls')),
|
path('taxonomy/', include('categories.urls')),
|
||||||
path('artists/', include('artists.urls')),
|
path('artists/', include('artists.urls')),
|
||||||
path('songs/', include('songs.urls')),
|
path('songs/', include('songs.urls')),
|
||||||
|
path('idols/', include('idols.urls')),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
]
|
]
|
||||||
|
@ -1,8 +1,54 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from . import models
|
from django import forms
|
||||||
|
|
||||||
|
from .models import Artist
|
||||||
|
from categories.models import Category
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
class ArtistForm(forms.ModelForm):
|
||||||
|
categories_str = forms.CharField(label='Category', required=False)
|
||||||
|
aliases_str = forms.CharField(label='Aliases', required=False)
|
||||||
|
class Meta:
|
||||||
|
model = Artist
|
||||||
|
fields = [
|
||||||
|
'name',
|
||||||
|
'romanized_name',
|
||||||
|
'slug',
|
||||||
|
'categories_str',
|
||||||
|
'aliases_str',
|
||||||
|
'about_artist',
|
||||||
|
'about_music',
|
||||||
|
]
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['about_artist'].widget.attrs['class'] = 'tm-textfield'
|
||||||
|
self.fields['about_music'].widget.attrs['class'] = 'tm-textfield'
|
||||||
|
instance = kwargs.get("instance")
|
||||||
|
if instance:
|
||||||
|
self.fields['categories_str'].initial = ", ".join(x.name for x in instance.category.all() )
|
||||||
|
self.fields['aliases_str'].initial = ", ".join(x.romanized_name for x in instance.aliases.all() )
|
||||||
|
|
||||||
class ArtistAdmin(admin.ModelAdmin):
|
class ArtistAdmin(admin.ModelAdmin):
|
||||||
|
form = ArtistForm
|
||||||
search_fields = ['romanized_name','name']
|
search_fields = ['romanized_name','name']
|
||||||
|
|
||||||
admin.site.register(models.Artist, ArtistAdmin)
|
class Media:
|
||||||
|
js = (
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.6.2/tinymce.min.js',
|
||||||
|
'tinymce-init.js'
|
||||||
|
)
|
||||||
|
def save_model(self, request, obj, form, change):
|
||||||
|
categories_str = form.cleaned_data.get('categories_str')
|
||||||
|
categories = Category.objects.comma_to_qs(categories_str)
|
||||||
|
aliases_str = form.cleaned_data.get('aliases_str')
|
||||||
|
aliases = Artist.objects.comma_to_qs(aliases_str)
|
||||||
|
if not obj.id:
|
||||||
|
obj.save()
|
||||||
|
obj.category.clear()
|
||||||
|
obj.category.add(*categories)
|
||||||
|
obj.aliases.clear()
|
||||||
|
obj.aliases.add(*aliases)
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
admin.site.register(Artist, ArtistAdmin)
|
||||||
|
@ -2,4 +2,5 @@ from django.apps import AppConfig
|
|||||||
|
|
||||||
|
|
||||||
class ArtistsConfig(AppConfig):
|
class ArtistsConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
name = 'artists'
|
name = 'artists'
|
||||||
|
31
artists/migrations/0005_idol_voiceactor.py
Normal file
31
artists/migrations/0005_idol_voiceactor.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Generated by Django 3.2.5 on 2021-07-09 17:06
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('artists', '0004_auto_20201216_1633'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='VoiceActor',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(blank=True, max_length=255)),
|
||||||
|
('romanized_name', models.CharField(max_length=255)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Idol',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(blank=True, max_length=255)),
|
||||||
|
('romanized_name', models.CharField(max_length=255)),
|
||||||
|
('voice_actor', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='artists.voiceactor')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
20
artists/migrations/0006_auto_20210709_1720.py
Normal file
20
artists/migrations/0006_auto_20210709_1720.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 3.2.5 on 2021-07-09 17:20
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('songs', '0006_alter_song_idols'),
|
||||||
|
('artists', '0005_idol_voiceactor'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='Idol',
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='VoiceActor',
|
||||||
|
),
|
||||||
|
]
|
18
artists/migrations/0007_alter_artist_id.py
Normal file
18
artists/migrations/0007_alter_artist_id.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.5 on 2021-07-10 07:00
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('artists', '0006_auto_20210709_1720'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='artist',
|
||||||
|
name='id',
|
||||||
|
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
|
||||||
|
),
|
||||||
|
]
|
18
artists/migrations/0008_alter_artist_aliases.py
Normal file
18
artists/migrations/0008_alter_artist_aliases.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.0.5 on 2022-06-24 14:07
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('artists', '0007_alter_artist_id'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='artist',
|
||||||
|
name='aliases',
|
||||||
|
field=models.ManyToManyField(blank=True, to='artists.artist'),
|
||||||
|
),
|
||||||
|
]
|
@ -4,20 +4,15 @@ from django.utils.text import slugify
|
|||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
class ArtistManager(models.Manager):
|
class ArtistManager(models.Manager):
|
||||||
def create_or_new(self, romanized_name):
|
|
||||||
romanized_name = romanized_name.strip()
|
|
||||||
qs = self.get_queryset().filter(romanized_name__iexact=romanized_name)
|
|
||||||
if qs.exists():
|
|
||||||
return qs.first(), False
|
|
||||||
return Artist.objects.create(romanized_name=romanized_name), True
|
|
||||||
|
|
||||||
def comma_to_qs(self, artists_str):
|
def comma_to_qs(self, artists_str):
|
||||||
final_ids = []
|
final_ids = []
|
||||||
|
if artists_str:
|
||||||
for artist in artists_str.split(','):
|
for artist in artists_str.split(','):
|
||||||
obj, created = self.create_or_new(artist.strip())
|
obj, created = self.get_or_create(romanized_name=artist.strip())
|
||||||
final_ids.append(obj.id)
|
final_ids.append(obj.id)
|
||||||
qs = self.get_queryset().filter(id__in=final_ids).distinct()
|
qs = self.get_queryset().filter(id__in=final_ids).distinct()
|
||||||
return qs
|
return qs
|
||||||
|
return self.none()
|
||||||
|
|
||||||
class Artist(models.Model):
|
class Artist(models.Model):
|
||||||
name = models.CharField(max_length=255,blank=True)
|
name = models.CharField(max_length=255,blank=True)
|
||||||
@ -39,3 +34,4 @@ class Artist(models.Model):
|
|||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
self.slug = slugify(self.romanized_name)
|
self.slug = slugify(self.romanized_name)
|
||||||
super().save(*args,**kwargs)
|
super().save(*args,**kwargs)
|
||||||
|
|
||||||
|
@ -4,9 +4,24 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Artists</h1>
|
<h1>Artists</h1>
|
||||||
<ul>
|
<form action="{{ request.path }}" method="GET">
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input type="text" class="form-control" placeholder="Search" aria-label="Search" aria-describedby="search-button" name="q">
|
||||||
|
<button class="btn btn-outline-secondary" type="submit" id="search-button">Search</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<th>Artist</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
{% for artist in artists %}
|
{% for artist in artists %}
|
||||||
<li><a href="/artists/{{ artist.slug }}">{{ artist.romanized_name }}</a></li>
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="/artists/{{ artist.slug }}">{{ artist.romanized_name }}</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</tbody>
|
||||||
|
</table>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -33,7 +33,7 @@
|
|||||||
Alias
|
Alias
|
||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<a href="/artists/{{ alias.id }}">{{ alias.romanized_name }}</a>
|
<a href="/artists/{{ alias.slug }}">{{ alias.romanized_name }}</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@ -50,9 +50,9 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<h2>About Artist</h2>
|
<h2>About Artist</h2>
|
||||||
<p>{{ artist.about_artist }}</p>
|
<div>{{ artist.about_artist|safe }}</div>
|
||||||
<h2>About Music</h2>
|
<h2>About Music</h2>
|
||||||
<p>{{ artist.about_music }}</p>
|
<div>{{ artist.about_music|safe }}</div>
|
||||||
<h2>Credits</h2>
|
<h2>Credits</h2>
|
||||||
{% include 'components/song-table.html' with songs=credit_songs %}
|
{% include 'components/song-table.html' with songs=credit_songs %}
|
||||||
<h2>Sample works outside Idolmaster</h2>
|
<h2>Sample works outside Idolmaster</h2>
|
||||||
|
@ -4,12 +4,30 @@ from django.shortcuts import render
|
|||||||
from .models import Artist
|
from .models import Artist
|
||||||
from songs.models import OutsideSong
|
from songs.models import OutsideSong
|
||||||
|
|
||||||
|
|
||||||
def artist_index(request):
|
def artist_index(request):
|
||||||
artists = Artist.objects.all()
|
artists = Artist.objects.all()
|
||||||
return render(request,'artists/index.html',{'artists':artists})
|
objs = {}
|
||||||
|
if "q" in request.GET:
|
||||||
|
q = request.GET['q']
|
||||||
|
artists = Artist.objects.filter(
|
||||||
|
name__icontains=q) | Artist.objects.filter(romanized_name__icontains=q)
|
||||||
|
objs['q'] = q
|
||||||
|
objs['artists'] = artists
|
||||||
|
return render(request, 'artists/index.html', objs)
|
||||||
|
|
||||||
|
|
||||||
def artist_show(request, slug):
|
def artist_show(request, slug):
|
||||||
artist = Artist.objects.filter(slug=slug)[0]
|
artist = Artist.objects.filter(slug=slug)[0]
|
||||||
credit_songs = (artist.written_songs.all() | artist.composed_songs.all() | artist.arranged_songs.all()).distinct()
|
credit_songs = artist.written_songs.all(
|
||||||
|
) | artist.composed_songs.all() | artist.arranged_songs.all()
|
||||||
|
aliases = artist.aliases.all()
|
||||||
outside_songs = OutsideSong.objects.filter(composer=artist)
|
outside_songs = OutsideSong.objects.filter(composer=artist)
|
||||||
return render(request,'artists/show.html',{'artist': artist,'credit_songs':credit_songs,'outside_songs':outside_songs})
|
for alias in aliases:
|
||||||
|
credit_songs = credit_songs | alias.written_songs.all(
|
||||||
|
) | artist.composed_songs.all() | artist.arranged_songs.all()
|
||||||
|
outside_songs = outside_songs | OutsideSong.objects.filter(
|
||||||
|
composer=alias)
|
||||||
|
credit_songs = credit_songs.distinct()
|
||||||
|
outside_songs = outside_songs.distinct()
|
||||||
|
return render(request, 'artists/show.html', {'artist': artist, 'credit_songs': credit_songs, 'outside_songs': outside_songs})
|
@ -1,13 +1,47 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django import forms
|
||||||
|
|
||||||
from . import models
|
from .models import Branch, Category
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
|
||||||
|
class BranchForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Branch
|
||||||
|
exclude = []
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['description'].widget.attrs['class'] = 'tm-textfield'
|
||||||
|
|
||||||
|
class CategoryForm(forms.ModelForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Category
|
||||||
|
exclude = []
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['description'].widget.attrs['class'] = 'tm-textfield'
|
||||||
|
|
||||||
class BranchAdmin(admin.ModelAdmin):
|
class BranchAdmin(admin.ModelAdmin):
|
||||||
|
form = BranchForm
|
||||||
search_fields = ['name', 'acronym']
|
search_fields = ['name', 'acronym']
|
||||||
|
|
||||||
|
class Media:
|
||||||
|
js = (
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.6.2/tinymce.min.js',
|
||||||
|
'tinymce-init.js'
|
||||||
|
)
|
||||||
|
|
||||||
class CategoryAdmin(admin.ModelAdmin):
|
class CategoryAdmin(admin.ModelAdmin):
|
||||||
|
form = CategoryForm
|
||||||
search_fields = ['name']
|
search_fields = ['name']
|
||||||
|
|
||||||
admin.site.register(models.Branch, BranchAdmin)
|
class Media:
|
||||||
admin.site.register(models.Category,CategoryAdmin)
|
js = (
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.6.2/tinymce.min.js',
|
||||||
|
'tinymce-init.js'
|
||||||
|
)
|
||||||
|
|
||||||
|
admin.site.register(Branch, BranchAdmin)
|
||||||
|
admin.site.register(Category,CategoryAdmin)
|
||||||
|
@ -2,4 +2,5 @@ from django.apps import AppConfig
|
|||||||
|
|
||||||
|
|
||||||
class CategoriesConfig(AppConfig):
|
class CategoriesConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
name = 'categories'
|
name = 'categories'
|
||||||
|
23
categories/migrations/0010_auto_20210710_0700.py
Normal file
23
categories/migrations/0010_auto_20210710_0700.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.2.5 on 2021-07-10 07:00
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('categories', '0009_auto_20201216_1732'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='branch',
|
||||||
|
name='id',
|
||||||
|
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='category',
|
||||||
|
name='id',
|
||||||
|
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
|
||||||
|
),
|
||||||
|
]
|
@ -12,20 +12,15 @@ class Branch(models.Model):
|
|||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
class CategoryManager(models.Manager):
|
class CategoryManager(models.Manager):
|
||||||
def create_or_new(self, name):
|
def comma_to_qs(self, categories_str):
|
||||||
name = name.strip()
|
|
||||||
qs = self.get_queryset().filter(name__iexact=name)
|
|
||||||
if qs.exists():
|
|
||||||
return qs.first(), False
|
|
||||||
return Category.objects.create(name=name), True
|
|
||||||
|
|
||||||
def comma_to_qs(self, categorys_str):
|
|
||||||
final_ids = []
|
final_ids = []
|
||||||
|
if categories_str:
|
||||||
for category in categories_str.split(','):
|
for category in categories_str.split(','):
|
||||||
obj, created = self.create_or_new(category)
|
obj, created = self.get_or_create(name=category.strip())
|
||||||
final_ids.append(obj.id)
|
final_ids.append(obj.id)
|
||||||
qs = self.get_queryset().filter(id__in=final_ids).distinct()
|
qs = self.get_queryset().filter(id__in=final_ids).distinct()
|
||||||
return qs
|
return qs
|
||||||
|
return self.none()
|
||||||
|
|
||||||
class Category(models.Model):
|
class Category(models.Model):
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
|
69
categories/static/branches.css
Normal file
69
categories/static/branches.css
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
.song-row a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.song-row a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.branch-765 {
|
||||||
|
background-color: #ffcdd2;
|
||||||
|
color: #c62828;
|
||||||
|
}
|
||||||
|
.branch-765 a {
|
||||||
|
color: #c62828;
|
||||||
|
}
|
||||||
|
.branch-346 {
|
||||||
|
background-color: #64b5f6;
|
||||||
|
color: #0d47a1;
|
||||||
|
}
|
||||||
|
.branch-346 a {
|
||||||
|
color: #0d47a1;
|
||||||
|
}
|
||||||
|
.branch-765ML {
|
||||||
|
background-color: #f9a825;
|
||||||
|
color: #6d4c41;
|
||||||
|
}
|
||||||
|
.branch-765ML a {
|
||||||
|
color: #6d4c41;
|
||||||
|
}
|
||||||
|
.branch-315 {
|
||||||
|
background-color: #a5d6a7;
|
||||||
|
color: #1b5e20;
|
||||||
|
}
|
||||||
|
.branch-315 a {
|
||||||
|
color: #1b5e20;
|
||||||
|
}
|
||||||
|
.branch-283 {
|
||||||
|
background-color: #bbdefb;
|
||||||
|
color: #1976d2;
|
||||||
|
}
|
||||||
|
.branch-283 a {
|
||||||
|
color: #1976d2;
|
||||||
|
}
|
||||||
|
.branch-876 {
|
||||||
|
background-color: #d1c4e9;
|
||||||
|
color:#512da8;
|
||||||
|
}
|
||||||
|
.branch-876 a {
|
||||||
|
color:#512da8;
|
||||||
|
}
|
||||||
|
.branch-961 {
|
||||||
|
background-color: #f0f4c3;
|
||||||
|
color: #827717;
|
||||||
|
}
|
||||||
|
.branch-961 a {
|
||||||
|
color: #827717;
|
||||||
|
}
|
||||||
|
.branch-5STARS {
|
||||||
|
background-color: #d81b60;
|
||||||
|
color: #fce4ec;
|
||||||
|
}
|
||||||
|
.branch-5STARS a {
|
||||||
|
color: #fce4ec;
|
||||||
|
}
|
||||||
|
.branch-POP {
|
||||||
|
background-color: #1663cd;
|
||||||
|
color: #e8eaf6;
|
||||||
|
}
|
||||||
|
.branch-POP a {
|
||||||
|
color: #e8eaf6;
|
||||||
|
}
|
@ -3,24 +3,18 @@
|
|||||||
{% block title %}Branches{% endblock %}
|
{% block title %}Branches{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Branches</h1>
|
<h1>Branches</h1>
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<th>Acronym</th>
|
|
||||||
<th>Logo</th>
|
|
||||||
<th>Name</th>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for branch in branches %}
|
{% for branch in branches %}
|
||||||
<tr>
|
<div class="row song-row branch-{{ branch.acronym }}">
|
||||||
<td>{{ branch.acronym }}</td>
|
<div class="col col-md-3">
|
||||||
<td>
|
|
||||||
{% if branch.logo %}
|
{% if branch.logo %}
|
||||||
<img src="{{ branch.logo.path }}" width=24>
|
<img src="{{ branch.logo.url }}" class="img-fluid">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</div>
|
||||||
<td><a href="/taxonomy/branches/{{ branch.acronym }}">{{ branch.name }} [{{ branch.acronym }}]</a></td>
|
<div class="col col-md-9">
|
||||||
</tr>
|
<div class="row h-100 align-items-center">
|
||||||
|
<p class="h2"><a href="/taxonomy/branches/{{ branch.acronym }}">{{ branch.name }} [{{ branch.acronym }}]</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -3,7 +3,20 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>[{{ branch.acronym }}] {{ branch.name }}</h1>
|
<h1>[{{ branch.acronym }}] {{ branch.name }}</h1>
|
||||||
<h2>Description</h2>
|
<h2>Description</h2>
|
||||||
<p>{{ branch.description }}</p>
|
<div>{{ branch.description|safe }}</div>
|
||||||
<h2>Songs</h2>
|
<h2>Songs</h2>
|
||||||
{% include 'components/song-table.html' with songs=songs %}
|
{% include 'components/song-table.html' with songs=page_obj %}
|
||||||
|
<nav aria-label="Pages">
|
||||||
|
<ul class="pagination">
|
||||||
|
{% if page_obj.has_previous %}
|
||||||
|
<li class="page-item"><a class="page-link" href="?page=1">First</a></li>
|
||||||
|
<li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}">Previous</a></li>
|
||||||
|
{% endif %}
|
||||||
|
<li class="page-item"><a class="page-link" href="?page={{ page_obj.number }}">{{ page_obj.number }} of {{ page_obj.paginator.num_pages }}</a></li>
|
||||||
|
{% if page_obj.has_next %}
|
||||||
|
<li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}">Next</a></li>
|
||||||
|
<li class="page-item"><a class="page-link" href="?page={{ page_obj.paginator.num_pages }}">Last</a></li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -5,7 +5,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Category: {{ category.name }}</h1>
|
<h1>Category: {{ category.name }}</h1>
|
||||||
<h2>Description</h2>
|
<h2>Description</h2>
|
||||||
<p>{{ category.description }}</p>
|
<div>{{ category.description|safe }}</div>
|
||||||
<h2>Artists</h2>
|
<h2>Artists</h2>
|
||||||
<ul>
|
<ul>
|
||||||
{% for artist in category.artist_set.all %}
|
{% for artist in category.artist_set.all %}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from django.core.paginator import Paginator
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from .models import Branch, Category
|
from .models import Branch, Category
|
||||||
@ -20,4 +21,7 @@ def branch_index(request):
|
|||||||
def branch_show(request, acronym):
|
def branch_show(request, acronym):
|
||||||
branch = Branch.objects.filter(acronym=acronym)[0]
|
branch = Branch.objects.filter(acronym=acronym)[0]
|
||||||
songs = Song.objects.filter(branch=branch)
|
songs = Song.objects.filter(branch=branch)
|
||||||
return render(request,"branches/show.html",{'branch':branch,'songs':songs})
|
paginator = Paginator(songs, 100)
|
||||||
|
page_number = request.GET.get('page',1)
|
||||||
|
page_obj = paginator.get_page(page_number)
|
||||||
|
return render(request,"branches/show.html",{'branch':branch,'page_obj':page_obj})
|
6
home/static/tinymce-init.js
Normal file
6
home/static/tinymce-init.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
tinymce.init({
|
||||||
|
selector: '.tm-textfield', // change this value according to your HTML
|
||||||
|
menubar: false,
|
||||||
|
plugins: 'advlist lists link',
|
||||||
|
toolbar: 'undo redo | styleselect | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | link',
|
||||||
|
});
|
@ -1,15 +1,20 @@
|
|||||||
{% extends 'layouts/base.html' %}
|
{% extends 'layouts/base.html' %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Welcome!</h1>
|
<h1>Welcome!</h1>
|
||||||
<p>This site is a work-in-progress database of Idolmaster songs, composers, arrangers, and lyricists.</p>
|
<p>This site is a work-in-progress database of Idolmaster songs, composers, arrangers, and lyricists.</p>
|
||||||
<p>The primary purpose of this site is to document the people behind the music in Idolmaster, make observations about the music, and showcase other works that might be of interest </p>
|
<p>The primary purpose of this site is to document the people behind the music in Idolmaster, make observations about
|
||||||
<p>This site originated from a spreadsheet I maintained to note the composers' works and their similarities. </p>
|
the music, and showcase other works that might be of interest </p>
|
||||||
<h2>Current to-do</h2>
|
<p>This site originated from a spreadsheet I maintained to note the composers' works and their similarities. </p>
|
||||||
<ul>
|
<h2>Current to-do</h2>
|
||||||
|
<ul>
|
||||||
<li>Complete lyricist credits</li>
|
<li>Complete lyricist credits</li>
|
||||||
<li>Add songs from IDOLM@STER Radio</li>
|
<li>Add songs from IDOLM@STER Radio</li>
|
||||||
<li>Re-add other songs that I might have missed</li>
|
<li>Re-add other songs that I might have missed</li>
|
||||||
<li>Complete showcases of composers</li>
|
<li>Complete showcases of composers</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<h2>Mildly interesting</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="/randomizer">A song randomizer</a></li>
|
||||||
|
</ul>
|
||||||
{% endblock %}
|
{% endblock %}
|
61
home/templates/randomizer.html
Normal file
61
home/templates/randomizer.html
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
{% extends 'layouts/base.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Song Randomizer</h1>
|
||||||
|
<p>A simple song randomizer. </p>
|
||||||
|
<p><strong>WARNING: Very experimental. Implementation is not very smart yet.</strong></p>
|
||||||
|
|
||||||
|
{% if song %}
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<th>Branch</th>
|
||||||
|
<th>Song</th>
|
||||||
|
</tr>
|
||||||
|
<tr class="song-row branch-{{ song.branch.acronym }}">
|
||||||
|
<td class="col-1">
|
||||||
|
<a href="/taxonomy/branches/{{ song.branch.acronym }}">{{ song.branch.acronym }}</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="/songs/{{ song.id }}/{{ song.title }}">{{ song.title }}</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
{% if idols %}
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<th>Branch</th>
|
||||||
|
<th>Idol</th>
|
||||||
|
</tr>
|
||||||
|
{% for idol in idols %}
|
||||||
|
<tr class="song-row branch-{{ idol.branch.acronym }}">
|
||||||
|
<td class="col-1">
|
||||||
|
<a href="/taxonomy/branches/{{ idol.branch.acronym }}">{{ idol.branch.acronym }}</a>
|
||||||
|
</td>
|
||||||
|
<td><a href="/idols/{{ idol.id }}">{{ idol.romanized_name}}</a></td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
{% if song is None and idols is None %}
|
||||||
|
<form action="{{ request.path }}" method="GET">
|
||||||
|
<button class="btn btn-outline-secondary" type="submit">Randomize song</button>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
{% if song and idols is None%}
|
||||||
|
<form action="{{ request.path }}" method="GET">
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input type="hidden" name="song_id" value="{{ song.id }}">
|
||||||
|
<input type="number" class="form-control" placeholder="Number of idols" aria-label="Number of idols"
|
||||||
|
value="{{ num }}" name="num">
|
||||||
|
<button class="btn btn-outline-secondary" type="submit">Randomize idols</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
<form action="{{ request.path }}" method="GET">
|
||||||
|
<div class="input mb-3">
|
||||||
|
<button class="btn btn-outline-secondary" type="submit">Randomize song again</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -4,4 +4,5 @@ from . import views
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('',views.index),
|
path('',views.index),
|
||||||
|
path('randomizer',views.randomizer),
|
||||||
]
|
]
|
||||||
|
@ -1,5 +1,27 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
import random
|
||||||
|
from songs.models import Song
|
||||||
|
from idols.models import Idol
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
return render(request,"index.html")
|
return render(request, "index.html")
|
||||||
|
|
||||||
|
|
||||||
|
def randomizer(request):
|
||||||
|
obj = {}
|
||||||
|
if "song_id" in request.GET:
|
||||||
|
obj['song'] = Song.objects.get(pk=request.GET['song_id'])
|
||||||
|
else:
|
||||||
|
song_ids = list(Song.objects.values_list('pk', flat=True))
|
||||||
|
song_id = random.choice(song_ids)
|
||||||
|
obj['song'] = Song.objects.get(pk=song_id)
|
||||||
|
if "num" in request.GET:
|
||||||
|
obj['num'] = request.GET['num']
|
||||||
|
idol_ids = list(Idol.objects.values_list('pk', flat=True))
|
||||||
|
idol_selected_ids = random.sample(idol_ids, int(request.GET['num']))
|
||||||
|
obj['idols'] = Idol.objects.filter(pk__in=idol_selected_ids)
|
||||||
|
return render(request, "randomizer.html", obj)
|
||||||
|
0
idols/__init__.py
Normal file
0
idols/__init__.py
Normal file
6
idols/admin.py
Normal file
6
idols/admin.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from idols.models import Idol
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
|
|
||||||
|
admin.site.register(Idol)
|
6
idols/apps.py
Normal file
6
idols/apps.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class IdolsConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'idols'
|
32
idols/migrations/0001_initial.py
Normal file
32
idols/migrations/0001_initial.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# Generated by Django 3.2.5 on 2021-07-09 17:20
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='VoiceActor',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(blank=True, max_length=255)),
|
||||||
|
('romanized_name', models.CharField(max_length=255)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Idol',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(blank=True, max_length=255)),
|
||||||
|
('romanized_name', models.CharField(max_length=255)),
|
||||||
|
('voice_actor', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='idols.voiceactor')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
27
idols/migrations/0002_auto_20210709_1733.py
Normal file
27
idols/migrations/0002_auto_20210709_1733.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# Generated by Django 3.2.5 on 2021-07-09 17:33
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('idols', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='idol',
|
||||||
|
name='voice_actor',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='idol',
|
||||||
|
name='romanized_voice_actor_name',
|
||||||
|
field=models.CharField(blank=True, max_length=255),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='idol',
|
||||||
|
name='voice_actor_name',
|
||||||
|
field=models.CharField(blank=True, max_length=255),
|
||||||
|
),
|
||||||
|
]
|
24
idols/migrations/0003_auto_20210709_1803.py
Normal file
24
idols/migrations/0003_auto_20210709_1803.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Generated by Django 3.2.5 on 2021-07-09 18:03
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('categories', '0009_auto_20201216_1732'),
|
||||||
|
('idols', '0002_auto_20210709_1733'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='VoiceActor',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='idol',
|
||||||
|
name='branch',
|
||||||
|
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.PROTECT, to='categories.branch'),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
17
idols/migrations/0004_alter_idol_options.py
Normal file
17
idols/migrations/0004_alter_idol_options.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 3.2.5 on 2021-07-10 07:00
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('idols', '0003_auto_20210709_1803'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='idol',
|
||||||
|
options={'ordering': ['romanized_name', 'name']},
|
||||||
|
),
|
||||||
|
]
|
0
idols/migrations/__init__.py
Normal file
0
idols/migrations/__init__.py
Normal file
33
idols/models.py
Normal file
33
idols/models.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
|
||||||
|
|
||||||
|
class IdolManager(models.Manager):
|
||||||
|
def comma_to_qs(self, idols_str):
|
||||||
|
final_ids = []
|
||||||
|
if idols_str:
|
||||||
|
for idol in idols_str.split(','):
|
||||||
|
obj, created = self.get_or_create(romanized_name=idol.strip())
|
||||||
|
final_ids.append(obj.id)
|
||||||
|
qs = self.get_queryset().filter(id__in=final_ids).distinct()
|
||||||
|
return qs
|
||||||
|
return self.none()
|
||||||
|
|
||||||
|
|
||||||
|
class Idol(models.Model):
|
||||||
|
branch = models.ForeignKey("categories.Branch", on_delete=models.PROTECT)
|
||||||
|
name = models.CharField(max_length=255, blank=True)
|
||||||
|
romanized_name = models.CharField(max_length=255)
|
||||||
|
voice_actor_name = models.CharField(max_length=255, blank=True)
|
||||||
|
romanized_voice_actor_name = models.CharField(max_length=255, blank=True)
|
||||||
|
|
||||||
|
objects = IdolManager()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = [ 'romanized_name','name' ]
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.romanized_name+" "+"["+self.branch.acronym+"] "+" (CV: "+self.romanized_voice_actor_name+")"
|
27
idols/templates/idols/index.html
Normal file
27
idols/templates/idols/index.html
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{% extends 'layouts/base.html' %}
|
||||||
|
|
||||||
|
{% block title %} Idols {% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Idols</h1>
|
||||||
|
<form action="{{ request.path }}" method="GET">
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input type="text" class="form-control" placeholder="Search" aria-label="Search" aria-describedby="search-button" name="q">
|
||||||
|
<button class="btn btn-outline-secondary" type="submit" id="search-button">Search</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<th>Idol</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for idol in idols %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="/idols/{{ idol.slug }}">{{ idol.romanized_name }}</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
52
idols/templates/idols/show.html
Normal file
52
idols/templates/idols/show.html
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
{% extends 'layouts/base.html' %}
|
||||||
|
|
||||||
|
{% block title %} Idol: {{ idol.romanized_name }} {% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Idol: {{ idol.romanized_name }}</h1>
|
||||||
|
<h2>Metadata</h2>
|
||||||
|
<table class="table">
|
||||||
|
<tbody>
|
||||||
|
{% if idol.name %}
|
||||||
|
<tr>
|
||||||
|
<th scope="row">
|
||||||
|
Name
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
{{ idol.name }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% if idol.romanized_name %}
|
||||||
|
<tr>
|
||||||
|
<th scope="row">
|
||||||
|
Romanized Name
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
{{ idol.romanized_name }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% if idol.voice_actor_name %}
|
||||||
|
<tr>
|
||||||
|
<th scope="row">
|
||||||
|
Voice Actor Name
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
{{ idol.voice_actor_name }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% if idol.romanized_voice_actor_name %}
|
||||||
|
<tr>
|
||||||
|
<th scope="row">
|
||||||
|
Romanized Voice Actor Name
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
{{ idol.romanized_voice_actor_name }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
3
idols/tests.py
Normal file
3
idols/tests.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
8
idols/urls.py
Normal file
8
idols/urls.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('',views.idol_index),
|
||||||
|
path('<int:id>',views.idol_show)
|
||||||
|
]
|
19
idols/views.py
Normal file
19
idols/views.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from idols.models import Idol
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
def idol_index(request):
|
||||||
|
idols = Idol.objects.all()
|
||||||
|
objs = {}
|
||||||
|
if "q" in request.GET:
|
||||||
|
q = request.GET['q']
|
||||||
|
idols = Idol.objects.filter(name__icontains=q) | Idol.objects.filter(
|
||||||
|
romanized_name__icontains=q)
|
||||||
|
objs['q'] = q
|
||||||
|
objs['idols'] = idols
|
||||||
|
return render(request, 'idols/index.html', objs)
|
||||||
|
|
||||||
|
|
||||||
|
def idol_show(request, id):
|
||||||
|
idol = Idol.objects.filter(id=id)[0]
|
||||||
|
return render(request, 'idols/show.html', {'idol': idol})
|
5
requirements.txt
Normal file
5
requirements.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Django>=4.0,<5.0
|
||||||
|
mysqlclient
|
||||||
|
gunicorn
|
||||||
|
whitenoise
|
||||||
|
Pillow
|
2
robots.txt
Normal file
2
robots.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
User-Agent: *
|
||||||
|
Disallow: /
|
@ -1,13 +1,80 @@
|
|||||||
|
from django import forms
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from . import models
|
from .models import Song, OutsideSong
|
||||||
|
from artists.models import Artist
|
||||||
|
from idols.models import Idol
|
||||||
|
|
||||||
|
|
||||||
|
class SongForm(forms.ModelForm):
|
||||||
|
lyricist_str = forms.CharField(label='Lyricists', required=False)
|
||||||
|
composer_str = forms.CharField(label='Composers', required=False)
|
||||||
|
arranger_str = forms.CharField(label='Arrangers', required=False)
|
||||||
|
idols_str = forms.CharField(label='Idols', required=False)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Song
|
||||||
|
fields = [
|
||||||
|
'branch',
|
||||||
|
'title',
|
||||||
|
'romanized_title',
|
||||||
|
'lyricist_str',
|
||||||
|
'composer_str',
|
||||||
|
'arranger_str',
|
||||||
|
'idols_str',
|
||||||
|
'impression',
|
||||||
|
]
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['impression'].widget.attrs['class'] = 'tm-textfield'
|
||||||
|
instance = kwargs.get("instance")
|
||||||
|
if instance:
|
||||||
|
self.fields['lyricist_str'].initial = ', '.join(
|
||||||
|
x.romanized_name for x in instance.lyricist.all())
|
||||||
|
self.fields['composer_str'].initial = ', '.join(
|
||||||
|
x.romanized_name for x in instance.composer.all())
|
||||||
|
self.fields['arranger_str'].initial = ', '.join(
|
||||||
|
x.romanized_name for x in instance.arranger.all())
|
||||||
|
self.fields['idols_str'].initial = ', '.join(
|
||||||
|
x.romanized_name for x in instance.idols.all())
|
||||||
|
|
||||||
|
|
||||||
class SongAdmin(admin.ModelAdmin):
|
class SongAdmin(admin.ModelAdmin):
|
||||||
search_fields = ['romanized_title','title']
|
form = SongForm
|
||||||
|
search_fields = ['romanized_title', 'title']
|
||||||
|
|
||||||
|
class Media:
|
||||||
|
js = (
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.6.2/tinymce.min.js',
|
||||||
|
'tinymce-init.js'
|
||||||
|
)
|
||||||
|
|
||||||
|
def save_model(self, request, obj, form, change):
|
||||||
|
lyricist_str = form.cleaned_data.get('lyricist_str')
|
||||||
|
composer_str = form.cleaned_data.get('composer_str')
|
||||||
|
arranger_str = form.cleaned_data.get('arranger_str')
|
||||||
|
idols_str = form.cleaned_data.get('idols_str')
|
||||||
|
lyricist = Artist.objects.comma_to_qs(lyricist_str)
|
||||||
|
composer = Artist.objects.comma_to_qs(composer_str)
|
||||||
|
arranger = Artist.objects.comma_to_qs(arranger_str)
|
||||||
|
idols = Idol.objects.comma_to_qs(idols_str)
|
||||||
|
if not obj.id:
|
||||||
|
obj.save()
|
||||||
|
obj.lyricist.clear()
|
||||||
|
obj.lyricist.add(*lyricist)
|
||||||
|
obj.composer.clear()
|
||||||
|
obj.composer.add(*composer)
|
||||||
|
obj.arranger.clear()
|
||||||
|
obj.arranger.add(*arranger)
|
||||||
|
obj.idols.clear()
|
||||||
|
obj.idols.add(*idols)
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
|
||||||
class OutsideSongAdmin(admin.ModelAdmin):
|
class OutsideSongAdmin(admin.ModelAdmin):
|
||||||
search_fields = ['title']
|
search_fields = ['title']
|
||||||
|
|
||||||
admin.site.register(models.Song, SongAdmin)
|
|
||||||
admin.site.register(models.OutsideSong, OutsideSongAdmin)
|
admin.site.register(Song, SongAdmin)
|
||||||
|
admin.site.register(OutsideSong, OutsideSongAdmin)
|
||||||
|
@ -2,4 +2,5 @@ from django.apps import AppConfig
|
|||||||
|
|
||||||
|
|
||||||
class SongsConfig(AppConfig):
|
class SongsConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
name = 'songs'
|
name = 'songs'
|
||||||
|
23
songs/migrations/0003_auto_20201216_1925.py
Normal file
23
songs/migrations/0003_auto_20201216_1925.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.1.4 on 2020-12-16 19:25
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('songs', '0002_auto_20201216_1622'),
|
||||||
|
]
|
||||||
|
|
||||||
|
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(max_length=255),
|
||||||
|
),
|
||||||
|
]
|
17
songs/migrations/0004_auto_20201217_0812.py
Normal file
17
songs/migrations/0004_auto_20201217_0812.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 3.1.4 on 2020-12-17 08:12
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('songs', '0003_auto_20201216_1925'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='song',
|
||||||
|
options={'ordering': ['-branch__acronym', 'romanized_title', 'title']},
|
||||||
|
),
|
||||||
|
]
|
19
songs/migrations/0005_song_idols.py
Normal file
19
songs/migrations/0005_song_idols.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 3.2.5 on 2021-07-09 17:11
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('artists', '0005_idol_voiceactor'),
|
||||||
|
('songs', '0004_auto_20201217_0812'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='song',
|
||||||
|
name='idols',
|
||||||
|
field=models.ManyToManyField(blank=True, related_name='idol_songs', to='artists.Idol'),
|
||||||
|
),
|
||||||
|
]
|
19
songs/migrations/0006_alter_song_idols.py
Normal file
19
songs/migrations/0006_alter_song_idols.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 3.2.5 on 2021-07-09 17:20
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('idols', '0001_initial'),
|
||||||
|
('songs', '0005_song_idols'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='song',
|
||||||
|
name='idols',
|
||||||
|
field=models.ManyToManyField(blank=True, related_name='idol_songs', to='idols.Idol'),
|
||||||
|
),
|
||||||
|
]
|
23
songs/migrations/0007_auto_20210710_0700.py
Normal file
23
songs/migrations/0007_auto_20210710_0700.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.2.5 on 2021-07-10 07:00
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('songs', '0006_alter_song_idols'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='outsidesong',
|
||||||
|
name='id',
|
||||||
|
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='song',
|
||||||
|
name='id',
|
||||||
|
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
|
||||||
|
),
|
||||||
|
]
|
@ -4,15 +4,16 @@ from django.db import models
|
|||||||
# Create your models here.
|
# Create your models here.
|
||||||
class Song(models.Model):
|
class Song(models.Model):
|
||||||
branch = models.ForeignKey("categories.Branch", on_delete=models.PROTECT)
|
branch = models.ForeignKey("categories.Branch", on_delete=models.PROTECT)
|
||||||
title = models.CharField(max_length=255,blank=True)
|
title = models.CharField(max_length=255)
|
||||||
romanized_title = models.CharField(max_length=255)
|
romanized_title = models.CharField(max_length=255,blank=True)
|
||||||
lyricist = models.ManyToManyField("artists.Artist", blank=True, related_name="written_songs")
|
lyricist = models.ManyToManyField("artists.Artist", blank=True, related_name="written_songs")
|
||||||
composer = models.ManyToManyField("artists.Artist", blank=True, related_name="composed_songs")
|
composer = models.ManyToManyField("artists.Artist", blank=True, related_name="composed_songs")
|
||||||
arranger = models.ManyToManyField("artists.Artist", blank=True, related_name="arranged_songs")
|
arranger = models.ManyToManyField("artists.Artist", blank=True, related_name="arranged_songs")
|
||||||
|
idols = models.ManyToManyField("idols.Idol",blank=True,related_name="idol_songs")
|
||||||
impression = models.TextField(blank=True)
|
impression = models.TextField(blank=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = [ 'romanized_title','title' ]
|
ordering = [ '-branch__acronym','romanized_title','title' ]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "["+self.branch.acronym+"] "+self.title
|
return "["+self.branch.acronym+"] "+self.title
|
||||||
|
@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Songs</h1>
|
<h1>Songs</h1>
|
||||||
|
<form action="{{ request.path }}" method="GET">
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input type="text" class="form-control" placeholder="Search" aria-label="Search" aria-describedby="search-button" name="q">
|
||||||
|
<button class="btn btn-outline-secondary" type="submit" id="search-button">Search</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
{% include 'components/song-table.html' with songs=page_obj %}
|
{% include 'components/song-table.html' with songs=page_obj %}
|
||||||
<nav aria-label="Pages">
|
<nav aria-label="Pages">
|
||||||
<ul class="pagination">
|
<ul class="pagination">
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
{% if song.branch %}
|
{% if song.branch %}
|
||||||
<tr>
|
<tr class="song-row branch-{{ song.branch.acronym }}">
|
||||||
<th scope="row">Branch</th>
|
<th scope="row">Branch</th>
|
||||||
<td><a href="/taxonomy/branches/{{ song.branch.acronym }}">[{{ song.branch.acronym }}] {{ song.branch.name }}</a></td>
|
<td><a href="/taxonomy/branches/{{ song.branch.acronym }}">[{{ song.branch.acronym }}] {{ song.branch.name }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -46,5 +46,5 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<h2>Impression</h2>
|
<h2>Impression</h2>
|
||||||
<p>{{ song.impression }}</p>
|
<div>{{ song.impression|safe }}</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -5,15 +5,21 @@ from .models import Song
|
|||||||
# Create your views here.
|
# Create your views here.
|
||||||
def song_index(request):
|
def song_index(request):
|
||||||
songs = Song.objects.all()
|
songs = Song.objects.all()
|
||||||
|
objs = {}
|
||||||
|
if "q" in request.GET:
|
||||||
|
q = request.GET['q']
|
||||||
|
songs = Song.objects.filter(title__icontains=q) | Song.objects.filter(romanized_title__icontains=q)
|
||||||
|
objs['q'] = q
|
||||||
paginator = Paginator(songs, 100)
|
paginator = Paginator(songs, 100)
|
||||||
page_number = request.GET.get('page',1)
|
page_number = request.GET.get('page',1)
|
||||||
page_obj = paginator.get_page(page_number)
|
page_obj = paginator.get_page(page_number)
|
||||||
return render(request,'songs/index.html',{'page_obj':page_obj})
|
objs['page_obj'] = page_obj
|
||||||
|
return render(request,'songs/index.html',objs)
|
||||||
|
|
||||||
def song_id(request, id):
|
def song_id(request, id):
|
||||||
song = Song.objects.filter(id=id)[0]
|
song = Song.objects.filter(id=id)[0]
|
||||||
return redirect(song_show,id=song.id,title=song.title)
|
return redirect(song_show,id=song.id,title=song.title)
|
||||||
|
|
||||||
def song_show(request, id, title):
|
def song_show(request, id, title):
|
||||||
song = Song.objects.filter(id=id,title=title)[0]
|
song = Song.objects.filter(id=id)[0]
|
||||||
return render(request,'songs/show.html',{'song':song})
|
return render(request,'songs/show.html',{'song':song})
|
@ -8,15 +8,9 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for song in songs %}
|
{% for song in songs %}
|
||||||
<tr>
|
<tr class="song-row branch-{{ song.branch.acronym }}">
|
||||||
<td>
|
<td>
|
||||||
{% if song.branch.logo %}
|
|
||||||
<a href="/taxonomy/branches/{{ song.branch.acronym }}">
|
|
||||||
<img src="{{ song.branch.logo.url }}" width=24>
|
|
||||||
</a>
|
|
||||||
{% else %}
|
|
||||||
<a href="/taxonomy/branches/{{ song.branch.acronym }}">{{ song.branch.acronym }}</a>
|
<a href="/taxonomy/branches/{{ song.branch.acronym }}">{{ song.branch.acronym }}</a>
|
||||||
{% endif %}
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="/songs/{{ song.id }}/{{ song.title }}">{{ song.title }}</a>
|
<a href="/songs/{{ song.id }}/{{ song.title }}">{{ song.title }}</a>
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
{% load static %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
@ -9,6 +11,7 @@
|
|||||||
</title>
|
</title>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||||
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
|
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
|
||||||
|
<link href="{% static 'branches.css' %}" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -27,6 +30,9 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/songs">Songs</a>
|
<a class="nav-link" href="/songs">Songs</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/idols">Idols</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/artists">Artists</a>
|
<a class="nav-link" href="/artists">Artists</a>
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user