mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 20:47:07 +08:00
1f7e5e8e75
In #20135 we prevented invalid inputs from being accepted in category setting form fields on the front-end. We didn't do anything on the back-end at that time, because we were still discussing which path we wanted to take. Eventually we decided we want to move this to a new CategorySetting model. This PR moves the num_auto_bump_daily from custom fields to the new CategorySetting model. In addition it sets the default value to 0, which exhibits the same behaviour as when the value is NULL.
37 lines
1.0 KiB
Ruby
37 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class CategorySetting < ActiveRecord::Base
|
|
belongs_to :category
|
|
|
|
validates :num_auto_bump_daily,
|
|
numericality: {
|
|
only_integer: true,
|
|
greater_than_or_equal_to: 0,
|
|
allow_nil: true,
|
|
}
|
|
|
|
validates :auto_bump_cooldown_days,
|
|
numericality: {
|
|
only_integer: true,
|
|
greater_than_or_equal_to: 0,
|
|
allow_nil: true,
|
|
}
|
|
end
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: category_settings
|
|
#
|
|
# id :bigint not null, primary key
|
|
# category_id :bigint not null
|
|
# require_topic_approval :boolean
|
|
# require_reply_approval :boolean
|
|
# num_auto_bump_daily :integer default(0)
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# auto_bump_cooldown_days :integer default(1)
|
|
# Indexes
|
|
#
|
|
# index_category_settings_on_category_id (category_id) UNIQUE
|
|
#
|