1
0
Fork 0

Bad artist name error fix. showing 404

This commit is contained in:
magnolia-fan 2011-04-13 17:40:24 +04:00
parent 970400cb74
commit 07920d2b79
1 changed files with 27 additions and 20 deletions

View File

@ -2,34 +2,41 @@
class ArtistController < ApplicationController class ArtistController < ApplicationController
require 'open-uri' require 'open-uri'
def view def view
# Dirty auth block START
unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id'] unless request.session['session_id'].nil? or MainController.logged_in request.session['session_id']
redirect_to '/login' redirect_to '/login'
return
else else
if request.session['session_id'].nil? if request.session['session_id'].nil?
redirect_to '/login' redirect_to '/login'
return
end end
end end
# Dirty auth block END
if params[:name].nil? if params[:name].nil?
name = '' name = ''
else else
if request.request_method == 'POST' if request.request_method == 'POST'
redirect_to :action => 'view', :name => params[:name].gsub(' ', '+') redirect_to :action => 'view', :name => params[:name].gsub(' ', '+')
end end
name = params[:name].gsub('+', ' ') name = params[:name].gsub('+', ' ')
end end
@artist = Artist.getByName(name) @artist = Artist.getByName(name)
@albums = [] if @artist.nil?
@artist.albums.each do |album| render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
unless album.releases.empty? else
tracks = album.tracksInDb() @albums = []
@albums << { @artist.albums.each do |album|
:object => album, unless album.releases.empty?
:tracks => tracks tracks = album.tracksInDb()
} @albums << {
end :object => album,
end :tracks => tracks
end }
end
end
end
end
def autocomplete def autocomplete
autocomplete = Artist.getLastFmAutocomplete(params[:query]) autocomplete = Artist.getLastFmAutocomplete(params[:query])
return render :nothing => true if autocomplete.nil? return render :nothing => true if autocomplete.nil?