mirror of https://github.com/Siphonay/mastodon
Use previously extracted model constants in form `maxlength` attributes (#32113)
This commit is contained in:
parent
04dd3a9eb6
commit
e02e88bff4
|
@ -73,6 +73,8 @@ class Form::AdminSettings
|
||||||
authorized_fetch: :authorized_fetch_mode?,
|
authorized_fetch: :authorized_fetch_mode?,
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
|
DESCRIPTION_LIMIT = 200
|
||||||
|
|
||||||
attr_accessor(*KEYS)
|
attr_accessor(*KEYS)
|
||||||
|
|
||||||
validates :registrations_mode, inclusion: { in: %w(open approved none) }, if: -> { defined?(@registrations_mode) }
|
validates :registrations_mode, inclusion: { in: %w(open approved none) }, if: -> { defined?(@registrations_mode) }
|
||||||
|
@ -82,7 +84,7 @@ class Form::AdminSettings
|
||||||
validates :show_domain_blocks, inclusion: { in: %w(disabled users all) }, if: -> { defined?(@show_domain_blocks) }
|
validates :show_domain_blocks, inclusion: { in: %w(disabled users all) }, if: -> { defined?(@show_domain_blocks) }
|
||||||
validates :show_domain_blocks_rationale, inclusion: { in: %w(disabled users all) }, if: -> { defined?(@show_domain_blocks_rationale) }
|
validates :show_domain_blocks_rationale, inclusion: { in: %w(disabled users all) }, if: -> { defined?(@show_domain_blocks_rationale) }
|
||||||
validates :media_cache_retention_period, :content_cache_retention_period, :backups_retention_period, numericality: { only_integer: true }, allow_blank: true, if: -> { defined?(@media_cache_retention_period) || defined?(@content_cache_retention_period) || defined?(@backups_retention_period) }
|
validates :media_cache_retention_period, :content_cache_retention_period, :backups_retention_period, numericality: { only_integer: true }, allow_blank: true, if: -> { defined?(@media_cache_retention_period) || defined?(@content_cache_retention_period) || defined?(@backups_retention_period) }
|
||||||
validates :site_short_description, length: { maximum: 200 }, if: -> { defined?(@site_short_description) }
|
validates :site_short_description, length: { maximum: DESCRIPTION_LIMIT }, if: -> { defined?(@site_short_description) }
|
||||||
validates :status_page_url, url: true, allow_blank: true
|
validates :status_page_url, url: true, allow_blank: true
|
||||||
validate :validate_site_uploads
|
validate :validate_site_uploads
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :site_short_description,
|
= f.input :site_short_description,
|
||||||
as: :text,
|
as: :text,
|
||||||
input_html: { rows: 2, maxlength: 200 },
|
input_html: { rows: 2, maxlength: Form::AdminSettings::DESCRIPTION_LIMIT },
|
||||||
wrapper: :with_block_label
|
wrapper: :with_block_label
|
||||||
|
|
||||||
.fields-row
|
.fields-row
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
= f.simple_fields_for :account do |ff|
|
= f.simple_fields_for :account do |ff|
|
||||||
= ff.input :username,
|
= ff.input :username,
|
||||||
append: "@#{site_hostname}",
|
append: "@#{site_hostname}",
|
||||||
input_html: { 'aria-label': t('simple_form.labels.defaults.username'), autocomplete: 'off', placeholder: t('simple_form.labels.defaults.username'), pattern: '[a-zA-Z0-9_]+', maxlength: 30 },
|
input_html: { 'aria-label': t('simple_form.labels.defaults.username'), autocomplete: 'off', placeholder: t('simple_form.labels.defaults.username'), pattern: '[a-zA-Z0-9_]+', maxlength: Account::USERNAME_LENGTH_LIMIT },
|
||||||
label: false,
|
label: false,
|
||||||
required: true,
|
required: true,
|
||||||
wrapper: :with_label
|
wrapper: :with_label
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
|
|
||||||
= simple_form_for(@appeal, url: disputes_strike_appeal_path(@strike)) do |f|
|
= simple_form_for(@appeal, url: disputes_strike_appeal_path(@strike)) do |f|
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :text, wrapper: :with_label, input_html: { maxlength: 500 }
|
= f.input :text, wrapper: :with_label, input_html: { maxlength: Appeal::TEXT_LENGTH_LIMIT }
|
||||||
|
|
||||||
.actions
|
.actions
|
||||||
= f.button :button, t('disputes.strikes.appeals.submit'), type: :submit
|
= f.button :button, t('disputes.strikes.appeals.submit'), type: :submit
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
.fields-row
|
.fields-row
|
||||||
.fields-row__column.fields-row__column-6
|
.fields-row__column.fields-row__column-6
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :display_name, wrapper: :with_block_label, input_html: { maxlength: 30, data: { default: @account.username } }
|
= f.input :display_name, wrapper: :with_block_label, input_html: { maxlength: Account::DISPLAY_NAME_LENGTH_LIMIT, data: { default: @account.username } }
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :note, wrapper: :with_block_label, input_html: { maxlength: 500 }
|
= f.input :note, wrapper: :with_block_label, input_html: { maxlength: Account::NOTE_LENGTH_LIMIT }
|
||||||
|
|
||||||
.fields-row__column.fields-group.fields-row__column-6
|
.fields-row__column.fields-group.fields-row__column-6
|
||||||
.input.with_block_label
|
.input.with_block_label
|
||||||
|
@ -27,8 +27,8 @@
|
||||||
|
|
||||||
= f.simple_fields_for :fields do |fields_f|
|
= f.simple_fields_for :fields do |fields_f|
|
||||||
.row
|
.row
|
||||||
= fields_f.input :name, placeholder: t('simple_form.labels.account.fields.name'), input_html: { maxlength: 255 }
|
= fields_f.input :name, placeholder: t('simple_form.labels.account.fields.name'), input_html: { maxlength: Account::Field::MAX_CHARACTERS_LOCAL }
|
||||||
= fields_f.input :value, placeholder: t('simple_form.labels.account.fields.value'), input_html: { maxlength: 255 }
|
= fields_f.input :value, placeholder: t('simple_form.labels.account.fields.value'), input_html: { maxlength: Account::Field::MAX_CHARACTERS_LOCAL }
|
||||||
|
|
||||||
.fields-row
|
.fields-row
|
||||||
.fields-row__column.fields-row__column-6
|
.fields-row__column.fields-row__column-6
|
||||||
|
|
Loading…
Reference in New Issue