Merge pull request #4107 from tomhughes/diary-visibility

Allow administrators to see deleted diary entries
This commit is contained in:
Andy Allan 2023-08-02 14:47:05 +01:00 committed by GitHub
commit 9619e699e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 10 deletions

View file

@ -56,7 +56,7 @@ class Ability
can [:account, :go_public], User
if user.moderator?
can [:hide, :hidecomment], DiaryEntry
can [:hide, :unhide, :hidecomment, :unhidecomment], DiaryEntry
can [:index, :show, :resolve, :ignore, :reopen], Issue
can :create, IssueComment
can [:new, :create, :edit, :update, :destroy], Redaction

View file

@ -62,7 +62,9 @@ class DiaryEntriesController < ApplicationController
end
def show
@entry = @user.diary_entries.visible.where(:id => params[:id]).first
entries = @user.diary_entries
entries = entries.visible unless can? :unhide, DiaryEntry
@entry = entries.where(:id => params[:id]).first
if @entry
@title = t ".title", :user => params[:display_name], :title => @entry.title
@comments = can?(:unhidecomment, DiaryEntry) ? @entry.comments : @entry.visible_comments