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

DRF Serializers dont call model clean #433

Closed
2 of 3 tasks
Tracked by #421
jon-nfc opened this issue Dec 19, 2024 · 0 comments · Fixed by #443
Closed
2 of 3 tasks
Tracked by #421

DRF Serializers dont call model clean #433

jon-nfc opened this issue Dec 19, 2024 · 0 comments · Fixed by #443
Assignees
Labels
bug::regression Bug reason type::bug Issue Type v1.4.0 Version Affected. v1.5.0 Version Affected. v1.6-beta Version Affected.
Milestone

Comments

@jon-nfc
Copy link
Member

jon-nfc commented Dec 19, 2024

A change was made in DRF 3.0 that removed the feature from the Serializers that calls the models clean method.

Serilaizers within Centurion still need to call a models clean method.

Details

We use the Model clean method as it was intended, to make any changes that must be done to a model prior to saving, regardless of the data ingress point.

As we move Centurion to be predominately an API application, 99% of data ingress will be via a serializer, and the lack of calling the clean method from a serializer is not an issue. However, we do have management commands and have celery tasks as data ingress points. As such a models clean method is still in play and required that it be called.

discovered models affected.

$ grep -a 'clean(' -r . | grep -a -v cache | grep -a '.py' | grep -a 'model'
./core/models/manufacturer.py:    def clean(self):
./settings/models/app_settings.py:    def clean(self):
./settings/management/commands/device_model.py:                software.clean()
./settings/management/commands/device_model.py:                software.clean()
./itam/models/device.py:    def clean(self):
./itam/models/device_models.py:    def clean(self):
./itam/models/software.py:    def clean(self):
./itam/models/software.py:    def clean(self):
$ 

Testing

Any model that has a clean method, must be tested to ensure that the clean method is called prior to saving the model.

Links

Requirements

  • Manufacturers moved to global org on creation/update
    When a global org is set and manufactures as global is true, ALL manufacturers on creation are supposed to be moved to the global organization. This is not occurring.
  • Audit remaining global model options to ensure functioning
  • 🧪 Test to ensure model clean is being called #445
@jon-nfc jon-nfc moved this to Backlog in Centurion ERP Dec 19, 2024
@jon-nfc jon-nfc added type::bug Issue Type bug::regression Bug reason labels Dec 19, 2024
@jon-nfc jon-nfc added this to the Next Release milestone Dec 19, 2024
@jon-nfc jon-nfc mentioned this issue Dec 19, 2024
10 tasks
@jon-nfc jon-nfc moved this from Backlog to Planning in Centurion ERP Dec 19, 2024
@jon-nfc jon-nfc changed the title Manufactures not moved to global organization DRF Serializers dont call model clean Dec 20, 2024
@jon-nfc jon-nfc moved this from Planning to Backlog in Centurion ERP Dec 20, 2024
@jon-nfc jon-nfc self-assigned this Dec 20, 2024
@jon-nfc jon-nfc moved this from Backlog to In progress in Centurion ERP Dec 20, 2024
@jon-nfc jon-nfc added v1.4.0 Version Affected. v1.5.0 Version Affected. v1.6-beta Version Affected. labels Dec 21, 2024
@jon-nfc jon-nfc moved this from In progress to Stale in Centurion ERP Dec 23, 2024
@jon-nfc jon-nfc moved this from Stale to Backlog in Centurion ERP Dec 23, 2024
@jon-nfc jon-nfc moved this from Backlog to In progress in Centurion ERP Dec 23, 2024
@jon-nfc jon-nfc moved this from In progress to Done in Centurion ERP Dec 23, 2024
@jon-nfc jon-nfc linked a pull request Dec 23, 2024 that will close this issue
9 tasks
@jon-nfc jon-nfc closed this as completed Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug::regression Bug reason type::bug Issue Type v1.4.0 Version Affected. v1.5.0 Version Affected. v1.6-beta Version Affected.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant