-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/46 producttype nl api #23
base: master
Are you sure you want to change the base?
Conversation
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.
Generally looks good I think. Nothing is broken. The use of the exclude field is generally bad
From the default project:
Check that ModelForms use Meta.fields instead of Meta.exclude.
ModelForm.Meta.exclude is dangerous because it doesn't protect against
fields that are added later. Explicit white-listing is safer and prevents
bugs such as IMA #645.
Also a few questions and random remarks
Should be Changed (or can be changed quickly):
- Formatted translation might cause issues
- Use
self.get_queryset()
instead of the model - use
fields = (.....)
instead ofexclude = (.....)
==> easier to understand and removes unexpected fields - Reverses instead of hard coded URLS
Could Be Changed:
- Should use
self.client
get/post/patch/put instead ofBaseApiTestCase
methods - Test that fields are actually set on basic creation tests
- Perform database stuff after validation i.e. do not perform if not validated
- Related to the last: only test for errors if the field is not none
Minor Suggestions:
- Simple serializers not in the files matching their name
- Might want to move API to separate direction but that can probably wait or just not be done
router.py
should beurls.py
- using a nested router for
actuele-prijzen
I think? - (Some) validation can be moved to validators
- Could use DRF status enum
- Some better ordering in prijs update
I will not be here next week, so I cannot review changes for a while
from open_producten.producttypen.models import Bestand, ProductType | ||
|
||
|
||
# TODO does not have viewset |
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.
Is this still the case?
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.
Yes. Is there a reason why?
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.
Bestand needs a special serializer to be able to upload files which I not gotten working.
serializer_class=ProductTypeActuelePrijsSerializer, | ||
url_path="actuele-prijzen", | ||
) | ||
def actuele_prijzen(self, request): |
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 seems wrong to me or at least the URL.
What if in the future you want prices but for one product type?
Should it not be all producttypen/alles-actuele-prijzen/
or is producttypen/actuele-prijzen/
for all and producttypen/<id>/actuele-prijzen/
for one fine?
Not too familiar with API design TBH. Might be something you want to ask in slack
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.
Added producttypen/<id>/actuele-prijs
. This also seems to be the correct way in drf using @action(detail=True)
|
||
def test_update_prijs_creating_and_deleting_opties(self): | ||
prijs = self._create_prijs() | ||
PrijsOptieFactory.create(prijs=prijs) |
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.
prijs_optie = PrijsOptieFactory.create(prijs=prijs)
if you delete prijs_optie, its id will be set to -1 which might be useful. Not sure if it works with custom ids though
Should be Changed (or can be changed quickly):
Could Be Changed:
Minor Suggestions: Simple serializers not in the files matching their name -> what to do about circular dependency?
|
Changes
Notes