Fix visibility setting and use the account details when distributing ads
This commit is contained in:
parent
6b599902c0
commit
5ed07abc07
|
@ -513,7 +513,7 @@ class Agora(util.Base):
|
|||
return (min_amount, max_amount)
|
||||
|
||||
@util.handle_exceptions
|
||||
def create_ad(self, asset, countrycode, currency, provider, payment_details, visible=True, edit=False, ad_id=None):
|
||||
def create_ad(self, asset, countrycode, currency, provider, payment_details, visible=None, edit=False, ad_id=None):
|
||||
"""
|
||||
Post an ad with the given asset in a country with a given currency.
|
||||
Convert the min and max amounts from settings to the given currency with CurrencyRates.
|
||||
|
@ -546,8 +546,11 @@ class Agora(util.Base):
|
|||
"require_trusted_by_advertiser": False,
|
||||
"online_provider": provider,
|
||||
"payment_method_details": settings.Agora.PaymentMethodDetails,
|
||||
"visible": visible,
|
||||
}
|
||||
if visible is False:
|
||||
form["visible"] = False
|
||||
elif visible is True:
|
||||
form["visible"] = False
|
||||
if payment_details:
|
||||
form["account_info"] = payment_details_text
|
||||
form["msg"] = ad_text
|
||||
|
@ -569,16 +572,18 @@ class Agora(util.Base):
|
|||
"""
|
||||
dist_list = list(self.markets.create_distribution_list(filter_asset))
|
||||
our_ads = self.enum_ads()
|
||||
supported_currencies, account_info = self.markets.get_valid_account_details()
|
||||
# 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]
|
||||
for asset, countrycode, currency, provider in dist_list:
|
||||
if (asset, countrycode, currency, provider) not in our_ads:
|
||||
# Create the actual ad and pass in all the stuff
|
||||
rtrn = self.create_ad(asset, countrycode, currency, provider)
|
||||
# Bail on first error, let's not continue
|
||||
if rtrn is False:
|
||||
return False
|
||||
yield rtrn
|
||||
if currency in supported_currencies:
|
||||
# Create the actual ad and pass in all the stuff
|
||||
rtrn = self.create_ad(asset, countrycode, currency, provider, payment_details=account_info[currency])
|
||||
# Bail on first error, let's not continue
|
||||
if rtrn is False:
|
||||
return False
|
||||
yield rtrn
|
||||
|
||||
def redist_countries(self):
|
||||
"""
|
||||
|
@ -590,12 +595,14 @@ class Agora(util.Base):
|
|||
:rtype: bool or dict
|
||||
"""
|
||||
our_ads = self.enum_ads()
|
||||
supported_currencies, account_info = self.markets.get_valid_account_details()
|
||||
for asset, ad_id, countrycode, currency, provider in our_ads:
|
||||
rtrn = self.create_ad(asset, countrycode, currency, provider, edit=True, ad_id=ad_id)
|
||||
# Bail on first error, let's not continue
|
||||
if rtrn is False:
|
||||
return False
|
||||
yield (rtrn, ad_id)
|
||||
if currency in supported_currencies:
|
||||
rtrn = self.create_ad(asset, countrycode, currency, provider, edit=True, ad_id=ad_id)
|
||||
# Bail on first error, let's not continue
|
||||
if rtrn is False:
|
||||
return False
|
||||
yield (rtrn, ad_id)
|
||||
|
||||
@util.handle_exceptions
|
||||
def strip_duplicate_ads(self):
|
||||
|
|
Loading…
Reference in New Issue