Commit f69111e8 authored by Al Vincent E. Bomediano's avatar Al Vincent E. Bomediano

Merge branch 'lab02' into 'main'

Lab02

See merge request !1
parents fe9d6d42 440a68b5
Al Vincent E. Bomediano (210924) Al Vincent E. Bomediano (210924)
CSCI 40 - E CSCI 40 - E
Lab 01: Song Library Lab 02: Song Library v2
Date of submission: February 13, 2023 Date of submission: February 21, 2023
I, Al Vincent E. Bomediano hereby state that this code has been written by me, and only me. I, Al Vincent E. Bomediano hereby state that this code has been written by me, and only me.
<alvin> Al Vincent E. Bomediano, 13/02/2023 <alvin> Al Vincent E. Bomediano, 21/02/2023
\ No newline at end of file
*DISCLAIMER: My local repo had to be reinitialized due to some errors, this was done by making a new repo then manually moving all project files (except .git file) into the new repo
\ No newline at end of file
from django.db import models
# Create your models here. # Create your models here.
...@@ -12,9 +12,9 @@ https://docs.djangoproject.com/en/4.1/ref/settings/ ...@@ -12,9 +12,9 @@ https://docs.djangoproject.com/en/4.1/ref/settings/
import os import os
from pathlib import Path from pathlib import Path
from dotenv import load_dotenv # from dotenv import load_dotenv
load_dotenv() # load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
...@@ -24,7 +24,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent ...@@ -24,7 +24,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('SECRET_KEY') SECRET_KEY = 'django-insecure-9i+46m6_m#3c(eej-9w9gw!3d02&hyujjj2k$c%lpsop9%rdir'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
......
from django.contrib import admin from django.contrib import admin
from .models import Artist, Album, Song
# Register your models here.
class AlbumInline(admin.TabularInline):
model = Album
class SongInline(admin.TabularInline):
model = Song
class ArtistAdmin(admin.ModelAdmin):
model = Artist
list_display = (
'artist_name',
'birth_name',
'monthly_listeners')
search_fields = ('artist_name', 'birth_name')
list_filter = ('artist_name', 'birth_name')
inlines = [AlbumInline, SongInline, ]
fieldsets = [
('Artist Data', {
'fields': [
('artist_name', 'birth_name'),
'monthly_listeners', 'bio'
]
}),
]
class AlbumAdmin(admin.ModelAdmin):
model = Album
list_display = (
'album_name',
'description',
'release_date',
'label', 'song_count')
search_fields = ('album_name', 'description', 'label')
list_filter = ('album_name',)
class SongAdmin(admin.ModelAdmin):
model = Song
list_display = ('song_title',
'song_length',
'lyrics',
'music_video')
search_fields = ('song_title', 'lyrics')
list_filter = ('song_title',)
admin.site.register(Artist, ArtistAdmin)
admin.site.register(Album, AlbumAdmin)
admin.site.register(Song, SongAdmin)
\ No newline at end of file
# Generated by Django 4.1.7 on 2023-02-21 13:32
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Album',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('album_name', models.CharField(max_length=100)),
('label', models.CharField(max_length=100)),
('description', models.CharField(max_length=100)),
('release_date', models.CharField(max_length=10)),
('song_count', models.IntegerField()),
],
),
migrations.CreateModel(
name='Artist',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('artist_name', models.CharField(max_length=100)),
('birth_name', models.CharField(max_length=100)),
('bio', models.CharField(max_length=700)),
('monthly_listeners', models.IntegerField()),
],
),
migrations.CreateModel(
name='Song',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('song_title', models.CharField(max_length=100)),
('song_length', models.IntegerField()),
('music_video', models.BooleanField()),
('lyrics', models.CharField(max_length=3000)),
('album', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='homepage.album')),
('artist', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='homepage.artist')),
],
),
migrations.AddField(
model_name='album',
name='artist',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='homepage.artist'),
),
]
# Generated by Django 4.1.7 on 2023-02-21 13:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='song',
name='lyrics',
field=models.CharField(max_length=8000),
),
]
...@@ -3,14 +3,24 @@ from django.db import models ...@@ -3,14 +3,24 @@ from django.db import models
class Artist(models.Model): class Artist(models.Model):
artist_name = models.CharField(max_length=100) artist_name = models.CharField(max_length=100)
birth_name = models.CharField(max_length=100)
bio = models.CharField(max_length=700)
monthly_listeners = models.IntegerField() monthly_listeners = models.IntegerField()
def str(self):
return '{} aka {}'.format(self.artist_name, self.birth_name)
class Album(models.Model): class Album(models.Model):
album_name = models.CharField(max_length=100) album_name = models.CharField(max_length=100)
label = models.CharField(max_length=100)
artist = models.ForeignKey(Artist, on_delete=models.CASCADE) artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
description = models.CharField(max_length=100) description = models.CharField(max_length=100)
release_date = models.CharField(max_length=10) release_date = models.CharField(max_length=10)
song_count = models.IntegerField()
def str(self):
return '{} aka {}'.format(self.album_name, self.label)
class Song(models.Model): class Song(models.Model):
...@@ -18,3 +28,8 @@ class Song(models.Model): ...@@ -18,3 +28,8 @@ class Song(models.Model):
artist = models.ForeignKey(Artist, on_delete=models.CASCADE) artist = models.ForeignKey(Artist, on_delete=models.CASCADE)
album = models.ForeignKey(Album, on_delete=models.CASCADE) album = models.ForeignKey(Album, on_delete=models.CASCADE)
song_length = models.IntegerField() song_length = models.IntegerField()
music_video = models.BooleanField()
lyrics = models.CharField(max_length=8000)
def str(self):
return '{}'.format(self.song_title)
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