1 class NotesController < ApplicationController
2 layout "site", :only => [:mine]
4 before_action :check_api_readable
5 before_action :authorize_web
9 before_action :set_locale
10 around_action :api_call_handle_error, :api_call_timeout
13 # Display a list of notes by a specified user
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
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
27 @title = t "users.no_such_user.title"
28 @not_found_user = params[:display_name]
30 render :template => "users/no_such_user", :status => :not_found