Implement nuking ads
This commit is contained in:
parent
bf65d028f1
commit
7f088d15c2
|
@ -20,7 +20,7 @@ from django.contrib.auth.views import LogoutView
|
|||
from django.urls import include, path
|
||||
from two_factor.urls import urlpatterns as tf_urls
|
||||
|
||||
from core.views import ads, aggregators, banks, base, notifications, platforms
|
||||
from core.views import aggregators, banks, base, notifications, platforms, ads
|
||||
|
||||
# from core.views.stripe_callbacks import Callback
|
||||
|
||||
|
@ -175,6 +175,11 @@ urlpatterns = [
|
|||
ads.AdDist.as_view(),
|
||||
name="ad_dist",
|
||||
),
|
||||
path(
|
||||
"ops/ads/nuke/",
|
||||
ads.AdNuke.as_view(),
|
||||
name="ad_nuke",
|
||||
),
|
||||
path(
|
||||
"ops/ads/redist/",
|
||||
ads.AdRedist.as_view(),
|
||||
|
|
|
@ -667,14 +667,17 @@ class LocalPlatformClient(ABC):
|
|||
account_info,
|
||||
) = self.get_valid_account_details(ad)
|
||||
# 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]
|
||||
if not our_ads:
|
||||
log.error("Could not get our ads.")
|
||||
if our_ads in [None, False]:
|
||||
log.error("Could not get our ads")
|
||||
return False
|
||||
our_ads = [(x[0], x[2], x[3], x[4]) for x in our_ads]
|
||||
|
||||
to_return = []
|
||||
for asset, countrycode, currency, provider in dist_list:
|
||||
if (asset, countrycode, currency, provider) not in our_ads:
|
||||
if currency in supported_currencies:
|
||||
if currency not in account_info:
|
||||
continue
|
||||
# Create the actual ad and pass in all the stuff
|
||||
rtrn = await self.create_ad(
|
||||
asset,
|
||||
|
|
|
@ -14,7 +14,8 @@ class ContactDataAd(BaseModel):
|
|||
trade_type: str
|
||||
advertiser: ContactDataBuyerSeller
|
||||
asset: str
|
||||
id: str
|
||||
id: str | None
|
||||
contact_id: str | None
|
||||
|
||||
|
||||
class ContactData(BaseModel):
|
||||
|
@ -51,8 +52,8 @@ class ContactData(BaseModel):
|
|||
|
||||
|
||||
class ContactActions(BaseModel):
|
||||
advertisement_public_view: str
|
||||
advertisement_url: str
|
||||
advertisement_public_view: str | None
|
||||
advertisement_url: str | None
|
||||
message_post_url: str
|
||||
messages_url: str
|
||||
release_url: str
|
||||
|
|
|
@ -17,6 +17,18 @@ from core.models import Ad
|
|||
from core.util import logs
|
||||
from core.views.helpers import synchronize_async_helper
|
||||
|
||||
class AdNuke(LoginRequiredMixin, OTPRequiredMixin, View):
|
||||
template_name = "mixins/partials/notify.html"
|
||||
|
||||
def get(self, request):
|
||||
ads = Ad.objects.filter(user=request.user, enabled=True)
|
||||
for ad in ads:
|
||||
for platform in ad.platforms.all():
|
||||
run = synchronize_async_helper(AgoraClient(platform))
|
||||
synchronize_async_helper(run.nuke_ads())
|
||||
|
||||
context = {"class": "success", "message": "Nuking ads"}
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
class AdDist(LoginRequiredMixin, OTPRequiredMixin, View):
|
||||
template_name = "mixins/partials/notify.html"
|
||||
|
@ -73,6 +85,13 @@ class AdList(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
|
|||
"label": "Update ads",
|
||||
"icon": "fa-solid fa-refresh",
|
||||
},
|
||||
{
|
||||
"url": reverse("ad_nuke"),
|
||||
"action": "nuke",
|
||||
"method": "get",
|
||||
"label": "Nuke ads",
|
||||
"icon": "fa-solid fa-bomb",
|
||||
},
|
||||
]
|
||||
return context
|
||||
|
||||
|
|
Loading…
Reference in New Issue