mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 10:31:50 +01:00
@@ -153,7 +153,7 @@ class AdPartial(ContextualModel):
|
||||
"""
|
||||
Returns a complete, validated Ad by merging this partial with values from ad_defaults.
|
||||
|
||||
Any field that is `None` or `""` is filled from `ad_defaults`.
|
||||
Any field that is `None` or `""` is filled from `ad_defaults` when it's not a list.
|
||||
|
||||
Raises `ValidationError` when, after merging with `ad_defaults`, not all fields required by `Ad` are populated.
|
||||
"""
|
||||
@@ -162,7 +162,7 @@ class AdPartial(ContextualModel):
|
||||
target = ad_cfg,
|
||||
defaults = ad_defaults.model_dump(),
|
||||
ignore = lambda k, _: k == "description", # ignore legacy global description config
|
||||
override = lambda _, v: v in {None, ""} # noqa: PLC1901 can be simplified
|
||||
override = lambda _, v: not isinstance(v, list) and v in {None, ""} # noqa: PLC1901 can be simplified
|
||||
)
|
||||
return Ad.model_validate(ad_cfg)
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ class AdDefaults(ContextualModel):
|
||||
price_type:Literal["FIXED", "NEGOTIABLE", "GIVE_AWAY", "NOT_APPLICABLE"] = "NEGOTIABLE"
|
||||
shipping_type:Literal["PICKUP", "SHIPPING", "NOT_APPLICABLE"] = "SHIPPING"
|
||||
sell_directly:bool = Field(default = False, description = "requires shipping_type SHIPPING to take effect")
|
||||
images:List[str] | None = Field(default = None)
|
||||
contact:ContactDefaults = Field(default_factory = ContactDefaults)
|
||||
republication_interval:int = 7
|
||||
|
||||
|
||||
Reference in New Issue
Block a user