We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 4587760 + 73951fb commit 79d8344Copy full SHA for 79d8344
adserver/forms.py
@@ -903,6 +903,16 @@ def save(self, commit=True):
903
for field in fields:
904
setattr(self.instance, field, getattr(self.old_flight, field))
905
906
+ # Set sold impressions/clicks appropriately based on supplied budget
907
+ if self.cleaned_data["budget"] > 0 and self.instance.cpm > 0:
908
+ self.instance.sold_impressions = int(
909
+ self.cleaned_data["budget"] * 1000 / float(self.instance.cpm)
910
+ )
911
+ elif self.cleaned_data["budget"] > 0 and self.instance.cpc > 0:
912
+ self.instance.sold_clicks = int(
913
+ self.cleaned_data["budget"] / float(self.instance.cpc)
914
915
+
916
# We must set the campaign
917
self.instance.campaign = (
918
self.old_flight.campaign
0 commit comments