daisylb / bridgekeeper

Django permissions, but with QuerySets
https://bridgekeeper.leigh.party/
MIT License
41 stars 14 forks source link

Remove the model class argument from Relation #3

Closed daisylb closed 5 years ago

daisylb commented 6 years ago

Currently, Relation has the signature Relation(attribute_name, model_class, rule). Having the model_class argument is kind of a pain; ideally, Relation and Attribute should have matching signatures, and we should figure out the model class to construct a QuerySet from when .query() is called. (What would really be ideal is if we could pass a Q object directly into {attr}__in, but Django doesn't let us do that.)

daisylb commented 6 years ago

ManyRelation is even uglier: it takes four args, when really it should just take two.

daisylb commented 5 years ago

This message on django-developers gives a function that adds a prefix to everything in a Q object, which should have the same effect as being able to go Q(foo__in=Q(...)).