openwisp / django-netjsonconfig

Configuration manager for embedded devices, implemented as a reusable django-app
http://openwisp.org
Other
194 stars 60 forks source link

[Fixes #78][Models] django-ondelta Implemented #84

Closed atb00ker closed 6 years ago

atb00ker commented 6 years ago

[Optimisation] In order to avoid extra query in the clean() in device.py & config.py ondelta is integrated.

Fixes #78

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.2%) to 99.802% when pulling af4b85a4f6e9cdbe7cd3127a8af4e1e1b9ae8b7b on atb00ker:master into e9bb45a34696c34cfb0ff4df4639cdcd87f1f9b1 on openwisp:master.

atb00ker commented 6 years ago

Since, test_status_modified_after_change in test_config.py, line 166 test_config_status_modified in test_device.py , line 47 Already check the final result is correct or not, i didn't implement the tests, i'll work on coverage. :smile:

atb00ker commented 6 years ago

Problem faced while implementing ondelta: _state.adding value is always false in the ondelta functions.

def clean(self):
    print(self._state.adding) # Output: True
    ...

def ondelta_[Field](self, old_value, new_value):
    print(self._state.adding) # Output: False | [Expected: True]
    ...

To solve this, i created a new variable customStateAdding in clean(), However if the ondelta() is called before the clean() the code breaks, this might cause unintentional bugs.

nemesifier commented 6 years ago

thanks for trying @atb00ker. I appreciate the fact that you didn't want to push for changes that could cause unintentional bugs. If you're looking for more issues on which you can contribute, ping me