Models:
Company
Product
We have a parent company (owner of all) who can create any Company
and any Product
, as sub-Company or sub-Product.
Now, what I'd like to accomplish, is limiting which Company can CRUD other Companies and Products alike.
Here's are the scenarios:
Company and Sub-Companies (sub-contractors):
Master (creates) -> Company “A”
Master (creates) -> Company “B” (creates) -> Company “C”
Master (creates) -> Company “D” (creates) -> Company “F” (creates) -> Company “G”
Company and Product Assignment:
Master (Add Product) -> Show all products
Master (assign products to top levels) -> Company “A”, Company “B” and Company ”D”
Sub-Company Product Assignment (management):
Company “B” (assign products only to sub-level) -> Company “C”
Company “D” (assign products only to sub-level) -> Company “F”
Company “F” (assign products only to sub-level) -> Company “G”
However, if Company D
removes a product from a sub-level, this will also remove from all sub-level products recursively.
Are there any sure ways of doing this with Django core, or perhaps there's a recommended library out there that I'm not finding? I also saw in the Django docs reference to Model Meta options
and the Options.permissions
method... but I'm not sure that's what I'm needing either.