]> git.openstreetmap.org Git - rails.git/blob - app/controllers/browse_controller.rb
Add a couple of notes to the vagrant instructions
[rails.git] / app / controllers / browse_controller.rb
1 class BrowseController < ApplicationController
2   layout :map_layout
3
4   before_action :authorize_web
5   before_action :set_locale
6   before_action :except => [:query] { |c| c.check_database_readable(true) }
7   before_action :require_oauth
8   around_action :web_timeout
9
10   def relation
11     @type = "relation"
12     @feature = Relation.find(params[:id])
13     render "feature"
14   rescue ActiveRecord::RecordNotFound
15     render :action => "not_found", :status => :not_found
16   end
17
18   def relation_history
19     @type = "relation"
20     @feature = Relation.find(params[:id])
21     render "history"
22   rescue ActiveRecord::RecordNotFound
23     render :action => "not_found", :status => :not_found
24   end
25
26   def way
27     @type = "way"
28     @feature = Way.preload(:way_tags, :containing_relation_members, :changeset => :user, :nodes => [:node_tags, :ways => :way_tags]).find(params[:id])
29     render "feature"
30   rescue ActiveRecord::RecordNotFound
31     render :action => "not_found", :status => :not_found
32   end
33
34   def way_history
35     @type = "way"
36     @feature = Way.preload(:way_tags, :old_ways => { :changeset => :user }).find(params[:id])
37     render "history"
38   rescue ActiveRecord::RecordNotFound
39     render :action => "not_found", :status => :not_found
40   end
41
42   def node
43     @type = "node"
44     @feature = Node.find(params[:id])
45     render "feature"
46   rescue ActiveRecord::RecordNotFound
47     render :action => "not_found", :status => :not_found
48   end
49
50   def node_history
51     @type = "node"
52     @feature = Node.find(params[:id])
53     render "history"
54   rescue ActiveRecord::RecordNotFound
55     render :action => "not_found", :status => :not_found
56   end
57
58   def changeset
59     @type = "changeset"
60     @changeset = Changeset.find(params[:id])
61     @comments = if @user && @user.moderator?
62                   @changeset.comments.unscope(:where => :visible).includes(:author)
63                 else
64                   @changeset.comments.includes(:author)
65                 end
66     @node_pages, @nodes = paginate(:old_nodes, :conditions => { :changeset_id => @changeset.id }, :per_page => 20, :parameter => "node_page")
67     @way_pages, @ways = paginate(:old_ways, :conditions => { :changeset_id => @changeset.id }, :per_page => 20, :parameter => "way_page")
68     @relation_pages, @relations = paginate(:old_relations, :conditions => { :changeset_id => @changeset.id }, :per_page => 20, :parameter => "relation_page")
69     if @changeset.user.data_public?
70       @next_by_user = @changeset.user.changesets.where("id > ?", @changeset.id).reorder(:id => :asc).first
71       @prev_by_user = @changeset.user.changesets.where("id < ?", @changeset.id).reorder(:id => :desc).first
72     end
73   rescue ActiveRecord::RecordNotFound
74     render :action => "not_found", :status => :not_found
75   end
76
77   def note
78     @type = "note"
79
80     if @user && @user.moderator?
81       @note = Note.find(params[:id])
82       @note_comments = @note.comments.unscope(:where => :visible)
83     else
84       @note = Note.visible.find(params[:id])
85       @note_comments = @note.comments
86     end
87   rescue ActiveRecord::RecordNotFound
88     render :action => "not_found", :status => :not_found
89   end
90 end