Fix visibility setting and use the account details when distributing ads

master
Mark Veidemanis 3 years ago
parent 6b599902c0
commit 5ed07abc07
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -513,7 +513,7 @@ class Agora(util.Base):
return (min_amount, max_amount) return (min_amount, max_amount)
@util.handle_exceptions @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. 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. 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, "require_trusted_by_advertiser": False,
"online_provider": provider, "online_provider": provider,
"payment_method_details": settings.Agora.PaymentMethodDetails, "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: if payment_details:
form["account_info"] = payment_details_text form["account_info"] = payment_details_text
form["msg"] = ad_text form["msg"] = ad_text
@ -569,16 +572,18 @@ class Agora(util.Base):
""" """
dist_list = list(self.markets.create_distribution_list(filter_asset)) dist_list = list(self.markets.create_distribution_list(filter_asset))
our_ads = self.enum_ads() 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 # 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]
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:
# Create the actual ad and pass in all the stuff if currency in supported_currencies:
rtrn = self.create_ad(asset, countrycode, currency, provider) # Create the actual ad and pass in all the stuff
# Bail on first error, let's not continue rtrn = self.create_ad(asset, countrycode, currency, provider, payment_details=account_info[currency])
if rtrn is False: # Bail on first error, let's not continue
return False if rtrn is False:
yield rtrn return False
yield rtrn
def redist_countries(self): def redist_countries(self):
""" """
@ -590,12 +595,14 @@ class Agora(util.Base):
:rtype: bool or dict :rtype: bool or dict
""" """
our_ads = self.enum_ads() 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: for asset, ad_id, countrycode, currency, provider in our_ads:
rtrn = self.create_ad(asset, countrycode, currency, provider, edit=True, ad_id=ad_id) if currency in supported_currencies:
# Bail on first error, let's not continue rtrn = self.create_ad(asset, countrycode, currency, provider, edit=True, ad_id=ad_id)
if rtrn is False: # Bail on first error, let's not continue
return False if rtrn is False:
yield (rtrn, ad_id) return False
yield (rtrn, ad_id)
@util.handle_exceptions @util.handle_exceptions
def strip_duplicate_ads(self): def strip_duplicate_ads(self):

Loading…
Cancel
Save