Settting up rights structure

I’m working on my first Django project. A Shift planning app. I’ve got all the ingredients working. Now I try to figure out how to setup ownership. What I want is this:
structure

  1. Site and User both have an OwnerID field added
  2. When owner is logged in he should see only his sites, users and accordingly shifts
  3. Now I also want: when User is logged in he should only sees shifts and sites from his own Owner

I can’t get my head arround how to do this. Some help would be appriciated

Let’s walk this through step-by-step.

Given a person who is logged in:

  • How you you know they’re the owner?
  • What would your query be for their Sites?
  • What would your query be for their Users?
  • What then would your query be for their Shifts?

If it is a User who is logged in:

  • How do you identify their Owner?
    (Once you know the Owner, then the rest of the queries are the same as above.)

Hi Ken, Here is what I have done so far:

Owner setup

Models with a Owner ID Foreignkey related to the model Owner

  1. Customer
  2. Site
  3. SiteAddress
  4. Function
  5. Shiftuser

When Owner is logged in he sees only his own Customers, Sites, SiteAddresses, Functions and Shiftusers.

The Shifts can be filtered by the owners set in these linked models.

The Shiftuser should also see his own Shifts and the Sites of the same owner as Shiftuser.

In the future I consider to make this application a SAAS solution. But for now I want more than one owner to use the software with their own data set.

Pointing me in a direction to set this up is very appreciated

Ok, I guess I’m confused. What is the question or issue that you’re having here? If you can write the queries I listed above, what are you having difficulties with?

I just wanted to know if this is a right approach. I do this for the first time. I’m gonna work on the query’s now and will come back if there are any issues?

I don’t see any issues with it - take that for what it’s worth.

We’ll still be here!