1 class NotesController < ApplicationController
6 before_action :check_api_readable
7 before_action :authorize_web
8 before_action :require_oauth
12 before_action :set_locale
13 around_action :web_timeout
16 # Display a list of notes by a specified user
18 if params[:display_name]
19 if @user = User.active.find_by(:display_name => params[:display_name])
20 @params = params.permit(:display_name)
21 @title = t ".title", :user => @user.display_name
22 @page = (params[:page] || 1).to_i
25 @notes = @notes.visible unless current_user&.moderator?
26 @notes = @notes.order("updated_at DESC, id").distinct.offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author)
28 render :layout => "site"
30 @title = t "users.no_such_user.title"
31 @not_found_user = params[:display_name]
33 render :template => "users/no_such_user", :status => :not_found, :layout => "site"
41 if current_user&.moderator?
42 @note = Note.find(params[:id])
43 @note_comments = @note.comments.unscope(:where => :visible)
45 @note = Note.visible.find(params[:id])
46 @note_comments = @note.comments
48 rescue ActiveRecord::RecordNotFound
49 render :template => "browse/not_found", :status => :not_found