Browse Source

Create redirects for merged/deleted candidates so old URLs still work

tags/last-sinatra-version
Adrian Short 10 years ago
parent
commit
7cc3641b0e
2 changed files with 11 additions and 0 deletions
  1. +4
    -0
      app.rb
  2. +7
    -0
      models.rb

+ 4
- 0
app.rb View File

@@ -185,6 +185,10 @@ end
# end

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])
@candidacies = repository(:default).adapter.select("
SELECT


+ 7
- 0
models.rb View File

@@ -86,6 +86,13 @@ class Candidate
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
include DataMapper::Resource



Loading…
Cancel
Save