mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 09:51:24 +00:00
Add to_label to preset warning model
This commit is contained in:
parent
18a045e221
commit
63b79c302c
|
@ -12,7 +12,15 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
class AccountWarningPreset < ApplicationRecord
|
class AccountWarningPreset < ApplicationRecord
|
||||||
|
LABEL_TEXT_LENGTH = 30
|
||||||
|
|
||||||
validates :text, presence: true
|
validates :text, presence: true
|
||||||
|
|
||||||
scope :alphabetic, -> { order(title: :asc, text: :asc) }
|
scope :alphabetic, -> { order(title: :asc, text: :asc) }
|
||||||
|
|
||||||
|
def to_label
|
||||||
|
[title.presence, text.to_s.truncate(LABEL_TEXT_LENGTH)]
|
||||||
|
.compact
|
||||||
|
.join(' - ')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user