]> git.openstreetmap.org Git - rails.git/blob - app/controllers/notes_controller.rb
Move the api trace methods into a separate controller under the api namespace
[rails.git] / app / controllers / notes_controller.rb
1 class NotesController < ApplicationController
2   layout "site", :only => [:mine]
3
4   before_action :check_api_readable
5   before_action :authorize_web
6
7   authorize_resource
8
9   before_action :set_locale
10   around_action :api_call_handle_error, :api_call_timeout
11
12   ##
13   # Display a list of notes by a specified user
14   def mine
15     if params[:display_name]
16       if @user = User.active.find_by(:display_name => params[:display_name])
17         @params = params.permit(:display_name)
18         @title = t "notes.mine.title", :user => @user.display_name
19         @heading = t "notes.mine.heading", :user => @user.display_name
20         @description = t "notes.mine.subheading", :user => render_to_string(:partial => "user", :object => @user)
21         @page = (params[:page] || 1).to_i
22         @page_size = 10
23         @notes = @user.notes
24         @notes = @notes.visible unless current_user&.moderator?
25         @notes = @notes.order("updated_at DESC, id").distinct.offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author).to_a
26       else
27         @title = t "users.no_such_user.title"
28         @not_found_user = params[:display_name]
29
30         render :template => "users/no_such_user", :status => :not_found
31       end
32     end
33   end
34 end