Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added code field to product resource, which was added to oscar #57

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions oscar_odin/mappings/catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ def product_class(self, value) -> ProductClassModel:
"description": {constants.PRODUCT_DESCRIPTION},
"is_discountable": {constants.PRODUCT_IS_DISCOUNTABLE},
"priority": {constants.PRODUCT_PRIORITY},
"code": {constants.PRODUCT_CODE},
}

@classmethod
Expand Down
1 change: 1 addition & 0 deletions oscar_odin/mappings/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
PRODUCT_STRUCTURE = "Product.structure"
PRODUCT_IS_PUBLIC = "Product.is_public"
PRODUCT_UPC = "Product.upc"
PRODUCT_CODE = "Product.code"
PRODUCT_PARENT = "Product.parent"
PRODUCT_TITLE = "Product.title"
PRODUCT_SLUG = "Product.slug"
Expand Down
1 change: 1 addition & 0 deletions oscar_odin/resources/catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class ProductResource(OscarCatalogueResource):
"""A product within Django Oscar."""

id: Optional[int]
code: Optional[str]
upc: Optional[str]
structure: str = StringField(choices=ProductModel.STRUCTURE_CHOICES)
title: str
Expand Down
1,502 changes: 822 additions & 680 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ classifiers = [

[tool.poetry.dependencies]
python = "^3.8"
django-oscar = {version = "^4.0a1", allow-prereleases = true}
django-oscar = {git = "https://github.com/django-oscar/django-oscar.git", allow-prereleases = true}
coverage = { version = "^7.3", optional = true }
pylint = { version = "^3.0.2", optional = true }
black = { version = "^23.11.0", optional = true }
Expand Down
16 changes: 2 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# this setup.py script is completely generated dynamically by poetry and
# is needed to be able to integrate this project in tools that are based on setuptools
from pathlib import Path
from setuptools import setup

from poetry.core.factory import Factory
from poetry.core.masonry.builders.sdist import SdistBuilder

# let poetry construct setupt.py
cwd_path = Path(".").resolve()
poetry = Factory().create_poetry()
sdist_builder = SdistBuilder(poetry)
setup_py = sdist_builder.build_setup()

# run setup in the current context
exec(setup_py, globals(), locals())
setup()
4 changes: 4 additions & 0 deletions tests/mappings/test_catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def test_get_mapped_fields(self):
"attributes",
"categories",
"children",
"code",
"date_created",
"date_updated",
"description",
Expand Down Expand Up @@ -116,6 +117,7 @@ def test_get_mapped_fields(self):
"availability",
"categories",
"children",
"code",
"currency",
"date_created",
"date_updated",
Expand Down Expand Up @@ -148,6 +150,7 @@ def test_get_mapped_fields(self):
"attributes",
"categories",
"children",
"code",
"date_created",
"date_updated",
"description",
Expand Down Expand Up @@ -177,6 +180,7 @@ def test_get_mapped_fields(self):
sorted(demfields),
[
"Category.code",
"Product.code",
"Product.description",
"Product.is_discountable",
"Product.is_public",
Expand Down
2 changes: 2 additions & 0 deletions tests/reverse/test_catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def test_create_product_with_related_fields(self):

product_resource = ProductResource(
upc="1234323-2",
code="semek-mumtaz",
title="asdf2",
slug="asdf-asdfasdf2",
description="description",
Expand Down Expand Up @@ -125,6 +126,7 @@ def test_create_product_with_related_fields(self):

product_resource = ProductResource(
upc="1234323-2",
code="haind-berrit",
title="asdf2",
structure=Product.STANDALONE,
price=D("21.50"),
Expand Down
Loading