Commit 240264c1 authored by Gink's avatar Gink

Adds models in model.py for database integration with Django

parent b2cc5ac2
-- Do NOT RUN -- Do NOT RUN
--artist extraction
INSERT INTO artist(id, name, description) INSERT INTO artist(id, name, description)
select ag.artistid, ag.name, "No description available" from artists_group ag where ag.name in select ag.artistid, ag.name, "No description available" from artists_group ag where ag.name in
( (
...@@ -27,12 +29,14 @@ select ag.artistid, ag.name, "No description available" from artists_group ag wh ...@@ -27,12 +29,14 @@ select ag.artistid, ag.name, "No description available" from artists_group ag wh
"Post Malone" "Post Malone"
); );
--album extraction
INSERT INTO album(id, album_name, year, artist_id) INSERT INTO album(id, album_name, year, artist_id)
select distinct tg.id, name, year, (select artistid from torrents_artists where groupid=tg.id order by importance asc limit 1) as artistidv select tg.id, name, year, (select artistid from torrents_artists where groupid=tg.id order by importance asc limit 1) as artistidv
from torrents_group tg join torrents_artists ta on ta.groupid = tg.id from torrents_group tg join torrents_artists ta on ta.groupid = tg.id
where (select artistid from torrents_artists where groupid=tg.id order by importance asc limit 1) where (select artistid from torrents_artists where groupid=tg.id order by importance asc limit 1)
in (select id from artist) and (ta.artistid in (select id from artist)) and tg.releasetype=1 order by tg.id; in (select id from artist) and (ta.artistid in (select id from artist)) and tg.releasetype=1 order by tg.id;
--song extraction
INSERT INTO song(song_name, genre, artist_id, album_id) INSERT INTO song(song_name, genre, artist_id, album_id)
select (select filelist from torrents where groupid=album.id order by time desc limit 1), tg.taglist , artist.id, album.id select (select filelist from torrents where groupid=album.id order by time desc limit 1), tg.taglist , artist.id, album.id
from artist join album on album.artist_id = artist.id join torrents_group tg on tg.id = album.id; from artist join album on album.artist_id = artist.id join torrents_group tg on tg.id = album.id;
......
...@@ -34,9 +34,9 @@ create table song( ...@@ -34,9 +34,9 @@ create table song(
create table music_playlist( create table music_playlist(
id int unique primary key auto_increment, id int unique primary key auto_increment,
owner_id int,
playlist_name varchar(32) not null, playlist_name varchar(32) not null,
is_public boolean not null, is_public boolean not null,
owner_id int,
FOREIGN KEY (owner_id) REFERENCES user_account(id) FOREIGN KEY (owner_id) REFERENCES user_account(id)
); );
......
from django.db import models from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.db.models.signals import post_save from django.db.models.signals import post_save
from django.dispatch import receiver
# Create your models here. class user_account(models.Model):
id = models.AutoField(primary_key=true)
first_name = models.CharField(max_length=64)
last_name = models.CharField(max_length=64)
email = models.CharField(max_length=64)
# class Profile(models.Model): class artist(models.Model):
# user = models.OneToOneField(User, on_delete=models.CASCADE) id = models.AutoField(primary_key=true)
# first_name = models.TextField(max_length=255) name = models.CharField(max_length=64)
# last_name = models.TextField(max_length=255) description = models.TextField()
# email_address = models.EmailField(max_length=255)
@receiver(post_save, sender=User) class album(models.Model):
def update_user_profile(sender, instance, created, **kwargs): id = models.AutoField(primary_key=true)
if created: album_name = models.CharField(max_length=64)
Profile.objects.create(user=instance) year = models.DecimalField(max_digits=4, decimal_places=0)
instance.profile.save() # FOREIGN KEY artist_id
class song(models.Model):
id = models.AutoField(primary_key=true)
song_name = models.TextField()
genre = models.CharField(max_length=128)
song_length = models.PositiveIntegerField(default=0)
lyrics = models.TextField()
#FOREIGN KEY ARTISTID
#FOREIGN KEY ALBUMID
class music_playlist(models.Model):
id = models.AutoField(primary_key=true)
playlist_name = models.CharField(max_length=32)
is_public = models.BooleanField(default=false)
#FOREIGN KEY TO user_account
class music_entry(models.Model):
RATING_CHOICES = (
(0,'1'),
(1,'2'),
(2,'3'),
(3,'4'),
(4,'5'),
(5,'6'),
(6,'7'),
(7,'8'),
(8,'9'),
(9,'10')
)
id = models.AutoField(primary_key=true)
order_in_playlist = models.PositiveSmallIntegerField()
rating = models.DecimalField(max_digits=1, decimal_places=0, choices=RATING_CHOICES)
#FOREIGN KEY TO PLAYLIST
#FOREIGN KEY TO SONG
class tag(models.Model):
id = models.AutoField(primary_key=true)
name = models.CharField(max_length=32)
\ No newline at end of file
...@@ -122,7 +122,7 @@ body { ...@@ -122,7 +122,7 @@ body {
@font-face { @font-face {
font-family: 'PalanquinDark'; font-family: 'PalanquinDark';
src: url('../fonts/PalanquinDark-Regular.ttf'); src: url('/files/fonts/palanquindark/PalanquinDark-Regular.ttf');
} }
...@@ -104,6 +104,7 @@ STATICFILES_FINDERS = [ ...@@ -104,6 +104,7 @@ STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder", "django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder", "django.contrib.staticfiles.finders.AppDirectoriesFinder",
] ]
STATICFILES_DIRS = [ STATICFILES_DIRS = [
os.path.join(BASE_DIR, "files"), os.path.join(BASE_DIR, "files"),
] ]
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>{% block title %}MyMusicList{% endblock %}</title> <title>{% block title %}MyMusicList{% endblock %}</title>
<link rel="stylesheet" href="/files/css/mymusiclist.css"> <link rel="stylesheet" href="/files/css/mymusiclist.css">
<link rel="stylesheet" href="/files/css/font-awesome.css">
</head> </head>
<body> <body>
<header> <header>
...@@ -18,6 +19,7 @@ ...@@ -18,6 +19,7 @@
<li><a class="nav_bar_home" href="/">MyMusicList</a></li> <li><a class="nav_bar_home" href="/">MyMusicList</a></li>
<li><a class="nav_bar_tab" href="{% url 'login' %}">LOGIN</a></li> <li><a class="nav_bar_tab" href="{% url 'login' %}">LOGIN</a></li>
<li><a class="nav_bar_tab" href="{% url 'signup' %}">SIGN UP</a></li> <li><a class="nav_bar_tab" href="{% url 'signup' %}">SIGN UP</a></li>
<li style="float:right"><button class="nav_bar_tab"type="button" onclick="toggleWallpaper()"></button></li>
</ul> </ul>
{% endif %} {% endif %}
</header> </header>
...@@ -34,5 +36,10 @@ ...@@ -34,5 +36,10 @@
{% block content %} {% block content %}
{% endblock %} {% endblock %}
</main> </main>
<script>
function toggleWallpaper() {
document.getElementByID("nav_bar").style.background-color = "white";
}
</script>
</body> </body>
</html> </html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment