Begin implementing ad deduplication and re-enable releasing

This commit is contained in:
2023-04-18 11:25:56 +01:00
parent 84871d5a7c
commit 2b7e83dc0d
4 changed files with 44 additions and 15 deletions

View File

@@ -81,6 +81,19 @@ class AdRedist(LoginRequiredMixin, OTPRequiredMixin, View):
return render(request, self.template_name, context)
class AdDedup(LoginRequiredMixin, OTPRequiredMixin, View):
template_name = "mixins/partials/notify.html"
def get(self, request):
platforms = get_platforms(request.user)
for platform in platforms:
run = synchronize_async_helper(AgoraClient(platform))
synchronize_async_helper(run.strip_duplicate_ads())
context = {"class": "success", "message": "Ads deduplicated"}
return render(request, self.template_name, context)
class AdList(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
list_template = "partials/ad-list.html"
model = Ad
@@ -123,6 +136,14 @@ class AdList(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
"icon": "fa-solid fa-bomb",
"confirm": True,
},
{
"url": reverse("ad_dedup"),
"action": "deduplicate",
"method": "get",
"label": "Deduplicate ads",
"icon": "fa-thin fa-copy",
"confirm": True,
},
]
return context