From 6c235732e2da0b1b558ca2838f5c48e81073e0fe Mon Sep 17 00:00:00 2001 From: Remy Date: Sun, 7 Aug 2011 12:33:41 -0700 Subject: [PATCH] Modified base.html to include album search --- data/interfaces/default/base.html | 6 +++++- data/interfaces/default/upcoming.html | 30 +++++++++++++++++++++++++-- headphones/webserve.py | 30 ++++++--------------------- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/data/interfaces/default/base.html b/data/interfaces/default/base.html index f9cea722..dc89306c 100755 --- a/data/interfaces/default/base.html +++ b/data/interfaces/default/base.html @@ -51,7 +51,11 @@
diff --git a/data/interfaces/default/upcoming.html b/data/interfaces/default/upcoming.html index 4eb45d72..086d8c6f 100644 --- a/data/interfaces/default/upcoming.html +++ b/data/interfaces/default/upcoming.html @@ -6,6 +6,7 @@ + Artist Album Name Release Date Release Type @@ -16,10 +17,11 @@ %for album in upcoming: + ${album['ArtistName']} ${album['AlbumTitle']} ${album['ReleaseDate']} - - + ${album['Type']} + ${album['Status']} %endfor @@ -28,6 +30,30 @@

Wanted Albums

+ + + + + + + + + + + + + %for album in wanted: + + + + + + + + + %endfor + +
ArtistAlbum NameRelease DateRelease TypeStatus
${album['ArtistName']}${album['AlbumTitle']}${album['ReleaseDate']}${album['Type']}${album['Status']}
diff --git a/headphones/webserve.py b/headphones/webserve.py index 887354fb..a812b1a9 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -55,29 +55,14 @@ class WebInterface(object): albumPage.exposed = True - def findArtist(self, name): + def search(self, name, type): - page = [templates._header] - page.append(templates._logobar) - page.append(templates._nav) - if len(name) == 0 or name == 'Add an artist': + if len(name) == 0: raise cherrypy.HTTPRedirect("home") + if type == 'artist': + searchresults = mb.findArtist(name, limit=10) else: - artistResults = mb.findArtist(name, limit=10) - if not artistResults: - logger.info(u"No results found for " + name) - page.append('''

No results! Go back

''') - return page - elif len(artistResults) > 1: - page.append('''

Search returned multiple artists. Click the artist you want to add:

''') - for result in artistResults: - page.append('''

%s (more info)

''' % (result['id'], result['uniquename'], result['id'])) - page.append('''
''') - return page - else: - for result in artistResults: - logger.info(u"Found one artist matching your search term: " + result['name'] +" ("+ result['id']+")") - raise cherrypy.HTTPRedirect("addArtist?artistid=%s" % result['id']) + searchresults = mb.findRelease(name, limit=10) findArtist.exposed = True @@ -164,8 +149,7 @@ class WebInterface(object): deleteArtist.exposed = True def refreshArtist(self, ArtistID): - import importer - importer.addArtisttoDB(artistid) + importer.addArtisttoDB(ArtistID) refreshArtist.exposed=True def markAlbums(self, ArtistID=None, action=None, **args): @@ -175,7 +159,6 @@ class WebInterface(object): newValueDict = {'Status': action} myDB.upsert("albums", newValueDict, controlValueDict) if action == 'Wanted': - import searcher searcher.searchNZB(mbid, new=False) raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID) markAlbums.exposed = True @@ -187,7 +170,6 @@ class WebInterface(object): controlValueDict = {'AlbumID': AlbumID} newValueDict = {'Status': 'Wanted'} myDB.upsert("albums", newValueDict, controlValueDict) - import searcher searcher.searchNZB(AlbumID, new) raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID) queueAlbum.exposed = True