-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Allow to create attribute values from product form #1973
Allow to create attribute values from product form #1973
Conversation
saleor/dashboard/product/forms.py
Outdated
|
||
# if the passed attribute value is a string, | ||
# create the attribute value. | ||
if not isinstance(value, AttributeChoiceValue): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block is the same as in VariantAttributeForm
, maybe we can make a function from it?
@akjanik You were right about duplicated code, so I've extracted a form mixin that handles dynamic attributes fields in the same way in both product and variant form. I think the code looks a bit better now. Also, I've taken the opportunity and dropped |
Codecov Report
@@ Coverage Diff @@
## master #1973 +/- ##
=========================================
Coverage ? 84.95%
=========================================
Files ? 161
Lines ? 6892
Branches ? 699
=========================================
Hits ? 5855
Misses ? 849
Partials ? 188
Continue to review full report at Codecov.
|
|
||
def iter_attribute_fields(self): | ||
for attr in self.available_attributes: | ||
yield self[attr.get_formfield_name()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be rather self.fields[attr.get_formfield_name()]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can access fields in this way as well. It was here before so I didn't change it.
This PR is follow-up to #1964. Just as with variant attributes, it introduces the ability to create new attribute values from the product form.
Pull Request Checklist
pycodestyle
,pydocstyle
,pylint
.eslint
.