diff --git a/recreate-db.txt b/recreate-db.txt new file mode 100644 index 0000000..5c1e574 --- /dev/null +++ b/recreate-db.txt @@ -0,0 +1,8 @@ +# https://stackoverflow.com/a/34576062/8811872 + +sudo su postgres +psql +drop database spotifyvis; +create database spotifyvis with owner django; +\q +exit diff --git a/requirements.txt b/requirements.txt index 7eba139..59c9dc6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ idna==2.6 isort==4.3.4 lazy-object-proxy==1.3.1 mccabe==0.6.1 -psycopg2==2.7.4 +psycopg2-binary==2.7.4 pylint==1.8.4 pytz==2018.4 requests==2.18.4 diff --git a/spotifyvis/models.py b/spotifyvis/models.py index 99f93d8..b6563ed 100644 --- a/spotifyvis/models.py +++ b/spotifyvis/models.py @@ -3,6 +3,22 @@ from django.db import models # id's are 22 in length in examples but set to 30 for buffer MAX_ID = 30 +# Genre {{{ # + +class Genre(models.Model): + + class Meta: + verbose_name = "Genre" + verbose_name_plural = "Genres" + + name = models.CharField(primary_key=True, max_length=50) + num_songs = models.PositiveIntegerField() + + def __str__(self): + return self.name + +# }}} Genre # + # Artist {{{ # @@ -14,6 +30,7 @@ class Artist(models.Model): artist_id = models.CharField(primary_key=True, max_length=MAX_ID) # unique since only storing one genre per artist right now name = models.CharField(unique=True, max_length=50) + genres = models.ManyToManyField(Genre, blank=True) def __str__(self): return self.name @@ -51,7 +68,9 @@ class Track(models.Model): runtime = models.PositiveSmallIntegerField() name = models.CharField(max_length=200) users = models.ManyToManyField(User, blank=True) - genre = models.CharField(max_length=30) + # genre = models.CharField(max_length=30) + genre = models.ForeignKey(Genre, on_delete=models.CASCADE, blank=True, + null=True) def __str__(self): return self.name @@ -60,7 +79,6 @@ class Track(models.Model): # AudioFeatures {{{ # - class AudioFeatures(models.Model): class Meta: diff --git a/spotifyvis/static/spotifyvis/css/dark_bg.css b/spotifyvis/static/spotifyvis/css/dark_bg.css new file mode 100644 index 0000000..a472959 --- /dev/null +++ b/spotifyvis/static/spotifyvis/css/dark_bg.css @@ -0,0 +1,8 @@ +body { +background-color: #1e1e1e; +} + +h1,p { +color: grey; +} + diff --git a/spotifyvis/templates/spotifyvis/index.html b/spotifyvis/templates/spotifyvis/index.html index 5964b34..28a9301 100644 --- a/spotifyvis/templates/spotifyvis/index.html +++ b/spotifyvis/templates/spotifyvis/index.html @@ -4,6 +4,7 @@