Skip to content

Commit

Permalink
refactor 📦 revert product resource clean method
Browse files Browse the repository at this point in the history
  • Loading branch information
samar-hassan committed Dec 9, 2024
1 parent 14c52e9 commit e190da5
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 112 deletions.
27 changes: 0 additions & 27 deletions oscar_odin/resources/catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@

import odin
from odin.fields import StringField
from odin.exceptions import ValidationError as OdinValidationError, NON_FIELD_ERRORS

from ..fields import DecimalField

OscarResource = get_class("oscar_odin.resources.base", "OscarResource")

PartnerResource = get_class("oscar_odin.resources.partner", "PartnerResource")
StockRecordResource = get_class("oscar_odin.resources.partner", "StockRecordResource")

ProductModel = get_model("catalogue", "Product")
Expand Down Expand Up @@ -137,28 +135,3 @@ class ProductResource(OscarCatalogueResource):
children: Optional[List["ProductResource"]] = odin.ListOf.delayed(
lambda: ProductResource, null=True
)

def clean(self):
if (
not self.stockrecords
and (self.price is not None or self.availability is not None)
and not (
self.upc is not None
and self.currency is not None
and self.partner is not None
)
):
errors = {
NON_FIELD_ERRORS: [
"upc, currency and partner are required when specifying price or availability"
]
}
# upc is allready required so we don't need to check for it here
if (
self.currency is None
): # currency has a default but it can be set to null by accident
errors["currency"] = ["Currency can not be empty."]
if self.partner is None:
errors["partner"] = ["Partner can not be empty."]

raise OdinValidationError(errors, code="simpleprice")
Empty file removed tests/resources/__init__.py
Empty file.
85 changes: 0 additions & 85 deletions tests/resources/test_catalogue.py

This file was deleted.

0 comments on commit e190da5

Please sign in to comment.