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

Make product variant attributes required in API #2911

Conversation

oldPadavan
Copy link
Contributor

@oldPadavan oldPadavan commented Sep 19, 2018

I want to merge this change because...

closes #2879

Screenshots

Pull Request Checklist

  1. Privileged views and APIs are guarded by proper permission checks.
  2. All visible strings are translated with proper context.
  3. All data-formatting is locale-aware (dates, numbers, and so on).
  4. Database queries are optimized and the number of queries is constant.
  5. The changes are tested.
  6. The code is documented (docstrings, project documentation).
  7. GraphQL schema and type definitions are up to date.

Copy link
Contributor

@Pacu2 Pacu2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work overall, thanks for picking this up! Just tiny bits and bobs to clean up


@classmethod
def clean_input(
cls, info, instance, input, errors, check_all_attrs_provided=True):
Copy link
Contributor

@Pacu2 Pacu2 Sep 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we rename it to check_if_...? It would be more natural
Also, is there any case when we shouldn't check if all attrs are provided?
I wonder if this variable is really necessary or we should always check if all product's attributes are present

tests/api/test_variant.py Show resolved Hide resolved
@@ -332,7 +332,19 @@ class Meta:
model = models.ProductVariant

@classmethod
def clean_input(cls, info, instance, input, errors):
def check_all_product_type_attributes_provided(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename it to check_if... ? or even clean_product_type_attributes

@codecov
Copy link

codecov bot commented Sep 19, 2018

Codecov Report

Merging #2911 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2911      +/-   ##
==========================================
+ Coverage   89.55%   89.55%   +<.01%     
==========================================
  Files         207      207              
  Lines       10615    10622       +7     
  Branches     1027     1030       +3     
==========================================
+ Hits         9506     9513       +7     
  Misses        794      794              
  Partials      315      315
Impacted Files Coverage Δ
saleor/graphql/product/mutations/products.py 95.84% <100%> (+0.07%) ⬆️
saleor/account/i18n.py 94.24% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 306802d...d416554. Read the comment docs.

attributes: $attributes,
trackInventory: $trackInventory,
weight: $weight
attributes: $attributes
}) {
errors {
field
message
}
productVariant {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's unnecessary as well.

return super(ProductVariantUpdate, cls).clean_input(
info, instance, input, errors, check_all_attrs_provided=False)
return super().get_cleaned_input(
info, instance, input, errors, check_if_all_attrs_provided=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In such case, one can update ProductVariant and write its attributes partly. I think we should always check if all attrs are provided.

Copy link
Contributor

@Pacu2 Pacu2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's perfect, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User can create a variant without attributes
3 participants