| @@ -185,6 +185,10 @@ end | |||||
| # end | # end | ||||
| get '/candidates/:id/?' do | get '/candidates/:id/?' do | ||||
| if @deleted_candidate = DeletedCandidate.get(params[:id]) | |||||
| redirect "/candidates/#{@deleted_candidate.candidate_id}", 301 # HTTP 301 Moved Permanently | |||||
| end | |||||
| if @candidate = Candidate.get(params[:id]) | if @candidate = Candidate.get(params[:id]) | ||||
| @candidacies = repository(:default).adapter.select(" | @candidacies = repository(:default).adapter.select(" | ||||
| SELECT | SELECT | ||||
| @@ -86,6 +86,13 @@ class Candidate | |||||
| end | end | ||||
| end | end | ||||
| class DeletedCandidate | |||||
| include DataMapper::Resource | |||||
| property :old_candidate_id, Integer, :key => true # ID of candidate that has been merged/deleted | |||||
| property :candidate_id, Integer, :required => true # ID of candidate that has been kept | |||||
| end | |||||
| class Candidacy | class Candidacy | ||||
| include DataMapper::Resource | include DataMapper::Resource | ||||