cartodb-4.42/app/models/carto/oauth_app_organization.rb
2024-04-06 05:25:13 +00:00

15 lines
556 B
Ruby

module Carto
class OauthAppOrganization < ActiveRecord::Base
belongs_to :organization, inverse_of: :oauth_app_organizations
belongs_to :oauth_app, inverse_of: :oauth_app_organizations
validates :organization, presence: true, uniqueness: { scope: :oauth_app }
validates :oauth_app, presence: true
validates :seats, presence: true, numericality: { only_integer: true, greater_than: 0 }
def open_seats?
oauth_app.oauth_app_users.joins(:user).where(users: { organization_id: organization.id }).count < seats
end
end
end