Allow users to delete their own diary entries

Fixes #4175
This commit is contained in:
Tom Hughes 2024-02-25 11:02:15 +00:00
parent cf9831c0af
commit 11a59aadfb
8 changed files with 47 additions and 18 deletions

View file

@ -36,6 +36,7 @@ class DiaryEntry < ApplicationRecord
has_many :subscribers, :through => :subscriptions, :source => :user
scope :visible, -> { where(:visible => true) }
scope :visible_to, ->(user) { where(:visible => true).or(where(:user => user)) unless user&.moderator? || user&.administrator? }
validates :title, :presence => true, :length => 1..255, :characters => true
validates :body, :presence => true, :characters => true