Commit 69b15e96 authored by Stanley Jason Galleta's avatar Stanley Jason Galleta

Merge branch 'playlistwip' of https://gitlab.discs.ateneo.edu/brian/mymusiclist into playlistwip

Minor design changes for Home Page
parents 304db245 336dc526
from django.apps import AppConfig
class MusicBrainzHook(AppConfig):
name = 'Musicbrainzhook'
verbose_name = name
def ready(self):
print("Self called")
def custom():
print("print called")
\ No newline at end of file
from django.shortcuts import render
# Create your views here.
from django.contrib.auth import login, authenticate
# from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django.shortcuts import render, redirect, get_object_or_404
from django.views.generic.edit import UpdateView
from core.forms import SignUpForm
from core.models import *
from core.musicbrainzhook import *
def signup(request):
if request.method == 'POST':
......@@ -38,6 +36,43 @@ class EditProfile(UpdateView):
slug_field = 'username'
slug_url_kwarg = 'slug'
def search(request):
type = request.GET.get('searchtype', '')
term = request.GET.get('search', '')
artistAlbums = album.objects.filter(artist__name__contains = term)
if type == 'song':
results = song.objects.filter(song_name__contains = term)
elif type == 'album':
results = album.objects.filter(album_name__contains = term)
elif type == 'artist':
results = artist.objects.filter(name__contains = term)
context = {
'type': type,
'term': term,
'results': results,
'albums': artistAlbums,
}
return render(request, 'search.html', context)
def artist_profile(request, identifier):
result = artist.objects.filter(id = identifier)
albums = album.objects.filter(artist = identifier)
return render(request, 'artist.html', {'result': result[0], 'albums': albums})
def album_profile(request, identifier):
result = album.objects.filter(id = identifier)
artist_name = result[0].artist.name
songs = song.objects.filter(album = identifier)
return render(request, 'album.html', {'result':result[0], 'songs': songs, 'artist': artist_name})
# def search(request,term):
# results = album.objects.filter(album_name__contains = term)
# custom()
# return render(request, 'search.html',{'term': term, 'results': results})
# def edit_profile(request, username):
# if request.method == 'POST':
# form = EditProfile(request.POST, instance=request.user)
......
......@@ -115,6 +115,10 @@ body {
margin-top: 2vh;
}
a, .link{
color: white;
}
@media (max-width:1280px){
.sidebar{
display:none;
......
......@@ -33,6 +33,7 @@ ALLOWED_HOSTS = []
INSTALLED_APPS = [
'core',
'core.musicbrainzhook',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
......
......@@ -24,8 +24,15 @@ urlpatterns = [
url(r'^logout/$', auth_views.logout, {'template_name': 'logged_out.html'}, name='logout'),
url(r'^admin/', admin.site.urls),
url(r'^signup/$', core_views.signup, name='signup'),
url(r'^profile/(?P<slug>[A-Za-z0-9-+_.@]+)/$', core_views.user_profile_page, name='viewprofile'),
# url(r'^search_by_(?P<type>[A-Za-z0-9-+_.@]+)/?search=(?P<term>[A-Za-z0-9-+_.@]+)/$',core_views.search, name='search'),
url(r'^search/$',core_views.search, name='search'),
url(r'^album/(?P<identifier>[0-9]+)/$', core_views.album_profile, name='album_profile'),
url(r'^artist/(?P<identifier>[0-9]+)/$', core_views.artist_profile, name='artist_profile'),
# url(r'^search/(?P<term>[A-Za-z0-9-+_.@]+)/$',core_views.search, name='search'),
url(r'^profile/(?P<slug>[A-Za-z0-9-+_.@]+)/$', core_views.user_profile_page, name='viewprofile'),
url(r'^profile/(?P<slug>[A-Za-z0-9-+_.@]+)/edit/$', core_views.EditProfile.as_view(success_url=reverse_lazy('home')), name='editprofile'),
# url(r'^profile/(?P<slug>[A-Za-z0-9-+_.@]+)/edit/$', core_views.EditProfile.as_view(success_url=reverse_lazy('profile', kwargs={'update':'true'})), name='editprofile'),
url(r'^$', core_views.home, name='home'),
url(r'^$', core_views.home, name='home')
]
{% extends 'base.html' %}
{% block title %}{{result.name}}{% endblock %}
{% block sidebar %}
<h2> Album info </h2>
<p>
Album: {{result.name}} <br>
Artist: {{artist_name}} <br>
Year: {{result.year}} <br>
{% endblock %}
{% block content %}
{% for i in songs %}
<div class = "boxified main">
<h3> {{i.song_name}} </h3>
<p> Genre: {{i.genre}} </p>
</div>
{% endfor %}
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}{{result.name}}{% endblock %}
{% block sidebar %}
<h2> Artist info </h2>
<p>
Artist: {{result.name}} <br>
Albums: {{albums.count}} <br>
<br>
<h2> Description </h2>
{{result.description}}
{% endblock %}
{% block content %}
{% for i in albums %}
<div class = "boxified main">
<h3> <a class = "link" href= "/album/{{i.id}}"> {{i.album_name}} </a></h3>
<p> Year: {{i.year}} </p>
</div>
{% endfor %}
{% endblock %}
......@@ -22,20 +22,68 @@
<li style="float:right"><button class="nav_bar_tab"type="button" onclick="toggleWallpaper()"></button></li>
</ul>
{% endif %}
<div class="boxified sidebar">
{% block sidebar %}
<h2>Featured Songs</h2>
<img src="/files/images/divide_edsheeran.jpeg" alt="Divide - Ed Sheeran">
Divide - Ed Sheeran
<img src="/files/images/palette_iu.jpeg" alt="Palette - IU">
Palette - IU
<img src="/files/images/rockstar_postmalone21savage.jpeg" alt="Rockstar">
Rockstar
{% endblock %}
</div>
</header>
<main>
<div class="boxified sidebar">
<h2>Featured Songs</h2>
<img src="/files/images/divide_edsheeran.jpeg" alt="Divide - Ed Sheeran">
Divide - Ed Sheeran
<img src="/files/images/palette_iu.jpeg" alt="Palette - IU">
Palette - IU
<img src="/files/images/rockstar_postmalone21savage.jpeg" alt="Rockstar">
Rockstar
</div>
<script>
function mainA(){
document.getElementById("demo").innerHTML = "Album Search";
document.getElementById("searchbytype").value = "album";
}
function mainB(){
document.getElementById("demo").innerHTML = "Artist Search";
document.getElementById("searchbytype").value = "artist";
}
function mainC(){
document.getElementById("demo").innerHTML = "Song Search";
document.getElementById("searchbytype").value = "song";
}
</script>
<form action="{% url 'search' %}" method="get">
<div class="wrap">
<div class="search">
<input type="text" name="search" placeholder="Search..">
<input id="searchbytype" type="hidden" name="searchtype" value="album">
<p id="demo">Album Search</p></input>
<button>Search</button>
</div>
</div>
</form>
<div>
<a><button onclick="mainA()">By Album</button></a>
<a><button onclick="mainB()">By Artist</button></a>
<a><button onclick="mainC()">By Song</button></a>
</div>
{% block content %}
{% endblock %}
</main>
<script>
function toggleWallpaper() {
document.getElementByID("nav_bar").style.background-color = "white";
......
{% extends 'base.html' %}
{% block title %}Song search test{% endblock %}
{% block sidebar %}
<h2> Search results (by {{type}})</h2>
<p>
You searched for '{{term}}' <br>
Found {{results.count}} results <br>
Source: Local</p>
{% endblock %}
{% block content %}
{% for i in results %}
<div class = "boxified main">
{% if type == "album" %}
<h3><a href="/album/{{i.id}}">{{i.album_name}}</a></h3>
<p>Artist: <a href="/artist/{{i.artist.id}}">{{i.artist.name}}</a><br>
Year: {{i.year}} </p>
{% endif %}
{% if type == "artist" %}
<h3><a href="/artist/{{i.id}}">{{i.name}}</a></h3>
{% for j in albums %}
<p> <tab>
{% if j.artist.name == i.name %}
<h3><a href="/album/{{j.id}}">{{ j.album_name }}</a> - {{ j.year }} </h3>
{% endif %} </p>
{% endfor %}
{% endif %}
{% if type == "song" %}
<h3>{{i.song_name}}</h3>
<h3><a href="/album/{{i.album.id}}">{{i.album.album_name}}</a></h3>
<p>Artist: <a href="/artist/{{i.artist.id}}">{{i.artist.name}}</a><br>
Year: {{i.album.year}} </p>
{% endif %}
</div>
{% endfor %}
{% endblock %}
\ No newline at end of file
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