1 class NotesController < ApplicationController
4 before_action :check_api_readable
5 before_action :authorize_web
6 before_action :require_oauth
10 before_action :set_locale
11 around_action :web_timeout
14 # Display a list of notes by a specified user
16 if params[:display_name]
17 if @user = User.active.find_by(:display_name => params[:display_name])
18 @params = params.permit(:display_name)
19 @title = t ".title", :user => @user.display_name
20 @page = (params[:page] || 1).to_i
23 @notes = @notes.visible unless current_user&.moderator?
24 @notes = @notes.order("updated_at DESC, id").distinct.offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author)
26 render :layout => "site"
28 @title = t "users.no_such_user.title"
29 @not_found_user = params[:display_name]
31 render :template => "users/no_such_user", :status => :not_found, :layout => "site"
39 if current_user&.moderator?
40 @note = Note.find(params[:id])
41 @note_comments = @note.comments.unscope(:where => :visible)
43 @note = Note.visible.find(params[:id])
44 @note_comments = @note.comments
46 rescue ActiveRecord::RecordNotFound
47 render :template => "browse/not_found", :status => :not_found