refactor: reformatted code
This commit is contained in:
@@ -173,9 +173,7 @@ def upload_ad_image(
|
|||||||
advertiser_id=advertiser_id,
|
advertiser_id=advertiser_id,
|
||||||
)
|
)
|
||||||
if ad_image.size >= 10 * 1024 * 1024:
|
if ad_image.size >= 10 * 1024 * 1024:
|
||||||
raise HttpError(
|
raise HttpError(status.BAD_REQUEST, "File can't be bigger than 10MB.")
|
||||||
status.BAD_REQUEST, "File can't be bigger than 10MB."
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
Image.open(ad_image).verify()
|
Image.open(ad_image).verify()
|
||||||
except (OSError, SyntaxError):
|
except (OSError, SyntaxError):
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ from apps.campaign.validators import (
|
|||||||
CampaignLimitsValidator,
|
CampaignLimitsValidator,
|
||||||
CampaignReportMessageValidator,
|
CampaignReportMessageValidator,
|
||||||
CampaignStartDateValidator,
|
CampaignStartDateValidator,
|
||||||
|
CampaignTargetingGenderValidator,
|
||||||
CampaignTargetingLocationValidator,
|
CampaignTargetingLocationValidator,
|
||||||
CampaignTargetingGenderValidator
|
|
||||||
)
|
)
|
||||||
from apps.client.models import Client
|
from apps.client.models import Client
|
||||||
from apps.core.models import BaseModel
|
from apps.core.models import BaseModel
|
||||||
@@ -385,14 +385,16 @@ class Campaign(BaseModel):
|
|||||||
else 1
|
else 1
|
||||||
)
|
)
|
||||||
|
|
||||||
prioritized.append((
|
prioritized.append(
|
||||||
|
(
|
||||||
campaign,
|
campaign,
|
||||||
{
|
{
|
||||||
"profit": profit,
|
"profit": profit,
|
||||||
"ml": ml_score,
|
"ml": ml_score,
|
||||||
"capacity": 1 - capacity_ratio,
|
"capacity": 1 - capacity_ratio,
|
||||||
},
|
},
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if not ml_values or not profit_values:
|
if not ml_values or not profit_values:
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ from typing import TYPE_CHECKING
|
|||||||
|
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.db.models.fields import Field
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from apps.campaign.models import Campaign, CampaignReport
|
from apps.campaign.models import Campaign, CampaignReport
|
||||||
@@ -21,6 +20,7 @@ class CampaignTargetingGenderValidator:
|
|||||||
err = "gender can't be blank."
|
err = "gender can't be blank."
|
||||||
raise ValidationError(err)
|
raise ValidationError(err)
|
||||||
|
|
||||||
|
|
||||||
class CampaignAgeValidator:
|
class CampaignAgeValidator:
|
||||||
def __call__(self, instance: "Campaign") -> None:
|
def __call__(self, instance: "Campaign") -> None:
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user