Parcourir la source

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

tags/last-sinatra-version
Adrian Short il y a 10 ans
Parent
révision
7cc3641b0e
2 fichiers modifiés avec 11 ajouts et 0 suppressions
  1. +4
    -0
      app.rb
  2. +7
    -0
      models.rb

+ 4
- 0
app.rb Voir le fichier

@@ -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 Voir le fichier

@@ -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



Chargement…
Annuler
Enregistrer