Commit 6c1efd64 authored by Gink's avatar Gink

Beta version of search page, no link yet just type /search/<term>

parent eacd23d2
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,11 @@ class EditProfile(UpdateView):
slug_field = 'username'
slug_url_kwarg = 'slug'
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)
......
......@@ -104,6 +104,10 @@ body {
margin-top: 2vh;
}
.a {
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,9 @@ 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'^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')
]
......@@ -22,9 +22,8 @@
<li style="float:right"><button class="nav_bar_tab"type="button" onclick="toggleWallpaper()"></button></li>
</ul>
{% endif %}
</header>
<main>
<div class="boxified sidebar">
{% block sidebar %}
<h2>Featured Songs</h2>
<img src="/files/images/divide_edsheeran.jpeg" alt="Divide - Ed Sheeran">
Divide - Ed Sheeran
......@@ -32,10 +31,12 @@
Palette - IU
<img src="/files/images/rockstar_postmalone21savage.jpeg" alt="Rockstar">
Rockstar
{% endblock %}
</div>
</header>
{% 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 </h2>
<p>
You searched for '{{term}}' <br>
Found {{results.count}} results <br>
Source: Local
{% endblock %}
{% block content %}
{% for i in results %}
<div class = "boxified main">
<h3> {{i.album_name}} </h3>
<p> Artist: {{i.artist.name}} <br>
Year: {{i.year}} </p>
</div>
{% endfor %}
{% endblock %}
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