Hi,
I am using my custom permission mixin on several of my apps's models (not all).
For the case when I need to merge from the "old - context" permission to the "new - context" permission I want to have function which changes the corresponding permission reference attribute in all models, which subclassed this mixin.
How do I know which models subclassed this permission mixin and that they have the inherited permission reference attribute?
In fact I want to have such function in my mixin:
@classmethod
def merge_to(cls, from_perm_context, to_perm_context):
perm_context_models = [] # How to get this?
try:
with transaction.atomic():
for model in perm_context_models:
model.objects.filter(
perm_context=from_perm_context,
).update(perm_context=to_perm_context)
except IntegrityError as e: # or DatabaseError
raise e
Thanks,
Radek