CDB-3486 Don't allow organization users to geocode over the org limits unless he has soft_geocoding_limit

pull/614/head
Jose A. Rilla 10 years ago
parent 86cf215800
commit 7a79221584

@ -40,10 +40,12 @@ module Concerns
case action
when :create
[:name, :seats, :quota_in_bytes, :display_name, :description, :website,
:discus_shortname, :twitter_username, :geocoding_quota, :map_view_quota]
:discus_shortname, :twitter_username, :geocoding_quota, :map_view_quota,
:geocoding_block_price, :map_view_block_price]
when :update
[:seats, :quota_in_bytes, :display_name, :description, :website,
:discus_shortname, :twitter_username, :geocoding_quota, :map_view_quota]
:discus_shortname, :twitter_username, :geocoding_quota, :map_view_quota,
:geocoding_block_price, :map_view_block_price]
end
elsif self.is_a?(User)
[:account_type, :admin, :crypted_password, :database_host,

@ -27,6 +27,8 @@ class Organization < Sequel::Model
# @param twitter_username String
# @param geocoding_quota Integer
# @param map_view_quota Integer
# @param geocoding_block_price Integer
# @param map_view_block_price Integer
one_to_many :users
many_to_one :owner, class_name: 'User', key: 'owner_id'
@ -102,13 +104,15 @@ class Organization < Sequel::Model
:avatar_url => self.owner ? self.owner.avatar_url : nil,
:email => self.owner ? self.owner.email : nil
},
:quota_in_bytes => self.quota_in_bytes,
:geocoding_quota => self.geocoding_quota,
:map_view_quota => self.map_view_quota,
:seats => self.seats,
:twitter_username => self.twitter_username,
:updated_at => self.updated_at,
:users => self.users.reject { |item| filtered_user && item.id == filtered_user.id }
:quota_in_bytes => self.quota_in_bytes,
:geocoding_quota => self.geocoding_quota,
:map_view_quota => self.map_view_quota,
:map_view_block_price => self.map_view_block_price,
:geocoding_block_price => self.geocoding_block_price,
:seats => self.seats,
:twitter_username => self.twitter_username,
:updated_at => self.updated_at,
:users => self.users.reject { |item| filtered_user && item.id == filtered_user.id }
.map { |u|
{
:id => u.id,

@ -3,7 +3,7 @@ module CartoDB
def data(options = {})
calls = self.get_api_calls(from: self.last_billing_cycle, to: Date.today)
calls.fill(0, calls.size..29)
data = {
data = {
id: self.id,
email: self.email,
username: self.username,
@ -20,13 +20,13 @@ module CartoDB
remaining_table_quota: self.remaining_table_quota,
remaining_byte_quota: self.remaining_quota.to_f,
api_calls: calls,
api_calls_quota: self.map_view_quota,
api_calls_block_price: self.map_view_block_price,
api_calls_quota: self.organization_user? ? self.organization.map_view_quota : self.map_view_quota,
api_calls_block_price: self.organization_user? ? self.organization.map_view_block_price : self.map_view_block_price,
geocoding: {
quota: self.geocoding_quota,
block_price: self.geocoding_block_price,
monthly_use: self.get_geocoding_calls,
hard_limit: self.hard_geocoding_limit?,
quota: self.organization_user? ? self.organization.geocoding_quota : self.geocoding_quota,
block_price: self.organization_user? ? self.organization.geocoding_block_price : self.geocoding_block_price,
monthly_use: self.organization_user? ? self.organization.get_geocoding_calls : self.get_geocoding_calls,
hard_limit: self.hard_geocoding_limit?
},
billing_period: self.last_billing_cycle,
max_layers: self.max_layers,

@ -0,0 +1,11 @@
Sequel.migration do
up do
add_column :organizations, :geocoding_block_price, :integer
add_column :organizations, :map_view_block_price, :integer
end
down do
remove_column :organizations, :geocoding_block_price
remove_column :organizations, :map_view_block_price
end
end
Loading…
Cancel
Save