Commit 240264c1 authored by Gink's avatar Gink

Adds models in model.py for database integration with Django

parent b2cc5ac2
-- Do NOT RUN
--artist extraction
INSERT INTO artist(id, name, description)
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
"Post Malone"
);
--album extraction
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
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;
--song extraction
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
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(
create table music_playlist(
id int unique primary key auto_increment,
owner_id int,
playlist_name varchar(32) not null,
is_public boolean not null,
owner_id int,
FOREIGN KEY (owner_id) REFERENCES user_account(id)
);
......
from django.db import models
from django.contrib.auth.models import User
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):
# user = models.OneToOneField(User, on_delete=models.CASCADE)
# first_name = models.TextField(max_length=255)
# last_name = models.TextField(max_length=255)
# email_address = models.EmailField(max_length=255)
class artist(models.Model):
id = models.AutoField(primary_key=true)
name = models.CharField(max_length=64)
description = models.TextField()
@receiver(post_save, sender=User)
def update_user_profile(sender, instance, created, **kwargs):
if created:
Profile.objects.create(user=instance)
instance.profile.save()
class album(models.Model):
id = models.AutoField(primary_key=true)
album_name = models.CharField(max_length=64)
year = models.DecimalField(max_digits=4, decimal_places=0)
# 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 {
@font-face {
font-family: 'PalanquinDark';
src: url('../fonts/PalanquinDark-Regular.ttf');
src: url('/files/fonts/palanquindark/PalanquinDark-Regular.ttf');
}
......@@ -104,6 +104,7 @@ STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "files"),
]
......
......@@ -4,6 +4,7 @@
<meta charset="utf-8">
<title>{% block title %}MyMusicList{% endblock %}</title>
<link rel="stylesheet" href="/files/css/mymusiclist.css">
<link rel="stylesheet" href="/files/css/font-awesome.css">
</head>
<body>
<header>
......@@ -18,6 +19,7 @@
<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 'signup' %}">SIGN UP</a></li>
<li style="float:right"><button class="nav_bar_tab"type="button" onclick="toggleWallpaper()"></button></li>
</ul>
{% endif %}
</header>
......@@ -34,5 +36,10 @@
{% block content %}
{% endblock %}
</main>
<script>
function toggleWallpaper() {
document.getElementByID("nav_bar").style.background-color = "white";
}
</script>
</body>
</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