Merge remote-tracking branch 'parent/main' into upstream-20230103
This commit is contained in:
commit
7356f776f2
60 changed files with 1349 additions and 323 deletions
|
@ -28,8 +28,8 @@ class Announcement < ApplicationRecord
|
|||
has_many :announcement_reactions, dependent: :destroy
|
||||
|
||||
validates :text, presence: true
|
||||
validates :starts_at, presence: true, if: -> { ends_at.present? }
|
||||
validates :ends_at, presence: true, if: -> { starts_at.present? }
|
||||
validates :starts_at, presence: true, if: :ends_at?
|
||||
validates :ends_at, presence: true, if: :starts_at?
|
||||
|
||||
before_validation :set_published, on: :create
|
||||
|
||||
|
@ -46,7 +46,7 @@ class Announcement < ApplicationRecord
|
|||
end
|
||||
|
||||
def time_range?
|
||||
starts_at.present? && ends_at.present?
|
||||
starts_at? && ends_at?
|
||||
end
|
||||
|
||||
def mentions
|
||||
|
|
|
@ -46,7 +46,7 @@ module Remotable
|
|||
public_send(:"download_#{attachment_name}!", url) if download_on_assign
|
||||
end
|
||||
|
||||
alias_method(:"reset_#{attachment_name}!", "download_#{attachment_name}!")
|
||||
alias_method(:"reset_#{attachment_name}!", :"download_#{attachment_name}!")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,8 +20,23 @@
|
|||
class CustomFilter < ApplicationRecord
|
||||
self.ignored_columns += %w(whole_word irreversible)
|
||||
|
||||
alias_attribute :title, :phrase
|
||||
alias_attribute :filter_action, :action
|
||||
# NOTE: We previously used `alias_attribute` but this does not play nicely
|
||||
# with cache
|
||||
def title
|
||||
phrase
|
||||
end
|
||||
|
||||
def title=(value)
|
||||
self.phrase = value
|
||||
end
|
||||
|
||||
def filter_action
|
||||
action
|
||||
end
|
||||
|
||||
def filter_action=(value)
|
||||
self.action = value
|
||||
end
|
||||
|
||||
VALID_CONTEXTS = %w(
|
||||
home
|
||||
|
|
|
@ -17,7 +17,15 @@ class CustomFilterKeyword < ApplicationRecord
|
|||
|
||||
validates :keyword, presence: true
|
||||
|
||||
alias_attribute :phrase, :keyword
|
||||
# NOTE: We previously used `alias_attribute` but this does not play nicely
|
||||
# with cache
|
||||
def phrase
|
||||
keyword
|
||||
end
|
||||
|
||||
def phrase=(value)
|
||||
self.keyword = value
|
||||
end
|
||||
|
||||
before_save :prepare_cache_invalidation!
|
||||
before_destroy :prepare_cache_invalidation!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue