]> git.openstreetmap.org Git - rails.git/blob - app/controllers/old_relation_controller.rb
Forgot that /history can also be called without a bbox (if one can't be found)
[rails.git] / app / controllers / old_relation_controller.rb
1 class OldRelationController < ApplicationController
2   require 'xml/libxml'
3
4   before_filter :check_api_readable
5   after_filter :compress_output
6   around_filter :api_call_handle_error, :api_call_timeout
7
8   def history
9     relation = Relation.find(params[:id])
10     doc = OSM::API.new.get_xml_doc
11     
12     relation.old_relations.each do |old_relation|
13       doc.root << old_relation.to_xml_node
14     end
15     
16     render :text => doc.to_s, :content_type => "text/xml"
17   end
18   
19   def version
20     old_relation = OldRelation.find(:first, :conditions => {:id => params[:id], :version => params[:version]} )
21     if old_relation.nil?
22       # (RecordNotFound is not raised with find :first...)
23       render :nothing => true, :status => :not_found
24       return
25     end
26     
27     response.headers['Last-Modified'] = old_relation.timestamp.rfc822
28     
29     doc = OSM::API.new.get_xml_doc
30     doc.root << old_relation.to_xml_node
31     
32     render :text => doc.to_s, :content_type => "text/xml"
33   end
34 end