1 class NotesController < ApplicationController
6 before_action :check_api_readable
7 before_action :authorize_web
8 before_action :require_oauth
12 before_action :lookup_user, :only => [:index]
13 before_action :set_locale
14 around_action :web_timeout
17 # Display a list of notes by a specified user
19 param! :page, Integer, :min => 1
21 @params = params.permit(:display_name, :status)
22 @title = t ".title", :user => @user.display_name
23 @page = (params[:page] || 1).to_i
26 @notes = @notes.visible unless current_user&.moderator?
27 @notes = @notes.where(:status => params[:status]) unless params[:status] == "all" || params[:status].blank?
28 @notes = @notes.order("updated_at DESC, id").distinct.offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author)
30 render :layout => "site"
36 if current_user&.moderator?
37 @note = Note.find(params[:id])
38 @note_comments = @note.comments.unscope(:where => :visible)
40 @note = Note.visible.find(params[:id])
41 @note_comments = @note.comments
43 rescue ActiveRecord::RecordNotFound
44 render :template => "browse/not_found", :status => :not_found
48 render :action => :new_readonly if api_status != "online"