diff --git a/altessimo/settings.py b/altessimo/settings.py index 6bec636..1920139 100644 --- a/altessimo/settings.py +++ b/altessimo/settings.py @@ -124,3 +124,5 @@ USE_TZ = True STATIC_URL = '/static/' STATIC_ROOT = BASE_DIR / 'static' +MEDIA_ROOT = BASE_DIR / 'media' +MEDIA_URL = '/media/' diff --git a/altessimo/urls.py b/altessimo/urls.py index 5a9ff86..fbc2d75 100644 --- a/altessimo/urls.py +++ b/altessimo/urls.py @@ -18,7 +18,7 @@ from django.urls import include, path urlpatterns = [ path('', include('home.urls')), - path('categories/', include('categories.urls')), + path('taxonomy/', include('categories.urls')), path('artists/', include('artists.urls')), path('songs/', include('songs.urls')), path('admin/', admin.site.urls), diff --git a/artists/migrations/0002_artist_slug.py b/artists/migrations/0002_artist_slug.py new file mode 100644 index 0000000..0b168ca --- /dev/null +++ b/artists/migrations/0002_artist_slug.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2020-12-16 15:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('artists', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='artist', + name='slug', + field=models.SlugField(blank=True, max_length=255), + ), + ] diff --git a/artists/migrations/0003_auto_20201216_1622.py b/artists/migrations/0003_auto_20201216_1622.py new file mode 100644 index 0000000..3d3a8d2 --- /dev/null +++ b/artists/migrations/0003_auto_20201216_1622.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2020-12-16 16:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('artists', '0002_artist_slug'), + ] + + operations = [ + migrations.AlterField( + model_name='artist', + name='romanized_name', + field=models.CharField(max_length=255), + ), + ] diff --git a/artists/migrations/0004_auto_20201216_1633.py b/artists/migrations/0004_auto_20201216_1633.py new file mode 100644 index 0000000..341c2ba --- /dev/null +++ b/artists/migrations/0004_auto_20201216_1633.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2020-12-16 16:33 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('artists', '0003_auto_20201216_1622'), + ] + + operations = [ + migrations.RenameField( + model_name='artist', + old_name='about_composer', + new_name='about_artist', + ), + ] diff --git a/artists/models.py b/artists/models.py index 17d3dd6..551e0af 100644 --- a/artists/models.py +++ b/artists/models.py @@ -1,5 +1,6 @@ from django.db import models from django.apps import apps +from django.utils.text import slugify # Create your models here. class ArtistManager(models.Manager): @@ -20,10 +21,11 @@ class ArtistManager(models.Manager): class Artist(models.Model): name = models.CharField(max_length=255,blank=True) - romanized_name = models.CharField(max_length=255,blank=True) + romanized_name = models.CharField(max_length=255) + slug = models.SlugField(max_length=255,blank=True) aliases = models.ManyToManyField("self",blank=True) category = models.ManyToManyField("categories.Category",blank=True) - about_composer = models.TextField(blank=True) + about_artist = models.TextField(blank=True) about_music = models.TextField(blank=True) objects = ArtistManager() @@ -33,3 +35,7 @@ class Artist(models.Model): def __str__(self): return self.romanized_name + + def save(self, *args, **kwargs): + self.slug = slugify(self.romanized_name) + super().save(*args,**kwargs) diff --git a/artists/templates/artists/index.html b/artists/templates/artists/index.html new file mode 100644 index 0000000..9584ed9 --- /dev/null +++ b/artists/templates/artists/index.html @@ -0,0 +1,12 @@ +{% extends 'layouts/base.html' %} + +{% block title %} Artists {% endblock %} + +{% block content %} +

Artists

+ +{% endblock %} \ No newline at end of file diff --git a/artists/templates/artists/show.html b/artists/templates/artists/show.html new file mode 100644 index 0000000..46277b0 --- /dev/null +++ b/artists/templates/artists/show.html @@ -0,0 +1,60 @@ +{% extends 'layouts/base.html' %} + +{% block title %} Artist: {{ artist.romanized_name }} {% endblock %} + +{% block content %} +

Artist: {{ artist.romanized_name }}

+

Metadata

+ + + {% if artist.name %} + + + + + {% endif %} + {% if artist.romanized_name %} + + + + + {% endif %} + {% for alias in artist.aliases.all %} + + + + + {% endfor %} + {% for category in artist.category.all %} + + + + + {% endfor %} + +
+ Name + + {{ artist.name }} +
+ Romanized Name + + {{ artist.romanized_name }} +
+ Alias + + {{ alias.romanized_name }} +
+ Category + + {{ category.name }} +
+

About Artist

+

{{ artist.about_artist }}

+

About Music

+

{{ artist.about_music }}

+

Credits

+ {% include 'components/song-table.html' with songs=credit_songs %} +

Sample works outside Idolmaster

+ {% include 'components/outside-song-table.html' with outside_songs=outside_songs %} +{% endblock %} \ No newline at end of file diff --git a/artists/urls.py b/artists/urls.py index f39e8be..8cd04b1 100644 --- a/artists/urls.py +++ b/artists/urls.py @@ -3,4 +3,6 @@ from django.urls import path from . import views urlpatterns = [ + path('',views.artist_index), + path('',views.artist_show) ] diff --git a/artists/views.py b/artists/views.py index 91ea44a..6793177 100644 --- a/artists/views.py +++ b/artists/views.py @@ -1,3 +1,15 @@ from django.shortcuts import render # Create your views here. +from .models import Artist +from songs.models import OutsideSong + +def artist_index(request): + artists = Artist.objects.all() + return render(request,'artists/index.html',{'artists':artists}) + +def artist_show(request, slug): + artist = Artist.objects.filter(slug=slug)[0] + credit_songs = (artist.written_songs.all() | artist.composed_songs.all() | artist.arranged_songs.all()).distinct() + outside_songs = OutsideSong.objects.filter(composer=artist) + return render(request,'artists/show.html',{'artist': artist,'credit_songs':credit_songs,'outside_songs':outside_songs}) \ No newline at end of file diff --git a/categories/migrations/0002_category_slug.py b/categories/migrations/0002_category_slug.py new file mode 100644 index 0000000..c137e4e --- /dev/null +++ b/categories/migrations/0002_category_slug.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.4 on 2020-12-16 15:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='category', + name='slug', + field=models.SlugField(default='', max_length=255), + preserve_default=False, + ), + ] diff --git a/categories/migrations/0003_branch_description.py b/categories/migrations/0003_branch_description.py new file mode 100644 index 0000000..0a2cc37 --- /dev/null +++ b/categories/migrations/0003_branch_description.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2020-12-16 16:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0002_category_slug'), + ] + + operations = [ + migrations.AddField( + model_name='branch', + name='description', + field=models.TextField(blank=True), + ), + ] diff --git a/categories/migrations/0004_auto_20201216_1622.py b/categories/migrations/0004_auto_20201216_1622.py new file mode 100644 index 0000000..0c3a78b --- /dev/null +++ b/categories/migrations/0004_auto_20201216_1622.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2020-12-16 16:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0003_branch_description'), + ] + + operations = [ + migrations.AlterField( + model_name='branch', + name='acronym', + field=models.CharField(max_length=20), + ), + ] diff --git a/categories/migrations/0005_branch_color.py b/categories/migrations/0005_branch_color.py new file mode 100644 index 0000000..17ae246 --- /dev/null +++ b/categories/migrations/0005_branch_color.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2020-12-16 16:46 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0004_auto_20201216_1622'), + ] + + operations = [ + migrations.AddField( + model_name='branch', + name='color', + field=models.CharField(default='#ffffff', max_length=10), + ), + ] diff --git a/categories/migrations/0006_auto_20201216_1650.py b/categories/migrations/0006_auto_20201216_1650.py new file mode 100644 index 0000000..661dd23 --- /dev/null +++ b/categories/migrations/0006_auto_20201216_1650.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.4 on 2020-12-16 16:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0005_branch_color'), + ] + + operations = [ + migrations.RenameField( + model_name='branch', + old_name='color', + new_name='background_color', + ), + migrations.AddField( + model_name='branch', + name='foreground_color', + field=models.CharField(default='#000000', max_length=10), + ), + ] diff --git a/categories/migrations/0007_auto_20201216_1707.py b/categories/migrations/0007_auto_20201216_1707.py new file mode 100644 index 0000000..8c84835 --- /dev/null +++ b/categories/migrations/0007_auto_20201216_1707.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.4 on 2020-12-16 17:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0006_auto_20201216_1650'), + ] + + operations = [ + migrations.RemoveField( + model_name='branch', + name='background_color', + ), + migrations.RemoveField( + model_name='branch', + name='foreground_color', + ), + migrations.AddField( + model_name='branch', + name='logo', + field=models.ImageField(blank=True, upload_to='logo'), + ), + ] diff --git a/categories/migrations/0008_auto_20201216_1728.py b/categories/migrations/0008_auto_20201216_1728.py new file mode 100644 index 0000000..1385fb0 --- /dev/null +++ b/categories/migrations/0008_auto_20201216_1728.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2020-12-16 17:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0007_auto_20201216_1707'), + ] + + operations = [ + migrations.AlterField( + model_name='branch', + name='logo', + field=models.ImageField(blank=True, upload_to='media/logo'), + ), + ] diff --git a/categories/migrations/0009_auto_20201216_1732.py b/categories/migrations/0009_auto_20201216_1732.py new file mode 100644 index 0000000..4e24bd4 --- /dev/null +++ b/categories/migrations/0009_auto_20201216_1732.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2020-12-16 17:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0008_auto_20201216_1728'), + ] + + operations = [ + migrations.AlterField( + model_name='branch', + name='logo', + field=models.ImageField(blank=True, upload_to='logo'), + ), + ] diff --git a/categories/models.py b/categories/models.py index daba675..3b4250e 100644 --- a/categories/models.py +++ b/categories/models.py @@ -1,8 +1,11 @@ from django.db import models +from django.utils.text import slugify class Branch(models.Model): name = models.CharField(max_length=255,blank=True) - acronym = models.CharField(max_length=20,blank=True) + acronym = models.CharField(max_length=20) + description = models.TextField(blank=True) + logo = models.ImageField(upload_to="logo",blank=True) def __str__(self): return self.name+" ["+self.acronym+"]" @@ -26,6 +29,7 @@ class CategoryManager(models.Manager): class Category(models.Model): name = models.CharField(max_length=255) + slug = models.SlugField(max_length=255) description = models.TextField(blank=True) objects = CategoryManager() @@ -37,3 +41,7 @@ class Category(models.Model): def __str__(self): return self.name + def save(self, *args, **kwargs): + self.slug = slugify(self.name) + super().save(*args,**kwargs) + diff --git a/categories/templates/branches/index.html b/categories/templates/branches/index.html new file mode 100644 index 0000000..92a099f --- /dev/null +++ b/categories/templates/branches/index.html @@ -0,0 +1,26 @@ +{% extends 'layouts/base.html' %} + +{% block title %}Branches{% endblock %} +{% block content %} +

Branches

+ + + + + + + + {% for branch in branches %} + + + + + + {% endfor %} + +
AcronymLogoName
{{ branch.acronym }} + {% if branch.logo %} + + {% endif %} + {{ branch.name }} [{{ branch.acronym }}]
+{% endblock %} \ No newline at end of file diff --git a/categories/templates/branches/show.html b/categories/templates/branches/show.html new file mode 100644 index 0000000..2bf5aed --- /dev/null +++ b/categories/templates/branches/show.html @@ -0,0 +1,9 @@ +{% extends 'layouts/base.html' %} + +{% block content %} +

[{{ branch.acronym }}] {{ branch.name }}

+

Description

+

{{ branch.description }}

+

Songs

+ {% include 'components/song-table.html' with songs=songs %} +{% endblock %} \ No newline at end of file diff --git a/categories/templates/categories/index.html b/categories/templates/categories/index.html new file mode 100644 index 0000000..2a7ed53 --- /dev/null +++ b/categories/templates/categories/index.html @@ -0,0 +1,12 @@ +{% extends 'layouts/base.html' %} + +{% block title %} Categories {% endblock %} + +{% block content %} +

Categories

+ +{% endblock %} \ No newline at end of file diff --git a/categories/templates/categories/show.html b/categories/templates/categories/show.html new file mode 100644 index 0000000..16da92c --- /dev/null +++ b/categories/templates/categories/show.html @@ -0,0 +1,15 @@ +{% extends 'layouts/base.html' %} + +{% block title %} Category: {{ category.name }} {% endblock %} + +{% block content %} +

Category: {{ category.name }}

+

Description

+

{{ category.description }}

+

Artists

+ +{% endblock %} \ No newline at end of file diff --git a/categories/urls.py b/categories/urls.py index f39e8be..0f22bc8 100644 --- a/categories/urls.py +++ b/categories/urls.py @@ -3,4 +3,8 @@ from django.urls import path from . import views urlpatterns = [ + path('categories',views.category_index), + path('categories/',views.category_show), + path('branches',views.branch_index), + path('branches/',views.branch_show), ] diff --git a/categories/views.py b/categories/views.py index 521df64..37a388e 100644 --- a/categories/views.py +++ b/categories/views.py @@ -1,6 +1,23 @@ from django.shortcuts import render from django.http import HttpResponse +from .models import Branch, Category +from songs.models import Song +from artists.models import Artist # Create your views here. -def index(request): - return HttpResponse("Yuika!") +def category_index(request): + categories = Category.objects.all() + return render(request,"categories/index.html",{'categories':categories}) + +def category_show(request, slug): + category = Category.objects.filter(slug=slug)[0] + return render(request,"categories/show.html",{'category':category}) + +def branch_index(request): + branches = Branch.objects.all() + return render(request,"branches/index.html",{'branches':branches}) + +def branch_show(request, acronym): + branch = Branch.objects.filter(acronym=acronym)[0] + songs = Song.objects.filter(branch=branch) + return render(request,"branches/show.html",{'branch':branch,'songs':songs}) \ No newline at end of file diff --git a/home/templates/index.html b/home/templates/index.html index a91310f..9399273 100644 --- a/home/templates/index.html +++ b/home/templates/index.html @@ -9,7 +9,7 @@
  • Complete lyricist credits
  • Add songs from IDOLM@STER Radio
  • -
  • Readd other songs that I might have missed
  • +
  • Re-add other songs that I might have missed
  • Complete showcases of composers
{% endblock %} \ No newline at end of file diff --git a/home/urls.py b/home/urls.py index f78b483..cd09f95 100644 --- a/home/urls.py +++ b/home/urls.py @@ -4,5 +4,4 @@ from . import views urlpatterns = [ path('',views.index), - path('home',views.index), ] diff --git a/media/.gitignore b/media/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/media/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/songs/migrations/0002_auto_20201216_1622.py b/songs/migrations/0002_auto_20201216_1622.py new file mode 100644 index 0000000..5e792b0 --- /dev/null +++ b/songs/migrations/0002_auto_20201216_1622.py @@ -0,0 +1,40 @@ +# Generated by Django 3.1.4 on 2020-12-16 16:22 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('categories', '0004_auto_20201216_1622'), + ('songs', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='outsidesong', + name='origin', + field=models.CharField(max_length=255), + ), + migrations.AlterField( + model_name='outsidesong', + name='title', + field=models.CharField(max_length=255), + ), + migrations.AlterField( + model_name='outsidesong', + name='url', + field=models.URLField(max_length=255), + ), + migrations.AlterField( + model_name='song', + name='branch', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='categories.branch'), + ), + migrations.AlterField( + model_name='song', + name='romanized_title', + field=models.CharField(max_length=255), + ), + ] diff --git a/songs/models.py b/songs/models.py index 92a493d..c208c89 100644 --- a/songs/models.py +++ b/songs/models.py @@ -3,9 +3,9 @@ from django.db import models # Create your models here. class Song(models.Model): - branch = models.ForeignKey("categories.Branch", blank=True, on_delete=models.PROTECT) + branch = models.ForeignKey("categories.Branch", on_delete=models.PROTECT) title = models.CharField(max_length=255,blank=True) - romanized_title = models.CharField(max_length=255,blank=True) + romanized_title = models.CharField(max_length=255) 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") @@ -18,10 +18,10 @@ class Song(models.Model): return "["+self.branch.acronym+"] "+self.title class OutsideSong(models.Model): - title = models.CharField(max_length=255,blank=True) + title = models.CharField(max_length=255) artist = models.CharField(max_length=255,blank=True) - origin = models.CharField(max_length=255,blank=True) - url = models.URLField(max_length=255,blank=True) + origin = models.CharField(max_length=255) + url = models.URLField(max_length=255) composer = models.ForeignKey("artists.Artist", blank=True, on_delete=models.CASCADE) class Meta: diff --git a/songs/templates/songs/index.html b/songs/templates/songs/index.html new file mode 100644 index 0000000..db97d03 --- /dev/null +++ b/songs/templates/songs/index.html @@ -0,0 +1,10 @@ +{% extends 'layouts/base.html' %} + +{% block title %} Songs {% endblock %} + +{% block content %} +

Songs

+
    + {% include 'components/song-table.html' with songs=songs %} +
+{% endblock %} \ No newline at end of file diff --git a/songs/templates/songs/show.html b/songs/templates/songs/show.html new file mode 100644 index 0000000..5b2b68c --- /dev/null +++ b/songs/templates/songs/show.html @@ -0,0 +1,50 @@ +{% extends 'layouts/base.html' %} + +{% block title %} Song: {{ song.title }} {% endblock %} + +{% block content %} +

{{ song.title }}

+

Metadata

+ + + {% if song.branch %} + + + + + {% endif %} + {% if song.title %} + + + + + {% endif %} + {% if song.romanized_title %} + + + + + {% endif %} + {% for lyricist in song.lyricist.all %} + + + + + {% endfor %} + {% for composer in song.composer.all %} + + + + + {% endfor %} + {% for arranger in song.arranger.all %} + + + + + {% endfor %} + +
Branch[{{ song.branch.acronym }}] {{ song.branch.name }}
Title{{ song.title }}
Romanized Title{{ song.romanized_title }}
Lyricist{{ lyricist.romanized_name }}
Composer{{ composer.romanized_name }}
Arranger{{ arranger.romanized_name }}
+

Impression

+

{{ song.impression }}

+{% endblock %} \ No newline at end of file diff --git a/songs/urls.py b/songs/urls.py index f39e8be..9da2ff9 100644 --- a/songs/urls.py +++ b/songs/urls.py @@ -3,4 +3,7 @@ from django.urls import path from . import views urlpatterns = [ + path('',views.song_index), + path('',views.song_id), + path('/',views.song_show), ] diff --git a/songs/views.py b/songs/views.py index 91ea44a..0057f69 100644 --- a/songs/views.py +++ b/songs/views.py @@ -1,3 +1,15 @@ -from django.shortcuts import render +from django.shortcuts import render, redirect +from .models import Song # Create your views here. +def song_index(request): + songs = Song.objects.all() + return render(request,'songs/index.html',{'songs':songs}) + +def song_id(request, id): + song = Song.objects.filter(id=id)[0] + return redirect(song_show,id=song.id,title=song.title) + +def song_show(request, id, title): + song = Song.objects.filter(id=id,title=title)[0] + return render(request,'songs/show.html',{'song':song}) \ No newline at end of file diff --git a/templates/components/outside-song-table.html b/templates/components/outside-song-table.html new file mode 100644 index 0000000..f826d1d --- /dev/null +++ b/templates/components/outside-song-table.html @@ -0,0 +1,18 @@ + + + + + + + + + {% for song in outside_songs %} + + + + + + + {% endfor %} + +
TitleArtistOriginLink
{{ song.title }}{{ song.artist }}{{ song.origin }}Open
\ No newline at end of file diff --git a/templates/components/song-table.html b/templates/components/song-table.html new file mode 100644 index 0000000..6414052 --- /dev/null +++ b/templates/components/song-table.html @@ -0,0 +1,42 @@ + + + + + + + + + + {% for song in songs %} + + + + + + + + {% endfor %} + +
BranchSong TitleLyricistComposerArranger
+ {% if song.branch.logo %} + + + + {% else %} + {{ song.branch.acronym }} + {% endif %} + + {{ song.title }} + + {% for artist in song.lyricist.all %} + {{ artist.romanized_name }}
+ {% endfor %} +
+ {% for artist in song.composer.all %} + {{ artist.romanized_name }}
+ {% endfor %} +
+ {% for artist in song.arranger.all %} + {{ artist.romanized_name }}
+ {% endfor %} +
\ No newline at end of file diff --git a/templates/layouts/base.html b/templates/layouts/base.html index a7d6e43..65c5a07 100644 --- a/templates/layouts/base.html +++ b/templates/layouts/base.html @@ -4,7 +4,9 @@ - Altessimo + + {% block title %} Altessimo {% endblock %} + @@ -22,6 +24,18 @@ + + + +