Fixed an issue with redirects to index page

This commit is contained in:
Remy
2011-07-11 02:54:43 -07:00
parent 2d2b5851db
commit 1d701bceb5
2 changed files with 10 additions and 6 deletions

View File

@@ -12,7 +12,7 @@ _header = '''
<div class="container">'''
_logobar = '''
<div class="logo"><a href=""><img src="data/images/headphoneslogo.png" border="0">headphones<a></div>
<div class="logo"><a href="home"><img src="data/images/headphoneslogo.png" border="0">headphones<a></div>
<div class="search"><form action="findArtist" method="GET">
<input type="text" value="Add an artist" onfocus="if
(this.value==this.defaultValue) this.value='';" name="name" />
@@ -20,7 +20,7 @@ _logobar = '''
'''
_nav = '''<div class="nav">
<a href="">HOME</a>
<a href="home">HOME</a>
<a href="upcoming">UPCOMING</a>
<a href="manage">MANAGE</a>
<a href="history">HISTORY</a>

View File

@@ -19,6 +19,10 @@ database = os.path.join(FULL_PATH, 'headphones.db')
class Headphones:
def index(self):
raise cherrypy.HTTPRedirect("home")
index.exposed=True
def home(self):
page = [templates._header]
page.append(templates._logobar)
page.append(templates._nav)
@@ -66,7 +70,7 @@ class Headphones:
else:
page.append("""<div class="datanil">Add some artists to the database!</div>""")
return page
index.exposed = True
home.exposed = True
def artistPage(self, ArtistID):
@@ -158,12 +162,12 @@ class Headphones:
page = [templates._header]
if len(name) == 0 or name == 'Add an artist':
raise cherrypy.HTTPRedirect("/")
raise cherrypy.HTTPRedirect("home")
else:
artistResults = ws.Query().getArtists(ws.ArtistFilter(string.replace(name, '&', '%38'), limit=8))
if len(artistResults) == 0:
logger.log(u"No results found for " + name)
page.append('''No results!<a class="blue" href="">Go back</a>''')
page.append('''No results!<a class="blue" href="home">Go back</a>''')
return page
elif len(artistResults) > 1:
page.append('''Search returned multiple artists. Click the artist you want to add:<br /><br />''')
@@ -200,7 +204,7 @@ class Headphones:
artistlist = c.fetchall()
if any(artistid in x for x in artistlist):
page = [templates._header]
page.append('''%s has already been added. Go <a href="">back</a>.''' % artist.name)
page.append('''%s has already been added. Go <a href="home">back</a>.''' % artist.name)
logger.log(artist.name + u" is already in the database!", logger.WARNING)
c.close()
return page