|
|
@ -551,7 +551,7 @@ class Local(util.Base):
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if self.platform == "agora":
|
|
|
|
if self.platform == "agora":
|
|
|
|
form["asset"] = asset
|
|
|
|
form["asset"] = asset
|
|
|
|
form["payment_method_details"] = (settings.Platform.PaymentMethodDetails,)
|
|
|
|
form["payment_method_details"] = settings.Platform.PaymentMethodDetails
|
|
|
|
form["online_provider"] = provider
|
|
|
|
form["online_provider"] = provider
|
|
|
|
elif self.platform == "lbtc":
|
|
|
|
elif self.platform == "lbtc":
|
|
|
|
form["online_provider"] = self.map_provider(provider, reverse=True)
|
|
|
|
form["online_provider"] = self.map_provider(provider, reverse=True)
|
|
|
@ -567,14 +567,13 @@ class Local(util.Base):
|
|
|
|
form["max_amount"] = round(max_amount, 2)
|
|
|
|
form["max_amount"] = round(max_amount, 2)
|
|
|
|
if self.platform == "lbtc":
|
|
|
|
if self.platform == "lbtc":
|
|
|
|
form["bank_name"] = bank_name
|
|
|
|
form["bank_name"] = bank_name
|
|
|
|
|
|
|
|
|
|
|
|
if edit:
|
|
|
|
if edit:
|
|
|
|
ad = self.api.ad(ad_id=ad_id, **form)
|
|
|
|
ad = yield self.api.ad(ad_id=ad_id, **form)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
ad = self.api.ad_create(**form)
|
|
|
|
ad = yield self.api.ad_create(**form)
|
|
|
|
return ad
|
|
|
|
return ad
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: make async
|
|
|
|
@inlineCallbacks
|
|
|
|
def dist_countries(self, filter_asset=None):
|
|
|
|
def dist_countries(self, filter_asset=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Distribute our advert into all countries and providers listed in the config.
|
|
|
|
Distribute our advert into all countries and providers listed in the config.
|
|
|
@ -583,18 +582,22 @@ class Local(util.Base):
|
|
|
|
:rtype: bool or dict
|
|
|
|
:rtype: bool or dict
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
dist_list = list(self.markets.create_distribution_list(self.platform, filter_asset))
|
|
|
|
dist_list = list(self.markets.create_distribution_list(self.platform, filter_asset))
|
|
|
|
our_ads = self.enum_ads()
|
|
|
|
our_ads = yield self.enum_ads()
|
|
|
|
(
|
|
|
|
(
|
|
|
|
supported_currencies,
|
|
|
|
supported_currencies,
|
|
|
|
account_info,
|
|
|
|
account_info,
|
|
|
|
) = self.markets.get_valid_account_details(self.platform)
|
|
|
|
) = self.markets.get_valid_account_details(self.platform)
|
|
|
|
# Let's get rid of the ad IDs and make it a tuple like dist_list
|
|
|
|
# Let's get rid of the ad IDs and make it a tuple like dist_list
|
|
|
|
our_ads = [(x[0], x[2], x[3], x[4]) for x in our_ads]
|
|
|
|
our_ads = [(x[0], x[2], x[3], x[4]) for x in our_ads]
|
|
|
|
|
|
|
|
if not our_ads:
|
|
|
|
|
|
|
|
self.log.error("Could not get our ads.")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
to_return = []
|
|
|
|
for asset, countrycode, currency, provider in dist_list:
|
|
|
|
for asset, countrycode, currency, provider in dist_list:
|
|
|
|
if (asset, countrycode, currency, provider) not in our_ads:
|
|
|
|
if (asset, countrycode, currency, provider) not in our_ads:
|
|
|
|
if currency in supported_currencies:
|
|
|
|
if currency in supported_currencies:
|
|
|
|
# Create the actual ad and pass in all the stuff
|
|
|
|
# Create the actual ad and pass in all the stuff
|
|
|
|
rtrn = self.create_ad(
|
|
|
|
rtrn = yield self.create_ad(
|
|
|
|
asset,
|
|
|
|
asset,
|
|
|
|
countrycode,
|
|
|
|
countrycode,
|
|
|
|
currency,
|
|
|
|
currency,
|
|
|
@ -604,9 +607,10 @@ class Local(util.Base):
|
|
|
|
# Bail on first error, let's not continue
|
|
|
|
# Bail on first error, let's not continue
|
|
|
|
if rtrn is False:
|
|
|
|
if rtrn is False:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
yield rtrn
|
|
|
|
to_return.append(rtrn)
|
|
|
|
|
|
|
|
return to_return
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: make async
|
|
|
|
@inlineCallbacks
|
|
|
|
def redist_countries(self):
|
|
|
|
def redist_countries(self):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Redistribute our advert details into all our listed adverts.
|
|
|
|
Redistribute our advert details into all our listed adverts.
|
|
|
@ -616,7 +620,7 @@ class Local(util.Base):
|
|
|
|
:return: False or dict with response
|
|
|
|
:return: False or dict with response
|
|
|
|
:rtype: bool or dict
|
|
|
|
:rtype: bool or dict
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
our_ads = self.enum_ads()
|
|
|
|
our_ads = yield self.enum_ads()
|
|
|
|
(
|
|
|
|
(
|
|
|
|
supported_currencies,
|
|
|
|
supported_currencies,
|
|
|
|
account_info,
|
|
|
|
account_info,
|
|
|
@ -624,9 +628,10 @@ class Local(util.Base):
|
|
|
|
if not our_ads:
|
|
|
|
if not our_ads:
|
|
|
|
self.log.error("Could not get our ads.")
|
|
|
|
self.log.error("Could not get our ads.")
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
to_return = []
|
|
|
|
for asset, ad_id, countrycode, currency, provider in our_ads:
|
|
|
|
for asset, ad_id, countrycode, currency, provider in our_ads:
|
|
|
|
if currency in supported_currencies:
|
|
|
|
if currency in supported_currencies:
|
|
|
|
rtrn = self.create_ad(
|
|
|
|
rtrn = yield self.create_ad(
|
|
|
|
asset,
|
|
|
|
asset,
|
|
|
|
countrycode,
|
|
|
|
countrycode,
|
|
|
|
currency,
|
|
|
|
currency,
|
|
|
@ -638,7 +643,8 @@ class Local(util.Base):
|
|
|
|
# Bail on first error, let's not continue
|
|
|
|
# Bail on first error, let's not continue
|
|
|
|
if rtrn is False:
|
|
|
|
if rtrn is False:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
yield (rtrn, ad_id)
|
|
|
|
to_return.append((rtrn, ad_id))
|
|
|
|
|
|
|
|
return to_return
|
|
|
|
|
|
|
|
|
|
|
|
@inlineCallbacks
|
|
|
|
@inlineCallbacks
|
|
|
|
def strip_duplicate_ads(self):
|
|
|
|
def strip_duplicate_ads(self):
|
|
|
|