I would appreciate help with the concept of how to implement the following.
I have a User A who wants to allow a single additional User B to administer their account. For this example User B should only have access to their own account and User A’s account.
The idea that I have in mind is that User B logs into their own account, where there would be some link to a page called, for example, “other admin”, which displays a list of other accounts that they have permission to administer, or none as the case maybe.
So, User B clicks on the link to administer User A’s account, which outputs a list of items, for example, from A’s AccountDetails model, using a view something like this;
class ListInfo(ListView):
model = AccountDetails
template_name = 'account/list_template.html'
def get_queryset(self):
qs = AccountDetails.objects.filter(user=self.request.user.pk)
return qs
and to make this work, I would have to write some code to;
a. Check that User B is still authorised to access User A’s account
b. Use User A’s pk instead of User B’s for each query.
and, I would have to do this on every single view, probably via a Mixin.
Limiting permissions (add, change, delete, view) is something that I want to implement later, so please ignore it for the purposes of this question.
My question is, am I on the right track here?
Does anyone have any other ideas on a better way of implementing this, or better still the flow or code from a working example?