0
0
Fork 0

Limit users to 50 lists, remove pagination from lists API (#5933)

This commit is contained in:
Eugen Rochko 2017-12-09 01:32:29 +01:00 committed by GitHub
parent f08e6e9ab5
commit 2f4c5f504f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 42 deletions

View file

@ -13,6 +13,8 @@
class List < ApplicationRecord
include Paginable
PER_ACCOUNT_LIMIT = 50
belongs_to :account
has_many :list_accounts, inverse_of: :list, dependent: :destroy
@ -20,6 +22,10 @@ class List < ApplicationRecord
validates :title, presence: true
validates_each :account_id, on: :create do |record, _attr, value|
record.errors.add(:base, I18n.t('lists.errors.limit')) if List.where(account_id: value).count >= PER_ACCOUNT_LIMIT
end
before_destroy :clean_feed_manager
private