django-polymorphic / django-polymorphic-tree

Polymorphic MPTT tree support for models
Other
171 stars 44 forks source link

Fix parent field name different from 'parent' #57

Closed singleton11 closed 7 years ago

singleton11 commented 7 years ago

If PolymorphicTreeForeignKey field name has name which different from 'parent' there was an error in admin Added test for case above Actualized tox and travis configs Added step-by-step instruction to readme how to run tests Adjusted supported version list in readme

codecov-io commented 7 years ago

Current coverage is 54.87% (diff: 98.76%)

Merging #57 into master will increase coverage by 9.55%

@@             master        #57   diff @@
==========================================
  Files            12         13     +1   
  Lines           631        707    +76   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits            286        388   +102   
+ Misses          345        319    -26   
  Partials          0          0          

Powered by Codecov. Last update 61debd4...06e26a0

singleton11 commented 7 years ago

Added possibility to make validation before move node in admin through can_be_moved method of PolymorphicMPTTModel overriding. This method calls in admin, and if there are exceptions during execution, error response returns

vdboor commented 7 years ago

Thanks for this wonderful work!

vdboor commented 7 years ago

@singleton11 I do wonder, is can_be_moved() needed? For example, there is already can_have_children() which does about the same thing. Where are you using that hook for?

I've also merged some other fixes, so please merge/rebase before you add a new fix ;-)

vdboor commented 7 years ago

@singleton11 FYI, I've renamedcan_move_to() to validate_move_to() Since we can limit the children types now, would you still need validate_move_to() to exist? Thanks for letting me know!

singleton11 commented 7 years ago

@vdboor, I promise, I will send different features as separate PRs next time ;-)

mptt doesn't call clean() to check, if validation error occurs, when move_to() executed.

Yes, I need to do clean() before moving. Hovewer it's not a django-polymorhic-tree problem, therefore I made this hook. I don't know where to add clean() calling in django-mptt